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

Fix cancel_all_subscriptions API #762

Closed
abitmore opened this issue Mar 21, 2018 · 5 comments
Closed

Fix cancel_all_subscriptions API #762

abitmore opened this issue Mar 21, 2018 · 5 comments
Assignees
Labels
1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2f Testing Status indicating the solution is being evaluated against the test case(s) 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 API Impact flag identifying the application programing interface (API) api bug

Comments

@abitmore
Copy link
Member

abitmore commented Mar 21, 2018

For clients, it's not broken. However, the implementation need to be improved. It now calls set_subscribe_callback( std::function<void(const fc::variant&)>(), true). I think using true as the second parameter here meant to clear filters according to the API document, but the document was wrong. The set_subscribe_callback function will always clear filters, and its second parameter is for something else, setting it to true may trigger an exception when #752 is done.

Update:

The set_subscribe_callback documentation has been fixed in develop branch.

This ticket is to rewrite cancel_all_subscriptions to do real cleanups, and perhaps refactor
it and set_subscribe_callback to call same cleanup function rather than having same code in both functions.

@jmjatlanta
Copy link
Contributor

jmjatlanta commented Mar 21, 2018

The documentation states that the boolean is indeed intended to clear filters. The code however says that this boolean dictates if a notification is sent on object creation and removal.

If set to true, an FC_ASSERT can fail if the application option "enable subscribe to all" is not set (note: this assert is not in the master branch, but does exist in the develop branch).

For details see

void database_api_impl::set_subscribe_callback( std::function<void(const variant&)> cb, bool notify_remove_create )

Therefore, the fix would be to adjust the documentation. Correct?

@abitmore abitmore added this to the Next Non-Consensus-Changing Release milestone Mar 24, 2018
@abitmore
Copy link
Member Author

Therefore, the fix would be to adjust the documentation. Correct?

The set_subscribe_callback documentation has been fixed in develop branch.

This ticket is to rewrite cancel_all_subscriptions to do real cleanups, and perhaps refactor
it and set_subscribe_callback to call same cleanup function rather than having same code in both functions.

@abitmore abitmore modified the milestones: 201806 - Non-Consensus-Changing Release, 201807 - Next Non-Consensus-Changing Release May 21, 2018
@ryanRfox ryanRfox added 1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2b Gathering Requirements Status indicating currently refining User Stories and defining Requirements 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 API Impact flag identifying the application programing interface (API) 2c Ready for Development Status indicating the Requirements are sufficent to begin designing a solution and removed 2b Gathering Requirements Status indicating currently refining User Stories and defining Requirements labels May 24, 2018
@jmjatlanta
Copy link
Contributor

Questions:

  1. Should database_api::set_subscribe_callback(func) clear the _subscribed_accounts collection? (It currently does.)
  2. Should database_api::set_subscribe_callback(func) clear the _market_subscriptions collection? (It currently does not.)

I cannot imagine a real use case, but here is a contrived example:

  • set_subscribe_callback(A) is called
  • accounts and markets are subscribed to
  • set_subscribe_callback(B) is called

Would the user expect that the previous subscriptions to (1) accounts and (2) markets be maintained?

@abitmore
Copy link
Member Author

Related discussion: #726 #774 #777.

@jmjatlanta jmjatlanta self-assigned this May 28, 2018
@ryanRfox ryanRfox added 2f Testing Status indicating the solution is being evaluated against the test case(s) and removed 2c Ready for Development Status indicating the Requirements are sufficent to begin designing a solution labels Jun 13, 2018
abitmore added a commit that referenced this issue Jul 21, 2018
Refactor cancel_all_subscriptions (Issue #762)
@abitmore
Copy link
Member Author

Merged #1009. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1b User Story The User Story details a requirement. It may reference a parent Epic. It may reference child Task(s) 2f Testing Status indicating the solution is being evaluated against the test case(s) 3d Bug Classification indicating the existing implementation does not match the intention of the design 6 API Impact flag identifying the application programing interface (API) api bug
Projects
None yet
Development

No branches or pull requests

3 participants