Skip to content

Commit 798140c

Browse files
committed
Roles: update per DEV review
1 parent d398494 commit 798140c

File tree

11 files changed

+112
-115
lines changed

11 files changed

+112
-115
lines changed

doc/book/admin/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This chapter includes the following sections:
2525
:maxdepth: 2
2626
:numbered: 0
2727

28+
instance_config
2829
start_stop_instance
2930
modules
3031
logs

doc/book/cluster_app.rst

-14
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
-- greeter.lua --
22
local log = require('log').new("greeter")
33

4-
local function validate_config(cfg)
4+
local function validate(cfg)
55
if cfg.greeting then
66
assert(type(cfg.greeting) == "string", "'greeting' should be a string")
77
assert(cfg.greeting == "Hi" or cfg.greeting == "Hello", "'greeting' should be 'Hi' or 'Hello'")
88
end
99
end
1010

11-
local function apply_config(cfg)
11+
local function apply(cfg)
1212
log.info("%s from the 'greeter' role!", cfg.greeting)
1313
end
1414

15-
local function stop_role()
15+
local function stop()
1616
log.info("The 'greeter' role is stopped")
1717
end
1818

1919
return {
20-
validate = validate_config,
21-
apply = apply_config,
22-
stop = stop_role,
20+
validate = validate,
21+
apply = apply,
22+
stop = stop,
2323
}

doc/code_snippets/snippets/config/instances.enabled/application_role_http_api/http-api.lua

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
local httpd
33
local json = require('json')
44

5-
local function validate_config(cfg)
5+
local function validate(cfg)
66
if cfg.host then
77
assert(type(cfg.host) == "string", "'host' should be a string containing a valid IP address")
88
end
99
if cfg.port then
1010
assert(type(cfg.port) == "number", "'port' should be a number")
11-
assert(cfg.port >= 1 and cfg.port <= 65536, "'port' should be between 1 and 65536")
11+
assert(cfg.port >= 1 and cfg.port <= 65535, "'port' should be between 1 and 65535")
1212
end
1313
end
1414

15-
local function apply_config(cfg)
15+
local function apply(cfg)
1616
if httpd then
1717
httpd:stop()
1818
end
@@ -48,7 +48,7 @@ local function apply_config(cfg)
4848
httpd:start()
4949
end
5050

51-
local function stop_role()
51+
local function stop()
5252
httpd:stop()
5353
end
5454

@@ -59,7 +59,7 @@ end
5959
init()
6060

6161
return {
62-
validate = validate_config,
63-
apply = apply_config,
64-
stop = stop_role,
62+
validate = validate,
63+
apply = apply,
64+
stop = stop,
6565
}

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

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ credentials:
22
users:
33
replicator:
44
password: 'topsecret'
5-
roles: [replication]
5+
roles: [ replication ]
66
storage:
77
password: 'secret'
8-
roles: [sharding]
8+
roles: [ sharding ]
99

1010
iproto:
1111
advertise:
@@ -19,11 +19,11 @@ sharding:
1919

2020
groups:
2121
storages:
22-
roles: [roles.crud-storage]
22+
roles: [ roles.crud-storage ]
2323
app:
2424
module: storage
2525
sharding:
26-
roles: [storage]
26+
roles: [ storage ]
2727
replication:
2828
failover: manual
2929
replicasets:
@@ -50,7 +50,7 @@ groups:
5050
listen:
5151
- uri: '127.0.0.1:3305'
5252
routers:
53-
roles: [roles.crud-router]
53+
roles: [ roles.crud-router ]
5454
roles_cfg:
5555
roles.crud-router:
5656
stats: true
@@ -62,7 +62,7 @@ groups:
6262
app:
6363
module: router
6464
sharding:
65-
roles: [router]
65+
roles: [ router ]
6666
replicasets:
6767
router-a:
6868
instances:

doc/concepts/configuration.rst

+7-8
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Roles and configuration scopes
240240
******************************
241241

242242
As the most of configuration options, roles and their configurations can be defined at :ref:`different levels <configuration_scopes>`.
243-
Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the ``map`` type, different rules are used when applying the configuration:
243+
Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the ``map`` type, there are some specifics when applying the configuration:
244244

245245
- For ``roles``, an instance's role takes precedence over roles defined at another levels.
246246
In the example below, ``instance001`` has only ``role3``:
@@ -275,23 +275,22 @@ Given that the ``roles`` option has the ``array`` type and ``roles_cfg`` has the
275275
role1:
276276
greeting: 'Hi'
277277
278-
- If some role's option exists at one level but doesn't exist at another level, these options are merged.
279-
In the example below, ``role1.greeting`` is ``'Hi'`` and ``role1.farewell`` is ``'Goodbye'``:
278+
- Options provided in ``roles_cfg`` for different roles on different levels are merged.
279+
In the example below, ``instance001`` has ``role1.greeting`` set to ``'Hi'`` and ``role2.farewell`` set to ``'Bye'``:
280280

281281
.. code-block:: yaml
282282
283283
# ...
284284
replicaset001:
285285
roles_cfg:
286286
role1:
287-
greeting: 'Hello'
288-
farewell: 'Goodbye'
287+
greeting: 'Hi'
289288
instances:
290289
instance001:
291-
roles: [ role1 ]
290+
roles: [ role1, role2 ]
292291
roles_cfg:
293-
role1:
294-
greeting: 'Hi'
292+
role2:
293+
farewell: 'Bye'
295294
296295
297296

0 commit comments

Comments
 (0)