-
Notifications
You must be signed in to change notification settings - Fork 705
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
[ADDED] Creating iterators for sync subscriptions #1728
Conversation
Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
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.
Some questions and clarifications requeted.
return nc.subscribe(subj, _EMPTY_, nil, mch, true, nil) | ||
var errCh chan error | ||
if nc.Opts.PermissionErrOnSubscribe { | ||
errCh = make(chan error, 100) |
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 wonder what is the proper size for this channel.
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.
Good question, I set it to some value without thinking much about this and kind of forgot to analyze it properly. Since we really only push permission errors on this channel and we do it once per subscription, a buffered channel with size 1 should suffice (so that it's not blocking).
} | ||
subject := matches[1] | ||
for _, sub := range nc.subs { | ||
if sub.Subject == subject && sub.Queue == q && sub.permissionsErr == nil { |
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.
sub.Queue
would be ""
if it's non-queue group subscription, right?
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.
Exactly, so if there is no match for the regex, q
will also be ""
and it will fulfill this condition.
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.
LGTM
This PR adds iterator capabilities to core NATS subscription. This API extends only to sync subscriptions.
Additionally, this adds an opt-in
PermissionErrOnSubscribe
option, which (if set) causessub.NextMsg()
to return permission error if encountered. Due to backwards compatibility this option is disabled by default, but we could consider enabling it by default in future releases.Signed-off-by: Piotr Piotrowski piotr@synadia.com