Clone this repo:
  1. 7bdd63e Adding Code of Conduct by Matteo Scandolo · 5 years ago master
  2. 57f4a48 [SEBA-497] Makefile for building Docker image by Zack Williams · 6 years ago 2.0.2
  3. 1116b97 Fixing retry mechanism when connection to kafka is failed by Matteo Scandolo · 6 years ago 2.0.1
  4. f152358 Retrying kafka connection by Matteo Scandolo · 6 years ago
  5. f80d5d0 release v2.0.0 of xos-ws by Zack Williams · 6 years ago 2.0.0

XOS Northbound Rest Interface

This is an abstraction layer that provide WebSockets read access to XOS.

Development

This software can be executed on your local machine as long as NodeJs is installed.

To start it use: npm install && npm start

Alternatively you can invoke the start script node src/server.js directly to pass addictional paramenters:

  • --config mycfg.yml to specify a different config file
  • LOG_LEVEL=error|warn|info|debug to enable different logging level (default is warn)

If you are actively working on this project we suggest you to take a look to nodemon to observe changes in you code and automatically restart the server.

Config

By default the used config is:

default:
  redis:
    host: redis
    port: 6379
  gateway:
    port: 3000

You can create a file called config.yml and replace one or more values. You can also have different config files and load them using the --config flag (see above for usage).

Tests

A comprehensive test suite defined using Mocha, Chai and Sinon is provided together with the project. To execute existing tests use npm test, while if you are currently working on it you can execute them in watch mode using npm run test:dev.

Styleguide are also applied using EsLint, to check style execute npm run lint.

Notes

Websocket

Socket.io client library will be available at: http://localhost:3000/socket.io/socket.io.js

Remember that redis in the Frontend config is linked

Test Client

To start the client: cd spec; browser-sync start --server

Send a fake REDIS event

redis-cli -h xos.dev

# In progress
PUBLISH Slice "{\"pk\": 19, \"object\": {\"id\": 19,\"name\": \"mysite_test_redis\", \"backend_status\": \"0 - In Progress\"}, \"changed_fields\": [\"updated\", \"backend_status\"]}"

# Succes
PUBLISH Slice "{\"pk\": 19, \"object\": {\"id\": 19,\"name\": \"mysite_test_redis\", \"backend_status\": \"1 - Success\"}, \"changed_fields\": [\"updated\", \"backend_status\"]}"

# Error
PUBLISH Slice "{\"pk\": 19, \"object\": {\"id\": 19,\"name\": \"mysite_test_redis\", \"backend_status\": \"2 - Error\"}, \"changed_fields\": [\"updated\", \"backend_status\"]}"