A Go REST API for managing agents and mock tasks.
- Went for the minimal deps route but the go sqlite package has a bunch of indirect deps.
- Blackbox unit tests only
- Didn't check rand for collisions when making uuids but obviously slim chance
- Reporting instead of logging with levels to give end user the ability to handle events how ever they want
- Reporting only the request id (nothing about the client or server)
- Designed around the concept of accepting more than one store type (you could swap in postgres or whatever)
| Tool | Description | Install |
|---|---|---|
| Go | Language used | go.dev/dl |
| Task | Task runner for dev commands | taskfile.dev/installation |
Download the dependencies and install the dev tools (optional)
go mod download
task install-toolsAll of the task commands are just aliases for go commands so feel free to just run the go commands directly.
| Command | Description |
|---|---|
task |
Run all checks and build |
task check |
Run format, lint, test, vulnerability, verify |
task format |
Format code with gofmt |
task lint |
Run golangci-lint |
task test |
Run all tests |
task test:verbose |
Run all tests with verbose output |
task test:unit |
Run unit tests only |
task test:unit:verbose |
Run unit tests with verbose output |
task test:integration |
Run integration tests only |
task test:integration:verbose |
Run integration tests with verbose output |
task vulnerability |
Check for known security vulnerabilities |
task verify |
Verify dependencies and checksums |
task build |
Build all packages |
task build:sqlite |
Build server with SQLite persistence to bin/ |
task build:storeless |
Build server without persistence to bin/ |
task run |
Run server with SQLite persistence |
task run:storeless |
Run server without persistence (in-memory) |
task clean |
Clean build artifacts and bin/ directory |
task tidy |
Tidy go.mod and go.sum |
task install-tools |
Install required development tools |
The server starts on http://localhost:8080.
task runtask run:storelessAll tests are done with go test
task test
# verbose
task test:verbosetask test:unit
# verbose
task test:unit:verbosetask test:integration
# verbose
task test:integration:verboseAll endpoints return JSON.
Agent: {id, name, description, task_id, archived}
Task: {id, name, description, supported_agent_ids, tasked_agent_ids, archived}
| Method | Endpoint | Body | Success | Response | Errors |
|---|---|---|---|---|---|
GET |
/agents |
- | 200 | {agents} |
- |
POST |
/agents |
{name, description} |
201 | {message, agent} |
400 |
GET |
/agents/{id} |
- | 200 | {agent} |
400, 404 |
PUT |
/agents/{id} |
{name?, description?} |
200 | {message, agent} |
400, 404 |
DELETE |
/agents/{id} |
- | 204 | - | 400, 404 |
POST |
/agents/{id}/restore |
- | 204 | - | 400, 404 |
GET |
/agents/{id}/task |
- | 200 | {task} |
400, 404 |
PUT |
/agents/{id}/task |
{task_id} |
204 | - | 400, 404 |
DELETE |
/agents/{id}/task |
- | 204 | - | 400, 404 |
| Method | Endpoint | Body | Success | Response | Errors |
|---|---|---|---|---|---|
GET |
/tasks |
- | 200 | {tasks} |
- |
POST |
/tasks |
{name, description, supported_agent_ids?} |
201 | {message, task} |
400 |
GET |
/tasks/{id} |
- | 200 | {task} |
400, 404 |
PUT |
/tasks/{id} |
{name?, description?, supported_agent_ids?} |
200 | {message, task} |
400, 404 |
DELETE |
/tasks/{id} |
- | 204 | - | 400, 404 |
POST |
/tasks/{id}/restore |
- | 204 | - | 400, 404 |
Error response is {error}.
| Code | Cause |
|---|---|
| 429 | Too many requests per second |
| 429 | Too many active requests |
Request: Content-Type: application/json (POST/PUT), X-Request-ID (optional)
Response: Content-Type: application/json, X-Request-ID, Access-Control-Allow-Origin: *