postgres-partitioned-queue

command module
v0.0.0-...-7c69fdb Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 13 Imported by: 0

README

This repository accompanies this blog post.

Setup

Prerequisites:

Run task setup to get everything running. This will spin up a Postgres database on port 5432, generate the relevant sqlc, and write the schema to the database. You might need to run it multiple times if Postgres doesn't start quickly.

Next, set the DATABASE_URL environment variable for all commands below:

export DATABASE_URL=postgresql://hatchet:hatchet@127.0.0.1:5432/hatchet

seed

Seeds the database with QUEUED tasks: for example, go run . seed -c 100000 -b 1000 -p 100. This would seed 100000 tasks across 100 partitions (groups).

seed the database with some tasks.

Usage:
  queue seed [flags]

Flags:
  -b, --batch-size int   The batch size for seeding. (default 100)
  -c, --count int        The number of tasks to seed. (default 10)
  -h, --help             help for seed
  -p, --partitions int   The number of partitions to seed. (default 10)

worker

Runs a set of workers which poll for tasks: for example, go run . worker -w 10 -s round-robin-concurrency -i 1s.

worker starts a set of workers to poll for tasks.

Usage:
  queue worker [flags]

Flags:
  -m, --concurrency-max-runs int   The maximum number of runs for the round-robin concurrency strategy. (default 4)
  -h, --help                       help for worker
  -l, --limit int                  The number of tasks to process per worker. (default 10)
  -i, --poll-interval string       The interval at which to poll for tasks. (default "5s")
  -s, --strategy string            The strategy to use for polling tasks. (default "fifo")
  -d, --task-delay string          The delay to introduce for each task in the worker. (default "0s")
  -w, --workers int                The number of workers to start. (default 1)

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
cmdutils
Adapted from: https://github.com/hatchet-dev/hatchet-v1-archived/blob/3c2c13168afa1af68d4baaf5ed02c9d49c5f0323/cmd/cmdutils/interrupt.go
Adapted from: https://github.com/hatchet-dev/hatchet-v1-archived/blob/3c2c13168afa1af68d4baaf5ed02c9d49c5f0323/cmd/cmdutils/interrupt.go

Jump to

Keyboard shortcuts

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