A processing microservice within the crowsnest ecosystem which accepts raw AIS messages as input and produces AIS messages in json struct format.
The microservice:
- Subscribes to the crowsnest mqtt broker and expects incoming envelopes according to the following format:
{ "sent_at": ..., "message": "IUFJVkRNLDEsMSwsQSwxM3U9UjFQMDAwUG5McEpRMFNKODNsPDIwODBRLDAqNUY=" # base64-encoded AIS message }
- Assembles multiline messages and decodes to json structs according to the format defined by pyais, see here
- Publishes jsonified AIS messages to the same crowsnest mqtt broker on the topic format
.../{mmsi}/{message_type}
according to the following format:{ "sent_at": ..., "message": "{jsonified AIS messages}" }
To setup the development environment:
python3 -m venv venv
source ven/bin/activate
Install everything thats needed for development:
pip install -r requirements_dev.txt
In addition, code for brefv
must be generated using the following commands:
mkdir brefv
datamodel-codegen --input brefv-spec/envelope.json --input-file-type jsonschema --output brefv/envelope.py
datamodel-codegen --input brefv-spec/messages --input-file-type jsonschema --reuse-model --output brefv/messages
To run the linters:
black main.py tests
pylint main.py
To run the tests:
python -m pytest --verbose tests
Apache 2.0, see LICENSE