-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Merged by Bors] - refactor: simplified control plane api #3073
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f6db42e
to
c05d69d
Compare
migrate to downcast
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
May 4, 2023
This PR implements a more generalized admin API. The existing Admin API uses a macro to map the admin type to a global object type. While this works, it requires maintaining a mapping relationship every time a new admin type is added. In addition, mapping for each action (create, delete, watch) has a slightly different kind of encoding, which adds to the complexity. The underlying complexity is that with the current Rust typing system, converting Traits with associated properties to trait objects is not allowed. Hence use of macro to map handle encoding and decoding. With this PR, type mapping is lazily done. Borrowing from `Arc` and `Anyhow` approaches, downcasting/upcasting is delayed much as possible. This preserves type-specific Admin type calls, but extending to any arbitrary admin object types is possible. The core of the new approach is this trait: ``` pub trait TryEncodableFrom<T>: Sized + Encoder + Decoder { fn try_encode_from(value: T, version: Version) -> Result<Self>; fn downcast(&self) -> Result<Option<T>>; } ``` Using fluvio's encoder/decoder, any arbitrary can be mapped into the binary blog and vice versa. Once received from the network, the encoded type can be downcast to a specific type as necessary. The changes are fully backward compatible. The existing macro is used when talking to the previous version of Fluvio. The backward compatibility codes (classic) will be removed in the future.
Canceled. |
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
May 4, 2023
This PR implements a more generalized admin API. The existing Admin API uses a macro to map the admin type to a global object type. While this works, it requires maintaining a mapping relationship every time a new admin type is added. In addition, mapping for each action (create, delete, watch) has a slightly different kind of encoding, which adds to the complexity. The underlying complexity is that with the current Rust typing system, converting Traits with associated properties to trait objects is not allowed. Hence use of macro to map handle encoding and decoding. With this PR, type mapping is lazily done. Borrowing from `Arc` and `Anyhow` approaches, downcasting/upcasting is delayed much as possible. This preserves type-specific Admin type calls, but extending to any arbitrary admin object types is possible. The core of the new approach is this trait: ``` pub trait TryEncodableFrom<T>: Sized + Encoder + Decoder { fn try_encode_from(value: T, version: Version) -> Result<Self>; fn downcast(&self) -> Result<Option<T>>; } ``` Using fluvio's encoder/decoder, any arbitrary can be mapped into the binary blog and vice versa. Once received from the network, the encoded type can be downcast to a specific type as necessary. The changes are fully backward compatible. The existing macro is used when talking to the previous version of Fluvio. The backward compatibility codes (classic) will be removed in the future.
Build failed: |
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
May 4, 2023
This PR implements a more generalized admin API. The existing Admin API uses a macro to map the admin type to a global object type. While this works, it requires maintaining a mapping relationship every time a new admin type is added. In addition, mapping for each action (create, delete, watch) has a slightly different kind of encoding, which adds to the complexity. The underlying complexity is that with the current Rust typing system, converting Traits with associated properties to trait objects is not allowed. Hence use of macro to map handle encoding and decoding. With this PR, type mapping is lazily done. Borrowing from `Arc` and `Anyhow` approaches, downcasting/upcasting is delayed much as possible. This preserves type-specific Admin type calls, but extending to any arbitrary admin object types is possible. The core of the new approach is this trait: ``` pub trait TryEncodableFrom<T>: Sized + Encoder + Decoder { fn try_encode_from(value: T, version: Version) -> Result<Self>; fn downcast(&self) -> Result<Option<T>>; } ``` Using fluvio's encoder/decoder, any arbitrary can be mapped into the binary blog and vice versa. Once received from the network, the encoded type can be downcast to a specific type as necessary. The changes are fully backward compatible. The existing macro is used when talking to the previous version of Fluvio. The backward compatibility codes (classic) will be removed in the future.
Pull request successfully merged into master. Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR implements a more generalized admin API.
The existing Admin API uses a macro to map the admin type to a global object type. While this works, it requires maintaining a mapping relationship every time a new admin type is added. In addition, mapping for each action (create, delete, watch) has a slightly different kind of encoding, which adds to the complexity. The underlying complexity is that with the current Rust typing system, converting Traits with associated properties to trait objects is not allowed. Hence use of macro to map handle encoding and decoding.
With this PR, type mapping is lazily done. Borrowing from
Arc
andAnyhow
approaches, downcasting/upcasting is delayed much as possible. This preserves type-specific Admin type calls, but extending to any arbitrary admin object types is possible.The core of the new approach is this trait:
Using fluvio's encoder/decoder, any arbitrary can be mapped into the binary blog and vice versa. Once received from the network, the encoded type can be downcast to a specific type as necessary.
The changes are fully backward compatible. The existing macro is used when talking to the previous version of Fluvio. The backward compatibility codes (classic) will be removed in the future.