Skip to content

Commit 4c38036

Browse files
committed
Centralized storage
1 parent a5dc52c commit 4c38036

File tree

26 files changed

+1051
-111
lines changed

26 files changed

+1051
-111
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Centralized configuration storages
2+
3+
Sample applications demonstrating how to store configuration data in one place using Tarantool or etcd-based storage. Learn more at [Centralized configuration storages](https://www.tarantool.io/en/doc/latest/concepts/configuration/configuration_etcd/).
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# 1. Remove the 'default.etcd' directory to reset etcd to initial state.
4+
# 2. Start etcd by executing the 'etcd' command.
5+
# 3. Execute this script to enable authentication.
6+
etcdctl user add root:topsecret
7+
etcdctl role add myapp_config_manager
8+
etcdctl role grant-permission myapp_config_manager --prefix=true readwrite /myapp/
9+
etcdctl user add sampleuser:123456
10+
etcdctl user grant-role sampleuser myapp_config_manager
11+
etcdctl auth enable
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# etcd configuration storage
2+
3+
A sample application demonstrating how to obtain a cluster's configuration from the etcd-based configuration storage.
4+
5+
## Running
6+
7+
Before running this sample, start etcd and enable authentication by executing [etcd_config_storage.sh](../../etcd_config_storage.sh).
8+
9+
To start all instances, execute the following command in the [centralized_config](../../../centralized_config) directory:
10+
11+
```console
12+
$ tt start config_etcd
13+
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /myapp
6+
username: sampleuser
7+
password: '123456'
8+
http:
9+
request:
10+
timeout: 3
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Tarantool configuration storage
2+
3+
A sample application demonstrating how to obtain a cluster's configuration from the Tarantool-based configuration storage.
4+
5+
## Running
6+
7+
Before running this sample, start a Tarantool-based configuration storage: [tarantool_config_storage](../tarantool_config_storage).
8+
9+
To start all instances, execute the following command in the [centralized_config](../../../centralized_config) directory:
10+
11+
```console
12+
$ tt start config_storage
13+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
config:
2+
storage:
3+
endpoints:
4+
- uri: '127.0.0.1:4401'
5+
login: sampleuser
6+
password: '123456'
7+
- uri: '127.0.0.1:4402'
8+
login: sampleuser
9+
password: '123456'
10+
- uri: '127.0.0.1:4403'
11+
login: sampleuser
12+
password: '123456'
13+
prefix: /myapp
14+
timeout: 3
15+
reconnect_after: 5
16+
17+
# Watch key changes
18+
app:
19+
file: 'myapp.lua'
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
net_box = require('net.box')
2+
local conn = net_box.connect('127.0.0.1:4401')
3+
local log = require('log')
4+
conn:watch('config.storage:/myapp/config/all', function(key, value)
5+
log.info("Configuration stored by the '/myapp/config/all' key is changed")
6+
end)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Setting up Tarantool configuration storage
2+
3+
A sample application demonstrating how to set up Tarantool configuration storage.
4+
5+
## Running
6+
7+
To start all instances of the configuration storage, execute the following command in the [centralized_config](../../../centralized_config) directory:
8+
9+
```console
10+
$ tt start tarantool_config_storage
11+
```

0 commit comments

Comments
 (0)