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

Implement unscubscribe on event stream #1991

Conversation

stana-miric
Copy link
Contributor

@stana-miric stana-miric commented Oct 16, 2023

Description

This PR implements unsubscribe on event stream, that will be called when subscription is closed. Earlier event stream held slice of update channels which belonged to subscriptions and were used to notify subscription when the event is received (push fn). The problem here was if some subscription is closed, its update channel was not removed from the event stream, and since it is buffered channel of 5 events, after the buffer was full and events kept coming, push function was blocked on writing to that channel preventing other subscriptions to receive events. Earlier there was default branch, but we removed it to avoid loosing events.
With this fix events stream is changed to have map of subscription and when unsubscribe is called on event stream that will remove the subscription and close subscription channel.

Changes include

  • Bugfix (non-breaking change that solves an issue)
  • Hotfix (change that solves an urgent issue, and requires immediate attention)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (change that is not backwards-compatible and/or changes current functionality)

Checklist

  • I have assigned this PR to myself
  • I have added at least 1 reviewer
  • I have added the relevant labels
  • I have updated the official documentation
  • I have added sufficient documentation in code

Testing

  • I have tested this code with the official test suite
  • I have tested this code manually

@stana-miric stana-miric added the bug fix Functionality that fixes a bug label Oct 16, 2023
@stana-miric stana-miric requested a review from a team October 16, 2023 06:34
@stana-miric stana-miric self-assigned this Oct 16, 2023
@stana-miric stana-miric force-pushed the EVM-863-after-closing-subscriber-update-channel-is-not-removed-from-event-stream branch 2 times, most recently from f7383b3 to cff11ad Compare October 16, 2023 07:11
@stana-miric stana-miric force-pushed the EVM-863-after-closing-subscriber-update-channel-is-not-removed-from-event-stream branch from cff11ad to 67886e6 Compare October 16, 2023 08:34
blockchain/subscription.go Outdated Show resolved Hide resolved
blockchain/subscription.go Outdated Show resolved Hide resolved
blockchain/subscription.go Outdated Show resolved Hide resolved
blockchain/subscription_test.go Outdated Show resolved Hide resolved
@stana-miric stana-miric merged commit 72a7e3a into develop Oct 18, 2023
10 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2023
@Stefan-Ethernal Stefan-Ethernal deleted the EVM-863-after-closing-subscriber-update-channel-is-not-removed-from-event-stream branch October 20, 2023 07:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fix Functionality that fixes a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants