forked from fl00r/go-tarantool-1.6
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
connection-pool: implement connection pool with master discovery
Main features: - Return available connection from pool according to round-robin strategy. - Automatic master discovery by `mode` parameter. Additional options (configurable via `ConnectWithOpts`): * `CheckTimeout` - time interval to check for connection timeout and try to switch connection `Mode` parameter: * `ANY` (use any instance) - the request can be executed on any instance (master or replica). * `RW` (writeable instance (master)) - the request can only be executed on master. * `RO` (read only instance (replica)) - the request can only be executed on replica. * `PREFER_RO` (prefer read only instance (replica)) - if there is one, otherwise fallback to a writeable one (master). * `PREFER_RW` (prefer write only instance (master)) - if there is one, otherwise fallback to a read only one (replica). Closes #113
- Loading branch information
Showing
13 changed files
with
3,050 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
-- Do not set listen for now so connector won't be | ||
-- able to send requests until everything is configured. | ||
box.cfg{ | ||
work_dir = os.getenv("TEST_TNT_WORK_DIR"), | ||
} | ||
|
||
box.once("init", function() | ||
box.schema.user.create('test', { password = 'test' }) | ||
box.schema.user.grant('test', 'read,write,execute', 'universe') | ||
|
||
local s = box.schema.space.create('testPool', { | ||
id = 520, | ||
if_not_exists = true, | ||
format = { | ||
{name = "key", type = "string"}, | ||
{name = "value", type = "string"}, | ||
}, | ||
}) | ||
s:create_index('pk', { | ||
type = 'tree', | ||
parts = {{ field = 1, type = 'string' }}, | ||
if_not_exists = true | ||
}) | ||
end) | ||
|
||
local function simple_incr(a) | ||
return a + 1 | ||
end | ||
|
||
rawset(_G, 'simple_incr', simple_incr) | ||
|
||
-- Set listen only when every other thing is configured. | ||
box.cfg{ | ||
listen = os.getenv("TEST_TNT_LISTEN"), | ||
} |
Oops, something went wrong.