Skip to content

The titan Endpoint Provider

The endpoint provider is used by the request/response brick pair to dynamically provide REST endpoints for flow inletts to the outside world.

Building/ running

To run the service simply use go run ./cmd/endpointprovider

or to create an executable file go build ./cmd/endpointprovider

It features the following command line arguments:

Name Options (default) Purpose
port (9020) Port on which the REST Api serves
zmq-port (9021) Port on which the ZeroMQ router can be reached
zmq-bind (*) IP or interface to bind the ZeroMQ router to
service-id ("no default set") Service ID string used for authentication
user-manager localhost:9000" URL of the user service
flow-manager localhost:9002" URL of the flow manager
log-level info/debug/warning/error Log level
(info)
log-to-kafka (false) Flag: use kafka hook for logging
kafka (10.14.0.23:9092) host:port of kafka broker
service-topic (titan.servicelogs) kafka topic for logs
config-file (internal/app/endpointprovider/config.yaml) Configuration file

Generally, all settings listed above can be done also via environment variables, whereby the variables are composed of a prefix (TITAN_EP) and the argument using snake case:

TITAN_EP_ARGUMENT, e.g. TITAN_EP_LOG_LEVEL

Usage

Register an endpoint

Send a registration with a zmq dealer to the zmq host:port to subscribe for an endpoint.

if the structure of the registration object is

Name Type Doc
Token string optional token string
FlowUID string UUID of the flow
FlowName string name of the flow
BrickName string name of the brick in the flow

The endpoint will be : host:port/UserName_of_FlowOwner/FlowName/BrickName

Alternatively, the structure of the registration object can be

Name Type Doc
Token string optional token string
Endpoint string the endpoint to register

The endpoint will be : host:port/Endpoint

All requests to the endpoint will be send to the subscriber as Response object

Name Type Doc
RequestID string UUID of the request
Request Request request

a Request object contains

Name Type Doc
Header map request header map (string-> variant)
Method string UUID of the request
Body variant request body

If the endpoint is registered to include authentication with a token all requests need to include a header:

Key Value
Authorization token

Delete an endpoint

send stop request to zmq endpoint via dealer

"stop":"endpoint"

further requests to the endpoint will not be possible.

Send a response to an endpoint

To send a response send a response message to the zmq host:port with a zmq dealer containing

Name Type Doc
RequestID string UUID of the request
Status int Status code
Body variant a response body
Response string a response type ("TEXT" or "JSON"), default: "JSON"