Skip to content

Commit b07b8e1

Browse files
committed
Applications: use new roles in the 'crud' sample
1 parent 7a8cd2d commit b07b8e1

File tree

3 files changed

+29
-45
lines changed

3 files changed

+29
-45
lines changed

doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster_crud/config.yaml

+14-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ sharding:
1919

2020
groups:
2121
storages:
22-
roles: [storage]
22+
roles: [roles.crud-storage]
23+
app:
24+
module: storage
2325
sharding:
2426
roles: [storage]
2527
replication:
@@ -48,7 +50,17 @@ groups:
4850
listen:
4951
- uri: '127.0.0.1:3305'
5052
routers:
51-
roles: [router]
53+
roles: [roles.crud-router]
54+
roles_cfg:
55+
roles.crud-router:
56+
stats: true
57+
stats_driver: metrics
58+
stats_quantiles: false
59+
stats_quantile_tolerated_error: 0.001
60+
stats_quantile_age_buckets_count: 5
61+
stats_quantile_max_age_time: 180
62+
app:
63+
module: router
5264
sharding:
5365
roles: [router]
5466
replicasets:
Original file line numberDiff line numberDiff line change
@@ -1,17 +1 @@
11
local vshard = require('vshard')
2-
local crud = require('crud')
3-
4-
local M = {}
5-
6-
function M.validate()
7-
end
8-
9-
function M.apply()
10-
crud.init_router()
11-
end
12-
13-
function M.stop()
14-
crud.stop_router()
15-
end
16-
17-
return M
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
local crud = require('crud')
2-
3-
local M = {}
4-
5-
function M.validate()
6-
end
7-
8-
function M.apply()
9-
crud.init_storage()
10-
if box.info.ro ~= true then
11-
box.schema.create_space('bands', {
12-
format = {
13-
{ name = 'id', type = 'unsigned' },
14-
{ name = 'bucket_id', type = 'unsigned' },
15-
{ name = 'band_name', type = 'string' },
16-
{ name = 'year', type = 'unsigned' }
17-
},
18-
if_not_exists = true
19-
})
20-
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
21-
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
1+
box.watch('box.status', function()
2+
if box.info.ro then
3+
return
224
end
23-
end
24-
25-
function M.stop()
26-
crud.stop_storage()
27-
end
285

29-
return M
6+
box.schema.create_space('bands', {
7+
format = {
8+
{ name = 'id', type = 'unsigned' },
9+
{ name = 'bucket_id', type = 'unsigned' },
10+
{ name = 'band_name', type = 'string' },
11+
{ name = 'year', type = 'unsigned' }
12+
},
13+
if_not_exists = true
14+
})
15+
box.space.bands:create_index('id', { parts = { 'id' }, if_not_exists = true })
16+
box.space.bands:create_index('bucket_id', { parts = { 'bucket_id' }, unique = false, if_not_exists = true })
17+
end)

0 commit comments

Comments
 (0)