CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl-labs/sqlite-go-best-practices

SQLite best practices for Go — WAL mode, foreign_keys, busy_timeout, SetMaxOpenConns, context-aware queries, transactions, migrations

98

2.36x
Quality

99%

Does it follow best practices?

Impact

97%

2.36x

Average score across 5 eval scenarios

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

task.mdevals/scenario-4/

Background Task Queue Service

Problem/Feature Description

A small team needs a lightweight background task queue implemented in Go with SQLite as the backing store. This replaces Redis/RabbitMQ for a low-traffic internal tool. The service runs as an HTTP server that accepts tasks and processes them in the background.

The service needs to support:

  • Submitting a new task via HTTP POST with a task type, JSON payload, and optional priority (1-5, default 3)
  • Claiming the next available task for processing (atomically marks it as "processing" so no other worker picks it up)
  • Marking a task as completed or failed (failed tasks include an error message)
  • Retrying failed tasks (up to 3 attempts, then marked as "dead")
  • Listing tasks by status (pending, processing, completed, failed, dead)
  • Getting task details by ID

Each task has: id, task_type, payload (JSON text), priority, status, attempts, max_attempts, error_message, created_at, updated_at, completed_at.

The claim operation is critical -- it must atomically find the highest-priority pending task and mark it as processing in a single transaction to prevent race conditions.

Output Specification

Produce:

  • main.go -- HTTP server with routes
  • db.go -- Database connection and migrations
  • queue.go -- Task queue operations (submit, claim, complete, fail, retry, list)
  • handlers.go -- HTTP handlers
  • go.mod -- Module file

The code should be complete Go with no placeholders or TODO comments.

evals

tile.json