examples/

directory
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2026 License: Apache-2.0

README

Go examples

Install the public beta with go get github.com/stablemates/workhorse/go, then set WORKHORSE_DATABASE_URL to a database where the Workhorse schema is installed.

  • transaction enqueues a retryable task inside an application-owned pgx transaction. Its createAccount function is the documented transactional enqueue, and a test shows that a failed enqueue rolls back the account row.
  • gorm enqueues through the GORM transaction's Statement.ConnPool, using the existing SQL executor. Real PostgreSQL tests cover plain and prepared-statement transactions.
  • sqlc uses pinned generated business queries and Workhorse with the same pgx transaction.
  • sqlx borrows Go sqlx's underlying *sql.Tx through pgx stdlib, not Rust SQLx.
  • dedicated-worker runs a supervised worker with checkpoints, a durable timer, bounded concurrency, and signal-driven drain.
  • orchestration shows child joins, signal waits, and human decisions. Another process supplies values with Queue.SendSignal and Queue.CompleteHumanWait.

Deploy a worker as a dedicated long-lived process. Run the standalone workhorse dashboard process beside it with the same database URL; the dashboard reads PostgreSQL directly and does not need to be embedded into the Go binary.

Directories

Path Synopsis
Commits an application row and a task in one Bun transaction.
Commits an application row and a task in one Bun transaction.
Runs a supervised worker process with checkpoints, a durable timer, and bounded concurrency, then drains its active tasks on SIGINT or SIGTERM.
Runs a supervised worker process with checkpoints, a durable timer, and bounded concurrency, then drains its active tasks on SIGINT or SIGTERM.
Serves the Go queues of the hosted dashboard demo at https://demo.workhorse.run, plus the queue every demo language shares, so the dashboard has live Go work to show.
Serves the Go queues of the hosted dashboard demo at https://demo.workhorse.run, plus the queue every demo language shares, so the dashboard has live Go work to show.
Enqueues through a GORM transaction's Statement.ConnPool with the existing SQL executor, so the application write and the task commit or roll back together.
Enqueues through a GORM transaction's Statement.ConnPool with the existing SQL executor, so the application write and the task commit or roll back together.
Runs an order handler that joins child tasks, then waits for a signal and a human decision.
Runs an order handler that joins child tasks, then waits for a signal and a human decision.
Enqueues one task, runs the worker once, and prints the task's outcome.
Enqueues one task, runs the worker once, and prints the task's outcome.
Runs sqlc-generated application queries and a Workhorse enqueue in one caller-owned pgx transaction, so the order row and its task commit together.
Runs sqlc-generated application queries and a Workhorse enqueue in one caller-owned pgx transaction, so the order row and its task commit together.
Enqueues through the *sql.Tx under a Go sqlx transaction, opened with pgx stdlib, so the application write and the task commit together.
Enqueues through the *sql.Tx under a Go sqlx transaction, opened with pgx stdlib, so the application write and the task commit together.
Enqueues a retryable task inside an application-owned pgx transaction, so the task exists only if the caller commits.
Enqueues a retryable task inside an application-owned pgx transaction, so the task exists only if the caller commits.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL