-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
rpc: add subscription id to events #6386
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6386 +/- ##
==========================================
- Coverage 65.99% 61.21% -4.78%
==========================================
Files 234 295 +61
Lines 20269 27914 +7645
==========================================
+ Hits 13376 17087 +3711
- Misses 5825 9110 +3285
- Partials 1068 1717 +649
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
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've just added some comments in passing as I try to understand the changes. I'm assuming this is to solve the case in #3931
The issue I understand is that we want to generate id's so that clients can cancel individual subscriptions. AFAICS, the query itself serves currently as the unique identifier for subscribing and unsubscribing i.e. a single client can subscribe to multiple queries. From this, I assume this PR therefore targets the case when a single client wants multiple subscriptions to the same query. This appears to me a bit illogical - why would I want to have multiple subscriptions of the same query? Even if multiple services where using the same query on the client side can't they handle it? Maybe I've misunderstood something
libs/pubsub/pubsub.go
Outdated
@@ -97,7 +116,7 @@ type Server struct { | |||
// check if we have subscription before | |||
// subscribing or unsubscribing | |||
mtx tmsync.RWMutex | |||
subscriptions map[string]map[string]struct{} // subscriber -> query (string) -> empty struct | |||
subscriptions map[string]map[string]string // subscriber -> query/id (string) -> id/query (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.
Does this mean it can be subscriptions[subscriber][query] -> id
as well as
subscriptions[subscriber][id] -> query`. I'm a little confused with the comments
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, subscriptions are tracked both by query and by ID in an effort to avoid breaking compatibility.
if err != nil { | ||
return fmt.Errorf("failed to parse query: %w", err) | ||
args.ID = query |
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.
Is this / will this always be the correct way to handle this error?
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 adding a comment.
I think it's fine because it'll eventually be an error if it's a bogus ID and a bogus query, but eventually when we remove subscription we can change this (in some way?)
Co-authored-by: Callum Waters <cmwaters19@gmail.com>
ff4b2cb
to
d863dde
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.
This seems all in order to me.
I still think that in the long run we should just track the subscriptions by id and not some hybrid of both.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
is this ready to be merged? |
Addresses #3931