Database Controller is designed to manage job status in database and API server. To be brief, we treat records in the database as the ground truth and synchronize them to the API server.
Database Controller contains 3 main components: write merger, poller, and watcher. Here is an example of a job lifetime controlled by these 3 components:
- User submits framework request to rest-server.
- Rest-server forwards the request to write merger.
- Write merger saves it to the database, mark
synced=false
, and return. - User is notified the framework request is successfully created.
- Poller finds the
synced=false
request and synchronizes it to the API server. - Now watcher finds the framework is created in the API server. So it sends the event to write merger.
- Write merger receives the watched event, mark
synced=true
, and update job status according to the event. - The job finishes. Watcher sends this event to write merger.
- Write merger receives the watched event, mark
completed=true
, and update job status according to the event. - Poller finds the
completed=true
request, deletes it from the API server. - Watcher sends the delete event to write merger.
- Write merger receives the watched event, mark
deleted=true
.
Environment: Node.js 8.17.0, use yarn install
to install all dependencies under src/
. To set environmental variables, create a .env
file under src
.
Lint: Run npm run lint -- --fix
under src/
or sdk/
.