-
Notifications
You must be signed in to change notification settings - Fork 52
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
Allow Configuration of Subscription Channels #93
Conversation
e49da81
to
0ba3142
Compare
{ | ||
var overrideOpts = subChannelOpts.Value; | ||
return new BoundedChannelOptions(overrideOpts.Capacity ?? | ||
DefaultChannelOptions.Capacity) |
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.
It seemed better from a maintenance perspective to fallback to DefaultChannelOptions
rather than re-specify defaults for these. If preferred I can just re-specify defaults however.
src/NATS.Client.Core/NatsSub.cs
Outdated
@@ -55,7 +55,7 @@ public abstract class NatsSubBase : INatsSub | |||
_cts.Token.UnsafeRegister( | |||
static (self, _) => | |||
{ | |||
((NatsSubBase) self!).EndSubscription(NatsSubEndReason.Cancelled); | |||
((NatsSubBase)self!).EndSubscription(NatsSubEndReason.Cancelled); |
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.
Linter complained about this so I went ahead and did it. If revert is preferred LMK.
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.
Make sure to run dotnet format
. That should fix these issues as well.
@@ -1,3 +1,5 @@ | |||
using System.Threading.Channels; |
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 this using
came in because of the XmlDoc, if preferred I can just use full type name in xmldoc?
@to11mtm couls you rebase please? There are no conflicts but it'd be easier to see without warnings etc. which was fixed afterwards. |
0ba3142
to
216583a
Compare
216583a
to
33538dd
Compare
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
There is value in being able to configure the
BoundedChannelOptions
for a given subscription (or series of subscriptions.)For example, in cases where it is preferred to discard older data on a subscription, or cases where only the most recent value is the one that is desired.
This PR also has the benefit, in the default case, we can just re-use our internal
BoundedChannelOptions
rather than passing a new one every time a new subscription is created (i.e. less memory allocation.)Note that for the sake of reuse, this marked
internal static
onNatsSub
rather thanprivate static
, since to have a separate static readonly onNatsSub<T>
would both be unnecessary and would cause a new static to be allocated for every newT
onNatsSub<T>
.