Xuanwo commented on code in PR #3464:
URL:
https://github.com/apache/incubator-opendal/pull/3464#discussion_r1379689140
##########
bindings/python/src/layers.rs:
##########
@@ -92,14 +71,18 @@ impl RetryLayer {
if let Some(min_delay) = min_delay {
retry = retry.with_min_delay(Duration::from_micros((min_delay *
1000000.0) as u64));
}
- Ok(Self(retry))
+
+ let retry_layer = Self(retry);
+ let class =
PyClassInitializer::from(Layer(Box::new(retry_layer.clone())))
+ .add_subclass(retry_layer);
+
+ Ok(class)
}
}
pub fn create_submodule(py: Python) -> PyResult<&PyModule> {
let submod = PyModule::new(py, "layers")?;
- submod.add_class::<ConcurrentLimitLayer>()?;
- submod.add_class::<ImmutableIndexLayer>()?;
+ submod.add_class::<Layer>()?;
Review Comment:
> Yes, we should forbid users to subclass `Layer`.
In fact, I'm not sure about this. Can users from python can implement this
trait?
##########
bindings/python/src/layers.rs:
##########
@@ -92,14 +71,18 @@ impl RetryLayer {
if let Some(min_delay) = min_delay {
retry = retry.with_min_delay(Duration::from_micros((min_delay *
1000000.0) as u64));
}
- Ok(Self(retry))
+
+ let retry_layer = Self(retry);
+ let class =
PyClassInitializer::from(Layer(Box::new(retry_layer.clone())))
+ .add_subclass(retry_layer);
+
+ Ok(class)
}
}
pub fn create_submodule(py: Python) -> PyResult<&PyModule> {
let submod = PyModule::new(py, "layers")?;
- submod.add_class::<ConcurrentLimitLayer>()?;
- submod.add_class::<ImmutableIndexLayer>()?;
+ submod.add_class::<Layer>()?;
Review Comment:
> Yes, we should forbid users to subclass `Layer`.
In fact, I'm not sure about this. Can users from python implement this trait?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]