Signal-hub is a platform with the aim to give to interop-platform users, the chance to notify and receive a "signal" if data has been updated. More info here: https://www.interop.pagopa.it/.
The platform has been splitted in several service, each one with its own scope:
- Push-signal service : In charge of signal's storage.
- Pull-signal service: In charge of retrieve signals from storage.
- Persister service : Actors in the middle between push and pull services.
- Eservice-event-consumer: Responsible to mantain platform sync with interop-platform (EService state).
- Purpose-event-consumer: Responsible to mantain platform sync with interop-platform (Purpose state).
- Agreement-event-consumer: Responsible to mantain platform sync with interop-platform (Purpose state).
- Clean up: Responsible to clean storage after a certain amount of time.
Within package folder, there are other libs that provide utils method for the platform like:
Throughout developing phases of this project, we make several decisions that we decide to keep track in ADR folder. You cand find it here.
If you want run this project you will need:
Before run the platform it's necessary install dependecies with this command:
pnpm install
Before running project you need to set/update envs files which you can find an example for each package.
If you want to run entire project on your machine, you need different tools like Postgres, ElasticMQ. If you've Docker available in your host you can run this:
./script/infra-start.sh
If you want to watch status of applications and logs you can prompt this:
./script/infra-status.sh
Moreover it's available scripts for stop and destroy containers which has been created with this:
./script/infra-stop.sh // Stop containers
./script/infra-destroy.sh
If you want to check ststus of single container within docker, you can launch this command:
docker-compose -f docker/docker-compose.yml logs -f -t <name-of-service>
# Example:
docker-compose -f docker/docker-compose.yml logs -f -t postgres
If you need to run only one service, maybe run every service is not necessary. For instance, if you want to run only "push-service" you need elasticMQ and Posgtres containers only.
If you choose to use docker you can run (NB: you need to be inside /docker folder):
docker-compose up postgres elasticmq
pnpm start:<service-name>
# example: pnpm start:push
You can also run service in background running followwing script:
- Push-service:
./script/push-start.sh
- Pull-service:
./script/pull-start.sh
-
docker-compose up postgres
Test with:
psql -h localhost -p 5432 -U postgres -d signal-hub -c "select 1+1 as result;"
To maintain data across container restart add this:
volumes: - ./postgres/data:/var/lib/postgresql/data user: 501:20
-
ElasticMQ is a message queue system oferring a SQS compatible interface.
docker-compose up elasticmq
test it with:
export AWS_PROFILE=<some aws profile in your ~/.aws/config> aws sqs list-queues --endpoint-url http://localhost:9324
You can even use a fake profile:
[profile FAKE-FOR-TEST] aws_access_key_id=test-aws-key aws_secret_access_key=test-aws-secret region=eu-south-1
-
This project use Kafka to retrieve mantain data sync with interop. To run what's necessary for kafka you need to run:
docker-compose up zookeeper docker-compose up kafka docker-compose up kafka-ui
If you want to create OpenAPI specification you can run
pnpm run api:generate:pull --version <version>
Latter instruction create OpenAPI spec for pull-service. It will create a new file under /packages/pull-signal/src/api if it doesn't exist yet.
Same you can do for push-service:
pnpm run api:generate:push --version <version>
You can find new open api spec file (for push-service) under packages/push-signal/src/api
NOTE: It's important define a version of open API following semantic versioning rules, otherwise cli will throw an error.
If you can check if openAPI created before is compliant on openAPI specification can run:
pnpm run api:validate:<service_name> --version <version>