-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
router: auto and manual enable/disable
This patch introduces protecting router's API while its configuration is not done as accessing these functions at that time is not safe and can cause low level errors like 'bad arguments' or 'no such function'. Now all non-trivial vshard.router functions are disabled until `vshard.router.cfg` (or `vshard.router.new`) is finished and error is raised in case of an attempt to access them. Manual API's enabling/disabling is also introduced in this patch. Closes #194 Closes #291 @TarantoolBot document Title: vshard.router.enable/disable() `vshard.router.disable()` makes most of the `vshard.router` functions throw an error. As Lua exception, not via `nil, err` pattern. `vshard.router.enable()` reverts the disable. `router_object:enable()/disable()`, where `router_object` is the return value of `vshard.router.new()`, can also be used for manual API access configuration for the specific non-static router. By default the router is enabled. Additionally, the router is forcefully disabled automatically until its configuration is finished and the instance finished recovery (its `box.info.status` is `'running'`, for example). Auto-disable protects from usage of vshard functions before the router's global state is fully created. Manual router's disabling helps to achieve the same for user's application. For instance, a user might want to do some preparatory work after `vshard.router.cfg` before the application is ready. Then the flow would be: ```Lua vshard.router.disable() vshard.router.cfg(...) -- Do your preparatory work here ... vshard.router.enable() ``` The behavior of the router's API enabling/disabling is similar to the storage's one.
- Loading branch information
1 parent
20263e0
commit dd70cfb
Showing
5 changed files
with
208 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters