/connectivityserver

The package contains the connection server, to which daq applications publish and lookup their connection information. It is implemented using python flask running under Gunicorn.

Primary LanguagePython

Connection-service

This service provides a very simple flask based server to serve connection information to DAQ applications.

REST interface

The server reponds to the following uris

/publish

Allows publication of connection information. The content of the request should be JSON encoded. For example, the following json file can be published using curl.

> cat publish.json
{
 "connections":[
  {
   "connection_type":0,
   "data_type":"TPSet",
   "uid":"DRO-000-tp_to_trigger",
   "uri":"tcp://192.168.1.100:1234"
  },
  {
   "connection_type":0,
   "data_type":"TPSet",
   "uid":"DRO-001-tp_to_trigger",
   "uri":"tcp://192.168.1.100:1235"
  }
 ],
 "partition":"ccTest"
}

> curl -d @publish.json -H "content-type: application/json" \
    http://connection-flask.connections:5000/publish

/getconnection/

This uri returns a list of connections matching the 'uid_regex' and 'data_type' specified in the JSON encoded request.

curl -d '{"uid_regex":"DRO.*","data_type":"TPSet"}' \
    -H "content-type: application/json" \
     http://connection-flask.connections:5000/getconnection/ccTest
[{"uid": "DRO-000-tp_to_trigger", "uri": "tcp://192.168.1.100:1234", "connection_type": 0, "data_type": "TPSet"}, {"uid": "DRO-001-tp_to_trigger", "uri": "tcp://192.168.1.100:1235", "connection_type": 0, "data_type": "TPSet"}]

/retract

This uri should be used to remove published connections. The request should be JSON encoded with the keys "partition" and "connections" with the latter being an array of "connection_id" and "data_type" values.

/retract-partition

This uri should be used to remove all published connections from the given partition. The request should be a urlencoded form with one field "partition" naming the partition to be retracted.

Running the server locally from the command line

The server is intended to be run under the Gunicorn web server.

gunicorn -b 0.0.0.0:5000 --workers=1 --worker-class=gthread --threads=2 \
       --timeout 5000000000 connection-service.connection-flask:app

Some debug information will be printed by the connection-flask if the environment variable 'CONNECTION_FLASK_DEBUG' is set to a number greater than 0. Currently 1 will print timing information for the publish/lookup calls. 2 will give information about what was published/looked up and 3 is even more verbose printing the actual JSON of the requests.