Last active
August 24, 2023 00:16
-
-
Save Totktonada/6339517a32cd7df4ac7df700fc3fa6b8 to your computer and use it in GitHub Desktop.
Tarantool 3.0.0-alpha2 (demo)
This file contains hidden or 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
credentials: | |
users: | |
replicator: | |
password: 'topsecret' | |
roles: [replication] | |
storage: | |
password: 'secret' | |
roles: [super] | |
iproto: | |
listen: 'unix/:./var/run/{{ instance_name }}.iproto' | |
advertise: | |
peer: replicator@ | |
sharding: storage@ | |
sharding: | |
bucket_count: 10000 | |
groups: | |
storages: | |
app: | |
module: storage | |
sharding: | |
roles: [storage] | |
replication: | |
failover: manual | |
replicasets: | |
storage-a: | |
leader: storage-a-001 | |
instances: | |
storage-a-001: {} | |
storage-a-002: {} | |
storage-b: | |
leader: storage-b-002 | |
instances: | |
storage-b-001: {} | |
storage-b-002: {} | |
routers: | |
app: | |
module: router | |
sharding: | |
roles: [router] | |
replicasets: | |
router-a: | |
instances: | |
router-a-001: {} |
This file contains hidden or 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
sharding.storage-a-001: | |
sharding.storage-a-002: | |
sharding.storage-b-001: | |
sharding.storage-b-002: | |
sharding.router-a-001: |
This file contains hidden or 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
local vshard = require('vshard') | |
vshard.router.bootstrap() | |
function put(id, data) | |
local bucket_id = vshard.router.bucket_id_mpcrc32({id}) | |
vshard.router.callrw(bucket_id, 'put', {id, bucket_id, data}) | |
end | |
function get(id) | |
local bucket_id = vshard.router.bucket_id_mpcrc32({id}) | |
return vshard.router.callro(bucket_id, 'get', {id}) | |
end |
This file contains hidden or 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
box.schema.create_space('s', { | |
format = { | |
{'id', 'unsigned'}, | |
{'bucket_id', 'unsigned'}, | |
{'data', 'string'}, | |
}, | |
if_not_exists = true, | |
}) | |
box.space.s:create_index('id', { | |
parts = {'id'}, | |
if_not_exists = true, | |
}) | |
box.space.s:create_index('bucket_id', { | |
parts = {'bucket_id'}, | |
unique = false, | |
if_not_exists = true, | |
}) | |
function put(id, bucket_id, data) | |
box.space.s:insert({id, bucket_id, data}) | |
end | |
function get(id) | |
local tuple = box.space.s:get(id) | |
if tuple == nil then | |
return nil | |
end | |
return {tuple.id, tuple.data} | |
end |
This file contains hidden or 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
tt: {} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment