Welcome to TC - Chronos. This is a microservice that takes on all the webhook work from TC. Before creation of Chronos, about 50% of the database was taken up by webhook logs & failed deliveries are causing some slowness in jobs etc. To battle this we will simply send 1 request from TC2 to Chronos per webhook then let chronos manage the rest.
This means the Chronos needs some certain functionality:
-
An object for storing endpoints where our clients wish webhooks to be sent to
-
An object for storing information about the webhook logs
-
An endpoint for CRUD operations on the Endpoint objects
-
An endpoint for retrieving webhook logs to be displayed in TC2
-
An endpoint for distributing webhooks to all Endpoints related to a branch
-
A job that runs periodically deleting all logs older than 15 days
To set up the Chronos system locally follow these steps:
- Create a virtual environment
- Install the requirements by running
make install-dev
- Create a
.env
file in the root of the project with the following content:
Set pg_dsn and test_pg_dsn You will need to export dev_mode = True to create tables
- Create the DB in Postgres by calling
make reset-db
- Start the server using
make run-server-dev
- Start the celery worker with
make run-worker
To set up the Chronos system in render follow these steps:
- Create a render project with the following services:
- A Postgres database
- A Redis database
- A web service
- A worker service
- Setup web service:
- Set to build from this repo and deploy from master branch
- Set
make install
as the build command - Set
make run-server
as the start command
- Setup worker service:
- Set to build from this repo and deploy from master branch
- Set
make install
as the build command - Set
make run-worker
as the start command
- Setup a Postgres instance
- Setup a Redis instance
- Return to environment variables on web service and set the following:
- HOST
- PORT
- logfire_token
- tc2_shared_key
- Setup shared environment variables from internally created postgres and redis instance
- pg_dsn
- redis_url