feat(core): add capability check#2461
Conversation
|
Hi @Xuanwo, maybe we can have a quick review of the current design, so we can make sure the direction is good to follow when implementing the rest things. |
All those related tasks are handled at |
One question for this, how should we pass the strict mode flag to the |
We can store a boolean |
Should we expose the configuration to users? Like overriding it when building the operator. |
I'm a bit hesitant about this. Maybe we can provide a |
No worrying about this, we can implement the mandatory operation-level checks first. |
|
Just updated the PR, it's now much simpler :) |
Xuanwo
left a comment
There was a problem hiding this comment.
Mostly looks good to me! Only a few minor changes.
|
Kv and TypedKv's blokcing cap is not set which results in our tests failed: https://github.com/apache/incubator-opendal/blob/main/core/src/raw/adapters/typed_kv/backend.rs#L65 Can you help fix it in this PR? |
Yep, bringing up the commits. |
|
There is still something wrong, I'm fixing it. |
Fixed #1752.
In this PR, we will only implement the capability check at operation-level.
Implementation Notes
Static dispatchingwith_strictmethod is added onOperatorBuildertype to eliminate dynamic dispatching & extra heap allocations. That will make the builtOperatorbe strict in its whole lifetime, thereforewith_strictmethod is also added onOperatorfor flexibility.Dedicated layer for checkingThe capability checking is performed inCapabilityCheckLayerto guarantee the single responsibility principle. It's also hard to mix them with any existing layer while allowing the flexible controls.Manually checking against all ops
The capability metadata is defined separately from ops (in different modules). We have to enumerate all the cases when checking, and map them manually. Fortunately, this is simplified by an internal macro, which can avoid a large amount of redundant code.
Checklist
Expose APIs for users to enable the strict mode