Skip to content

Commit fb2dd55

Browse files
Docs for roles/role_cfg (#4221)
1 parent 8521c33 commit fb2dd55

File tree

24 files changed

+995
-204
lines changed

24 files changed

+995
-204
lines changed

doc/book/admin/instance_config.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ The main steps of creating and preparing the application for deployment are:
2020
In this section, a `sharded_cluster <https://github.com/tarantool/doc/tree/latest/doc/code_snippets/snippets/sharding/instances.enabled/sharded_cluster>`_ application is used as an example.
2121
This cluster includes 5 instances: one router and 4 storages, which constitute two replica sets.
2222

23-
.. image:: admin_instances_dev.png
23+
.. image:: /book/admin/admin_instances_dev.png
2424
:align: left
2525
:width: 700
2626
:alt: Cluster topology
@@ -171,7 +171,7 @@ define instances to run on each machine by changing the content of the ``instanc
171171

172172
- On the developer's machine, this file might include all the instances defined in the cluster configuration.
173173

174-
.. image:: admin_instances_dev.png
174+
.. image:: /book/admin/admin_instances_dev.png
175175
:align: left
176176
:width: 700
177177
:alt: Cluster topology
@@ -184,7 +184,7 @@ define instances to run on each machine by changing the content of the ``instanc
184184

185185
- In the production environment, this file includes instances to run on the specific machine.
186186

187-
.. image:: admin_instances_prod.png
187+
.. image:: /book/admin/admin_instances_prod.png
188188
:align: left
189189
:width: 700
190190
:alt: Cluster topology

doc/book/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ User's Guide
1717
box/index
1818
admin/index
1919
monitoring/index
20+
cluster_app
2021
connectors
2122
../reference/reference_sql/index
2223
faq
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
roles: [ greeter ]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- greeter.lua --
2+
return {
3+
validate = function() end,
4+
apply = function() require('log').info("Hi from the 'greeter' role!") end,
5+
stop = function() end,
6+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- byeer.lua --
2+
local log = require('log').new("byeer")
3+
4+
return {
5+
dependencies = { 'greeter' },
6+
validate = function() end,
7+
apply = function() log.info("Bye from the 'byeer' role!") end,
8+
stop = function() end,
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
groups:
2+
group001:
3+
replicasets:
4+
replicaset001:
5+
instances:
6+
instance001:
7+
roles: [ greeter ]
8+
roles_cfg:
9+
greeter:
10+
greeting: 'Hi'
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
-- greeter.lua --
2+
local log = require('log').new("greeter")
3+
4+
local function validate(cfg)
5+
if cfg.greeting then
6+
assert(type(cfg.greeting) == "string", "'greeting' should be a string")
7+
assert(cfg.greeting == "Hi" or cfg.greeting == "Hello", "'greeting' should be 'Hi' or 'Hello'")
8+
end
9+
end
10+
11+
local function apply(cfg)
12+
log.info("%s from the 'greeter' role!", cfg.greeting)
13+
end
14+
15+
local function stop()
16+
log.info("The 'greeter' role is stopped")
17+
end
18+
19+
return {
20+
validate = validate,
21+
apply = apply,
22+
stop = stop,
23+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
instance001:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# HTTP API
2+
3+
A sample application showing how to implement a custom `http-api` role.
4+
5+
## Running
6+
7+
To start an application, execute the following command in the [config](../../../config) directory:
8+
9+
```console
10+
$ tt start application_role_http_api
11+
```
12+
13+
## Making test requests
14+
15+
To test the API, make the following requests:
16+
17+
```console
18+
$ curl -X GET --location "http://0.0.0.0:8080/band?limit=7" \
19+
-H "Accept: application/json"
20+
$ curl -X GET --location "http://0.0.0.0:8080/band/5" \
21+
-H "Accept: application/json"
22+
```

0 commit comments

Comments
 (0)