Sample Containerized Go service using DuckDB
The service exposes GET http://localhost:8000/stats
api which returns aggregated user count from DuckDB database test.duckdb
.
API response:
[
{
"date": "2021-02-20",
"users_joined": 2598
},
{
"date": "2021-02-21",
"users_joined": 2578
}
]
The service uses go-duckdb library to interact with DuckDB C++ shared library.
make run
This will build and run the GIN service without using docker.
# builds docker image downloading DuckDB dependencies
make docker.build
# runs docker image
make docker.run
This is an optional step as there is already test.duckdb
duckdb file necessary to run the service without setting up anything. It contains a table called users
which has following columns:
id (int32) | joined_date (date) | name (varchar) | email (varchar) |
---|---|---|---|
1 | 2021-09-14 | Jarret Kuhn | [email protected] |
Command:
make test-db
- Creates a duckdb database file
test.duckdb
inside folderprepare-test-data
- Then creates 'users' table and populates 1 million dummy data. Takes around 2 mins.
test.duckdb
file is copied to the docker image and used by the service.