Skip to content

wolves-fc/dispatch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dispatch

A Go REST API for managing agents and mock tasks.

Comments

  • 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)

Prerequisites

Tool Description Install
Go Language used go.dev/dl
Task Task runner for dev commands taskfile.dev/installation

Setup

Download the dependencies and install the dev tools (optional)

go mod download
task install-tools

Available Tasks

All 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

Running the Server

The server starts on http://localhost:8080.

Data Persistant via SQLite

task run

No Data Persisted

task run:storeless

Running Tests

All tests are done with go test

All tests

task test
# verbose
task test:verbose

Unit tests

task test:unit
# verbose
task test:unit:verbose

Integration tests

task test:integration
# verbose
task test:integration:verbose

REST API

All endpoints return JSON.

Objects

Agent: {id, name, description, task_id, archived}

Task: {id, name, description, supported_agent_ids, tasked_agent_ids, archived}

Agents

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

Tasks

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

Errors

Error response is {error}.

Rate Limiting

Code Cause
429 Too many requests per second
429 Too many active requests

Headers

Request: Content-Type: application/json (POST/PUT), X-Request-ID (optional) Response: Content-Type: application/json, X-Request-ID, Access-Control-Allow-Origin: *

About

A Go REST API for managing agents and mock tasks.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages