-
Notifications
You must be signed in to change notification settings - Fork 169
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
add queue subscriber and unit test #388
Conversation
Signed-off-by: Steve <[email protected]>
@@ -725,15 +735,38 @@ impl Client { | |||
format!("_INBOX.{}", nuid::next()) | |||
} | |||
|
|||
pub async fn queue_subscribe( | |||
&mut self, | |||
subject: String, |
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 didn't want to stray from your existing conventions, but it would be slightly more ergonomic for the signature of subscribe to be
fn subscribe<T:ToString>(&self, subject: T)
and for queue_subscribe to be
fn queue_subscribe<T1:ToString,T2:ToString>(&self, subject: T1, queue_group: T2)
Or, if they are to be unified into a single subscribe function, then
fn subscribe<T1:ToString,T2:ToString>(&self, subject: T1, queue_group: Option<T2>)
If you're ok with either of those, I can also implement it on the next commit.
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.
ToString
allocates, even if you pass String
.
Into<String>
is a better option here, though we decided to NOT have that right now, as we might add Subject
type later, which would break API.
We refrained from having those helpers to allow ourselves to decide later.
Both @caspervonb and I want to be very clear in the codebase - especially in publish
which can happen thousands of times per second - what is allocated etc.
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 hesitant towards doing this because the ToString
implementation for String is a deep clone, it could be Into<String>
which should be a move but personally I'm more for explicit conversions than implicit ones as the caller is in control of how the conversion happens.
We're considering if we want a (potentially interned) type for Subject
s, header names will likely get one in the form of HeaderName
s from the http crate's API.
I'd say hold off on this for now, at-least until the subject-type matter is resolved.
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.
Short notice: So far #222 is ready for review and completely integrated the Subject
type and a AsSubject
trait into the old code base. It may went unnoticed with all the async rewriting process.
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.
Hey @stevelr, appreciate the test driving, feedback and PRs! 😁
LGTM
add queue subscription and unit test
there are a couple open questions on function naming (see TODO in code)
Signed-off-by: Steve [email protected]