Service discovery tool
Project description
= Empusa
`Empusa` is a trivial tool to build a *service registry* on top of https://etcd.io/[`etcd`]. etcd alone serves as a key/value store, while `empusa` handles the keys, their structure, and values to implement the functionality of a trivial service registry.
== Usage
Main command, `empusa`, provides several subcommands, dedicated to different aspects of the service registry operation.
[source,shell]
....
$ empusa --help
Usage: empusa [OPTIONS] COMMAND [ARGS]...
Options:
--etcd-endpoint HOST:PORT [required]
--etcd-protocol TEXT
--tree-root TEXT [required]
--help Show this message and exit.
Commands:
service
....
Two bits of information are always required:
* etcd endpoint - host and port where `etcd` listens for client connections. Use `--etcd-endpoint` command-line option, or `EMPUSA_ETCD_ENDPOINT` environment variable.
+
[NOTE]
====
At this moment, only the first `etcd` endpoint is used, the rest is ignored. In the future, multiple endpoints will be supported.
====
+
* tree root - path in the key hierarchy under which `empusa` would store it's data. `empusa --tree-root /foo` will not read nor modify data `empusa --tree-root /bar` created. Use `--tree-root` command-line option, or `EMPUSA_TREE_ROOT` environment variable.
=== Services
Services come in different types, e.g. HTTP server, SMTP server, Prometheus exporter, internal directory service, and so on. Of each type, usualy multiple instances exist, each having a different name and location. `emposa` treats service types as directories to which each instance, identified by its name, is added together with its location.
To register a service, execute following command:
[source,shell]
....
$ empusa service register --service-type type-of-service --service-name name-of-the-service-instance --service-location baz:1235
....
It is possible to use environment variables instead of command-line options:
[source,shell]
....
$ EMPUSA_SERVICE_TYPE=type-of-service \
EMPUSA_SERVICE_NAME=name-of-the-service-instance \
EMPUSA_SERVICE_LOCATION=baz:1235 \
empusa service register
....
The service can be unregistered as well:
[source,shell]
....
$ empusa service unregister --service-type type-of-service --service-name name-of-the-service-instance
....
A service remains registered until explicitly removed. This may not be always possible, e.g. sometimes the services dies without any chance to perform teardown actions including update to the service registry. To help with this situation, a TTL can be set during registration, in seconds. After that time, the service is removed from the registry.
[source,shell]
....
$ empusa service register ... --ttl 30
....
The service must then periodicaly update the registry, updating its record and extending the TTL before it expires. You can either have your own scripts to perform this, or you can use `empusa`'s `--refresh-every` option:
[source,shell]
....
$ empusa service register ... --ttl 30 --refresh-every 20
....
Every 20 seconds, `empusa` would update the registry, setting the TTL to 30 seconds. Should the service die unexpectedly, `empusa` would not have an opportunity to prolong the TTL, and `etcd` would remove service's key.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
empusa-0.0.1.tar.gz
(6.1 kB
view details)
Built Distribution
File details
Details for the file empusa-0.0.1.tar.gz
.
File metadata
- Download URL: empusa-0.0.1.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Linux/5.2.18-100.fc29.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d01f4b0f39d8814a50359a158cc2489c0341dad6701b0f3110e1a1e053746bd5 |
|
MD5 | 62fd70c08fdccb6e81af68d27267854a |
|
BLAKE2b-256 | 3b6813ce3cd9aac7ad46628a2cd3dfd86839f04d315a7af3fbf9f39339731c73 |
File details
Details for the file empusa-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: empusa-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.7.4 Linux/5.2.18-100.fc29.x86_64
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0fa31b005c64c2894e06b5d7492fc72db0c8f6fa4556ad6e017fc2fd218fd9a |
|
MD5 | 925cba291569403cc6094042cbf8ab32 |
|
BLAKE2b-256 | 3d9440aef3ad6524f307c0dbd982f749a8e44e5d718967953069223ce952d522 |