The idea behind delix is the create an overlay network that connects microservices. It uses semantic addressing and takes care of encryption, fail-over and load balancing.
cargo install delix
Run three delix nodes in three different terminals.
delix -c example/one.conf.toml
delix -c example/two.conf.toml
delix -c example/three.conf.toml
The node one
opens an interface at 127.0.0.1:4200
which take http requests. All nodes have the service slashdot
configured. In order to request a response from the service run...
curl -H 'Host: slashdot.org' -H 'X-Delix-Service: slashdot' http://127.0.0.1:4200
Let's dive into the config file of node one.
```toml [log] type = "console" level = "debug"
[metric] type = "terminal" refreshintervalms = 100
[discovery] type = "constant" addresses = [ ]
[transport] type = "direct" localaddress = "localhost:4001" requesttimeoutms = 5000 balancer = { type = "dynamicround_robin" }
[[relay]] type = "httpstatic" address = "localhost:4200" headerfield = "X-Delix-Service"
[[relay.service]] name = "slashdot" address = "slashdot.org:80" ```
The discovery
section contains the field addresses
which holds a list of IPs (with ports) that is used during
the node's boot up to search for other nodes. Since node one
is the first, the list is empty here.
In order to bind a node to an interface, local_address
in the transport
section must be set. If the interface
differs from the interface visible to other nodes, the field public_address
can be set.
The relay
section at the end, defines here a http_static
relay that opens a port at address
that takes HTTP
requests. The header_field
in the request tells delix to which service the request should be routed to. The services
are defined in the relay.service
section and define a name and an address which defines the endpoint where the
request is send. In this example it's the slashdot server.
The code is licensed under Apache 2.0.