Skip to content

Conversation

@calvin681
Copy link
Collaborator

@calvin681 calvin681 commented Jul 15, 2022

Context

There is an implicit assumption that subscription should be 1. Before, the subscriptionActive gauge is always set to 1 whenever there is at least 1 subscription. I change that to increment/decrement on subscribe/unsubscribe to more accurately reflect the number of subscriptions. Before, the unsubscribe was purposely commented out. Clearly, this can lead to multiple subscription, which violates the assumption. With this change, we will unsubscribe the old subscription when a new subscription is created. This should correct keep active subscription at 1.

Checklist

  • ./gradlew build compiles code correctly
  • Added new tests where applicable
  • ./gradlew test passes all tests
  • Extended README or added javadocs where applicable
  • Added copyright headers for new files from CONTRIBUTING.md

@github-actions
Copy link

github-actions bot commented Jul 15, 2022

Unit Test Results

489 tests  ±0   481 ✔️ ±0   5m 24s ⏱️ -7s
111 suites ±0       8 💤 ±0 
111 files   ±0       0 ±0 

Results for commit 08846a3. ± Comparison against base commit b202912.

♻️ This comment has been updated with latest results.


));
// decouple from calling thread
.observeOn(Schedulers.computation())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts on computation scheduler vs IO scheduler for this task?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I wonder why we need to specify a schedule at all. It can just run on whatever scheduler it's already running on. @hmitnflx do you know? Maybe I can just remove this line.

Copy link
Contributor

@sundargates sundargates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

subscriptionActive.decrement();
})
.subscribe((T data) -> queue.write(data)
,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move this to the previous line?

@calvin681 calvin681 merged commit 706f216 into Netflix:master Jul 20, 2022
calvin681 added a commit that referenced this pull request Jul 22, 2022
* Ensure there is only 1 subscription

* clean up some formatting

* fix scheduler

Co-authored-by: Calvin Cheung <ccheung@netflix.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants