Skip to content

Commit

Permalink
refactor(bindings/python): Refactor layout for python bindings (apach…
Browse files Browse the repository at this point in the history
…e#3473)

* remove submodule

Signed-off-by: Xuanwo <[email protected]>

* refactor(bindings/python): Refactor layout for python bindings

Signed-off-by: Xuanwo <[email protected]>

---------

Signed-off-by: Xuanwo <[email protected]>
  • Loading branch information
Xuanwo authored Nov 3, 2023
1 parent e3b1164 commit 318decc
Show file tree
Hide file tree
Showing 7 changed files with 829 additions and 722 deletions.
14 changes: 4 additions & 10 deletions bindings/python/src/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@

use std::time::Duration;

use ::opendal as od;
use opendal::Operator;
use pyo3::prelude::*;

use crate::*;

pub trait PythonLayer: Send + Sync {
fn layer(&self, op: Operator) -> Operator;
}
Expand All @@ -30,7 +31,7 @@ pub struct Layer(pub Box<dyn PythonLayer>);

#[pyclass(module = "opendal.layers", extends=Layer)]
#[derive(Clone)]
pub struct RetryLayer(od::layers::RetryLayer);
pub struct RetryLayer(ocore::layers::RetryLayer);

impl PythonLayer for RetryLayer {
fn layer(&self, op: Operator) -> Operator {
Expand All @@ -55,7 +56,7 @@ impl RetryLayer {
max_delay: Option<f64>,
min_delay: Option<f64>,
) -> PyResult<PyClassInitializer<Self>> {
let mut retry = od::layers::RetryLayer::default();
let mut retry = ocore::layers::RetryLayer::default();
if let Some(max_times) = max_times {
retry = retry.with_max_times(max_times);
}
Expand All @@ -79,10 +80,3 @@ impl RetryLayer {
Ok(class)
}
}

pub fn create_submodule(py: Python) -> PyResult<&PyModule> {
let submod = PyModule::new(py, "layers")?;
submod.add_class::<Layer>()?;
submod.add_class::<RetryLayer>()?;
Ok(submod)
}
Loading

0 comments on commit 318decc

Please sign in to comment.