-
Notifications
You must be signed in to change notification settings - Fork 8
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
feat: improve sink SDK experience #29
Conversation
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
examples/sink-log/src/main.rs
Outdated
success: true, | ||
err: "".to_string(), | ||
} | ||
struct Logger {} |
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.
For 'empty' struct, we can use unit struct:
struct Logger;
// value is same
sink::Server::new(Logger).start().await
src/map.rs
Outdated
@@ -127,7 +127,7 @@ pub struct Server<T> { | |||
map_svc: Option<T>, | |||
} | |||
|
|||
impl<T> Server<T> { | |||
impl<T: Mapper> Server<T> { |
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.
In Rust, usually trait bounds are specified at the locations where it is needed. Here, it would be the start
and start_with_shutdown
methods. If we are moving the trait bounds to full implementation block itself, let's remove it from the where
clause of those methods and make T: Mapper + Send + Sync + 'static
src/sink.rs
Outdated
@@ -29,43 +32,37 @@ pub trait Sinker { | |||
/// A simple log sink. | |||
/// | |||
/// ```rust,ignore |
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.
Let's make this
```no_run
to ensure code is valid and compiles.
Also, a few lines above, the doc comment still refers to the old Datum
struct
/// The sink handle is given a stream of [`Datum`].
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
Signed-off-by: Vigith Maurice <[email protected]>
No description provided.