Skip to main content

Service Routing

An application running in Data may consist of several micro-executors. To properly set up the service routing between micro-executors you can define the service mapping using a specified file called registry.yaml in your DSL library.

Registry is composed by:

  • handlers: micro-executors definition. This is a Map whose key define the micro-executor ID and its value contains:
    • url: the internal URL to perform the redirect
  • services: the list of service and relative handlers. This contains two Map:
    • names: the Map whose key is the service name and its value contains:
      • handler: the micro executor key

i.e.

registry.yaml

---
# Micro Executor List
handlers:
me-java-accounting:
url: http://me-java-accounting
me-node-warehouse:
url: http://me-node-warehouse
. . .

# Services
services:
names:
SRV_001:
handler: me-java-accounting
SRV_002:
handler: me-node-warehouse

This configuration define that application works with 2 micro-executors:

  • me-java-accounting
  • me-node-warehouse

and two service:

  • SRV_001: this service is defined into me-java-accounting
  • SRV_002: this service is defined into me-node-warehouse

This configuration is similar to nginx proxy configuration.

warning

Registry configuration require micro executor reloading on change if you work in a non develop environment

Aliases

Many applications need to define their services through effective but poorly spoken codes. It is possible to associate aliases with services so that they are more talkative.

To define an alias you can add aliases key under services key. aliases is a Map whose key is the service alias and its value is the service name.

i.e.

registry.yaml

---
# Micro Executor List
handlers:
me-java-accounting:
url: http://me-java-accounting
me-node-warehouse:
url: http://me-node-warehouse
. . .

# Services
services:
names:
SRV_001:
handler: me-java-accounting
SRV_002:
handler: me-node-warehouse

aliases:
BASIC_ACCOUNTING: SRV_001

This configuration specifies that service SRV_001 may also be invoked with the key BASIC_ACCOUNTING.

Default Micro-Executor

If you want to avoid mapping services one by one, you can define a default micro-executor that will allow it to take over all requests to services that do not have a defined mapping.

You can achieve this setting default: true at handler level.

i.e.

registry.yaml

---
# Micro Executor List
handlers:
me-java-accounting:
url: http://me-java-accounting
me-node-warehouse:
url: http://me-node-warehouse
default: true
. . .

# Services
services:
names:
SRV_001:
handler: me-java-accounting

In this example, the configuration redirects all service request to me-node-warehouse except the service SRV_001 because it is mapped to me-java-accounting.