Skip to main content

Dojot flow node.

Project description

# dojot-flow-node-python

A Python library that allows you to integrate your own node on Dojot's [FlowBroker](https://github.com/dojot/flowbroker).

## How to build your own node

1) You need to create a class that extends the `DataHandlerBase` class, this
class is the responsable by implements your node behavior. The following methods
__must be__ implemented:
- get_node_representation_path
- get_metadata
- get_locale_data
- handle_message

2) Is necessary to create a `.html` file that describes your node. You can find how to create it using the [NodeRed documentation](https://nodered.org/docs/creating-nodes/). Dojot's FlowBroker uses the [NodeRed](https://nodered.org/) frontend.


3) You need to encapsulate your code into a docker container.

4) Publish your container in some public repository like [DockerHub](https://hub.docker.com/) or some private based on [DockerRegistry](https://docs.docker.com/registry).

5) Call the FlowBroker endpoint to add a new node. Please check the [FlowBroker documentation](https://dojot.github.io/flowbroker/apiary_latest.html) to check
how this endpoint works.

## Sample
A sample node is attached to this package to illustrate the steps described in
the previous section. It's a simple node that converts a Celcius temperature
measure into Kelvin.

### How to build

Build the docker image:
```sh
cd sample_node
docker build -t <your dockerHub username>/kelvin .
```

Publish it on your DockerHub:
```sh
docker push <your dockerHub username>/kelvin
```

Acquire a Dojot's token:
```sh
curl -X POST http://127.0.0.1:8000/auth \
-H 'Content-Type:application/json' \
-d '{"username": "admin", "passwd" : "admin"}'
```

This command will return a JWT token, you need to store it on an environment
variable:
```sh
export JWT=<the value returned>
```

Add the Kelvin node to Dojot.
```sh
curl -H "Authorization: Bearer ${JWT}" http://localhost:8000/flows/v1/node -H 'content-type: application/json' -d '{"image": "<your dockerHub username>/kelvin:latest", "id":"kelvin"}'
```

Now the Kelvin node will be available on `converters` category into the FlowBroker Dojot's interface.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dojot-flow-node, version 0.0.10
Filename, size File type Python version Upload date Hashes
Filename, size dojot_flow_node-0.0.10-py2-none-any.whl (6.0 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size dojot_flow_node-0.0.10-py3-none-any.whl (6.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size dojot-flow-node-0.0.10.tar.gz (3.8 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page