The traveler-processed-service
is an API server to record processed travelers for a period of 48-hour window to speed up next hop processing. Once the 48-hour window is over, the record will be offloaded to a separate data backend for archive and compliance purposes.
The requirements are the followings:
- a CRUD API service providing a JSON formatted output when queried
- a decoupled backend database service to connect to
- backend databases to support at v1
- MariaDB
- Postgres
- sqlite
- the service should be recovering for a partioning from its backend database
- the data structure should include the followings:
- an UUID
- first name
- last name
- multi hop travel
- was previously processed
- when previously processed
- should be reprocessed
- after the 48-hour window the record should be offloaded to a historical database
- concurrent writing to database and in-memory caching using sqlite to leverage gorm
- starting service
- validating backend support
- validating backend connectivity
- validating if database exists
- if not create it
- reconnecting with backend targeting the database
- migrating schema in database (including potential update)
Clone the repository:
git clone https://github.com/beezy-dev/traveler-crud-service.git
Get either postgres or mariadb running with Podman (or docker):
for postgres
podman run --detach --name postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -p 5432:5432
for mariadb
podman run --detach --name mariadb -e MYSQL_ROOT_PASSWORD=user -e MYSQL_USER=password -p 3306:3306 -p 8082:8080 mariadb
NOTE: as-is, the data is not persistent! Use a volume to achieve data persistency like:
podman run --detach --name postgres -e POSTGRES_USER=user -e POSTGRES_PASSWORD=password -p 5432:5432 -v postgres:/var/lib/data postgres
Run CompileDaemon to catch any code changes to trigger a rebuild and start of your binary:
~/go/bin/CompileDaemon -build="go build -o traveler-processed-service.out" -command="./traveler-processed-service.out" -color -graceful-kill -graceful-timeout 5