Skip to content

a rust-based job-processing service that accepts text-processing jobs via REST.

Notifications You must be signed in to change notification settings

manuelinfosec/job-processor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Job Processor Microservice (Rust + Actix-Web + SQLite)

A lightweight job-processing microservice that accepts text-processing jobs via REST, processes them asynchronously (simulated heavy work), persists state/results in SQLite, and exposes endpoints to submit and query jobs.

Features

  • ⁠POST /jobs to submit a job
  • ⁠GET /jobs/{job_id} to fetch status and result
  • ⁠Background processing using Tokio tasks
  • ⁠SQLite persistence with connection pooling via ⁠ sqlx ⁠
  • ⁠Tests: unit and integration

Requirements

  • ⁠Rust toolchain (1.62+ recommended)
  • ⁠⁠ cargo ⁠ available

Optional environment variables

  • ⁠⁠ DATABASE_URL ⁠ - SQLite connection string. Defaults to ⁠ sqlite://jobs.db ⁠.
  • ⁠⁠ BIND_ADDR ⁠ - server bind address. Defaults to ⁠ 127.0.0.1:8080 ⁠.

Build

cargo build --release

Run

run with default SQLite file 'jobs.db' in the working directory

cargo run --release

or set a different database or bind address

DATABASE_URL="sqlite://./my_jobs.db" BIND_ADDR="0.0.0.0:8080" cargo run --release

On first run the service will create the jobs table if it does not exist.

Endpoints

POST /jobs

Request JSON

{ "input": "some text" }

Response JSON

{ "job_id": "<uuid>" }

Behavior

Inserts a new row with status = "pending"

Spawns a background task that updates status to running, sleeps 5 seconds, computes reverse(input), and sets status to completed with the result.

Example curl

curl -s -X POST http://127.0.0.1:8080/jobs
-H "Content-Type: application/json"
-d '{"input": "hello world"}'

GET /jobs/{job_id}

Response JSON

{
  "job_id": "<uuid>",
  "status": "pending|running|completed|failed",
  "result": "<string|null>",
  "created_at": "<RFC3339>",
  "updated_at": "<RFC3339>"
}

Example curl

curl -s http://127.0.0.1:8080/jobs/<job_id> | jq

About

a rust-based job-processing service that accepts text-processing jobs via REST.

Topics

Resources

Stars

Watchers

Forks

Languages