-
Notifications
You must be signed in to change notification settings - Fork 182
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
refactor: rm async_trait and add trait_variant #186
Conversation
pub trait Catalog: std::fmt::Debug { | ||
/// see https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html | ||
#[trait_variant::make(Catalog: Send)] | ||
pub trait LocalCatalog: std::fmt::Debug { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need this LocalCatalog
variant? I think it would be enough to have a thread safe one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the better approach would be like FileWriter
trait, which adds Send
for each return type:
pub trait Catalog: Debug + Send {
fn list_namespace(&self, parent: Option<&NamespeceIdent>) -> impl Future<Output =
Result<Vec<NamespaceIdent>>> + Send;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal was to minimize code changes as much as possible. There are 13 methods and 2 implementations of Catalog
, while trait_variant
is a one-line change. I personally prefer async fn
over impl Future
since it looks neater. But it is true that LocalCatalog
is never used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm hesitating adding this LocalCatalog
trait. Also async fn
seems much more concise to me. Maybe we should close this pr before finding a better approach?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are adding a rewrite
feature to rewrite a trait instead of creating 2 variants. We can wait till it's done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that's great! Let's wait for this.
cc @odysa Should we close this? |
@liurenjie1024 Yes, we can close this and reopen it after they release the rewrite feature. |
Close #139
Use
trait_variant::make
to support async fn in pub traits. It creates 2 traits ----LocalCatalog
for single thread andCatalog
withSend
for multithreaded runtime.