Skip to content

Commit f54107c

Browse files
committed
Applications: hello world role sample
1 parent 1a39ddb commit f54107c

File tree

3 files changed

+35
-0
lines changed

3 files changed

+35
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
roles: [greeter]
8+
roles_cfg:
9+
greeter:
10+
greeting: 'Hi'
11+
iproto:
12+
listen:
13+
- uri: '127.0.0.1:3301'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- greeter.lua --
2+
local log = require('log')
3+
4+
local M = {}
5+
6+
function M.validate(cfg)
7+
if cfg.greeting then
8+
assert(type(cfg.greeting) == "string", "'greeting' should be a string")
9+
assert(cfg.greeting == ("Hi" or "Hello"), "'greeting' should be 'Hi' or 'Hello'")
10+
end
11+
end
12+
13+
function M.apply(cfg)
14+
log.info("%s from the 'greeter' role!", cfg.greeting)
15+
end
16+
17+
function M.stop(cfg)
18+
log.info("The 'greeter' role is stopped")
19+
end
20+
21+
return M
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:

0 commit comments

Comments
 (0)