Skip to content
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

Merged
merged 13 commits into from
Jun 15, 2021

Conversation

tychoish
Copy link
Contributor

@tychoish tychoish commented Apr 22, 2021

Addresses #3931

@tychoish tychoish marked this pull request as draft April 22, 2021 21:05
@codecov
Copy link

codecov bot commented Apr 23, 2021

Codecov Report

Merging #6386 (5b3e13f) into master (007eeb9) will decrease coverage by 4.77%.
The diff coverage is 17.81%.

@@            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     
Impacted Files Coverage Δ
abci/client/grpc_client.go 0.00% <0.00%> (ø)
abci/client/local_client.go 0.00% <0.00%> (ø)
abci/types/application.go 0.00% <0.00%> (ø)
abci/types/pubkey.go 0.00% <0.00%> (ø)
abci/types/result.go 23.07% <0.00%> (ø)
abci/types/util.go 0.00% <0.00%> (ø)
cmd/tendermint/commands/gen_node_key.go 0.00% <ø> (ø)
cmd/tendermint/commands/gen_validator.go 18.18% <ø> (+18.18%) ⬆️
cmd/tendermint/commands/init.go 3.27% <ø> (+3.27%) ⬆️
cmd/tendermint/commands/light.go 24.27% <ø> (ø)
... and 426 more

@tychoish tychoish marked this pull request as ready for review April 23, 2021 21:13
@tessr tessr changed the title rpc: add subscritpion id to events rpc: add subscription id to events Apr 23, 2021
@github-actions
Copy link

github-actions bot commented May 4, 2021

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.

@github-actions github-actions bot added the stale for use by stalebot label May 4, 2021
Copy link
Contributor

@cmwaters cmwaters left a 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

@@ -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)
Copy link
Contributor

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

Copy link
Contributor Author

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.

libs/pubsub/pubsub.go Outdated Show resolved Hide resolved
if err != nil {
return fmt.Errorf("failed to parse query: %w", err)
args.ID = query
Copy link
Contributor

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?

Copy link
Contributor Author

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?)

@tychoish tychoish requested a review from cmwaters May 5, 2021 14:17
@github-actions github-actions bot closed this May 10, 2021
@tessr tessr reopened this May 10, 2021
@cmwaters cmwaters removed the stale for use by stalebot label May 11, 2021
Copy link
Contributor

@cmwaters cmwaters left a 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.

@github-actions
Copy link

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.

@github-actions github-actions bot added the stale for use by stalebot label May 25, 2021
@tac0turtle tac0turtle removed the stale for use by stalebot label May 25, 2021
@tac0turtle
Copy link
Contributor

@tac0turtle
Copy link
Contributor

is this ready to be merged?

@tychoish tychoish added the S:automerge Automatically merge PR when requirements pass label Jun 14, 2021
@mergify mergify bot merged commit 886519e into tendermint:master Jun 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S:automerge Automatically merge PR when requirements pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants