MCPcopy Index your code
hub / github.com/choria-io/asyncjobs

github.com/choria-io/asyncjobs @v0.3.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.0 ↗ · + Follow
2,358 symbols 5,738 edges 100 files 117 documented · 5% updated 4d agov0.3.0 · 2026-04-19★ 1314 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Choria Asynchronous Jos

Overview

This is an Asynchronous Job Queue system that relies on NATS JetStream for storage and general job life cycle management. It is compatible with any NATS JetStream based system like a private hosted JetStream, Choria Streams or a commercial SaaS.

Each Task is stored in JetStream by a unique ID and Work Queue item is made referencing that Task. JetStream will handle dealing with scheduling, retries, acknowledgements and more of the Work Queue item. The stored Task will be updated during the lifecycle.

Multiple processes can process jobs concurrently, thus job processing is both horizontally and vertically scalable. Job handlers are implemented in Go with one process hosting one or many handlers. Other languages can implement Job Handlers using NATS Request-Reply services. Per process concurrency and overall per-queue concurrency controls exist.

This package heavily inspired by hibiken/asynq.

Go Reference Go Report Card CodeQL Unit Tests

Status

This is a brand-new project, under heavy development. The core Task handling is in good shape and reasonably stable. Task Scheduler is still subject to some change.

Synopsis

Tasks are published to Work Queues:

// establish a connection to the EMAIL work queue using a NATS context
client, _ := asyncjobs.NewClient(asyncjobs.NatsConn(nc), asyncjobs.BindWorkQueue("EMAIL"))

// create a task with the type 'email:new' and body from newEmail()
task, _ := asyncjobs.NewTask("email:new", newEmail())

// store it in the Work Queue
client.EnqueueTask(ctx, task)

Tasks are processes by horizontally and vertically scalable processes. Typically, a Handler handles one type of Task. We have Prometheus integration, concurrency and backoffs configured.

// establish a connection to the EMAIL work queue using a 
// NATS context, with concurrency, prometheus stats and backoff
client, _ := asyncjobs.NewClient(
    asyncjobs.NatsContext("EMAIL"), 
    asyncjobs.BindWorkQueue("EMAIL"),
    asyncjobs.ClientConcurrency(10),
    asyncjobs.PrometheusListenPort(8080),
    asyncjobs.RetryBackoffPolicy(asyncjobs.RetryLinearTenMinutes))

router := asyncjobs.NewTaskRouter()
router.Handler("email:new", func(ctx context.Context, log asyncjobs.Logger, task *asyncjobs.Task) (any, error) {
    log.Printf("Processing task %s", task.ID)

    // do work here using task.Payload

    return "sent", nil
})

client.Run(ctx, router)

See our documentation for a deep dive into the use cases, architecture, abilities and more.

Requirements

NATS 2.8.0 or newer with JetStream enabled.

Features

See the Feature List page for a full feature break down.

Extension points exported contracts — how you extend this code

Logger (Interface)
Logger is a pluggable logger interface [2 implementers]
logger.go
StorageAdmin (Interface)
StorageAdmin is helpers to support the CLI mainly, this leaks a bunch of details about JetStream but that's ok, we're no [1 …
asyncjobs.go
RetryPolicyProvider (Interface)
RetryPolicyProvider is the interface that the ReplyPolicy implements, use this to implement your own exponential backoff [1 …
retrypolicy.go
Generator (Interface)
Generator is the interfaces generators must implement [1 implementers]
generators/package.go
Backoff (Interface)
Backoff controls the interval of campaigns [1 implementers]
election/election.go
HandlerFunc (FuncType)
HandlerFunc handles a single task, the response bytes will be stored in the original task
mux.go
TaskOpt (FuncType)
TaskOpt configures Tasks made using NewTask()
task.go
ClientOpt (FuncType)
ClientOpt configures the client
client_options.go

Core symbols most depended-on inside this repo

r
called by 537
docs/themes/hugo-theme-relearn/assets/js/orama/trees.js
Errorf
called by 136
logger.go
n
called by 134
docs/themes/hugo-theme-relearn/assets/js/swagger-ui/swagger-ui-standalone-preset.js
It
called by 111
docs/themes/hugo-theme-relearn/assets/js/orama/orama.js
o
called by 102
docs/themes/hugo-theme-relearn/assets/js/swagger-ui/swagger-ui-standalone-preset.js
add
called by 101
docs/themes/hugo-theme-relearn/assets/js/orama/trees.js
toString
called by 90
docs/themes/hugo-theme-relearn/assets/js/swagger-ui/swagger-ui-standalone-preset.js
NewTask
called by 64
task.go

Shape

Function 1,635
Method 580
Class 90
Struct 36
Interface 8
FuncType 6
TypeAlias 3

Languages

TypeScript86%
Go14%

Modules by API surface

docs/themes/hugo-theme-relearn/assets/js/swagger-ui/swagger-ui-standalone-preset.js393 symbols
docs/themes/hugo-theme-relearn/assets/js/orama/orama.js251 symbols
docs/themes/hugo-theme-relearn/assets/js/search-orama.js237 symbols
docs/themes/hugo-theme-relearn/assets/js/orama/components.js170 symbols
docs/themes/hugo-theme-relearn/assets/js/lunr/wordcut.js139 symbols
docs/themes/hugo-theme-relearn/assets/js/orama/trees.js135 symbols
docs/themes/hugo-theme-relearn/assets/js/theme.js94 symbols
docs/themes/hugo-theme-relearn/assets/js/d3/d3-selection.min.js69 symbols
docs/themes/hugo-theme-relearn/assets/js/js-yaml/js-yaml.min.js61 symbols
docs/themes/hugo-theme-relearn/assets/js/lunr/lunr.tr.min.js55 symbols
asyncjobs.go45 symbols
docs/themes/hugo-theme-relearn/assets/js/d3/d3-color.min.js44 symbols

For agents

$ claude mcp add asyncjobs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page