Documentation
¶
Overview ¶
Package taskqueue provides a durable task client for Hanzo Tasks.
Drop-in replacement for Base's Cron():
// Before (cron):
e.App.Cron().Add("settlement", "*/30 * * * * *", func() { ... })
// After (tasks):
tasks.Add("settlement", "30s", func() { ... })
If TASKS_URL is set, schedules run as durable Temporal workflows (retries, dead letter, audit trail). If not, runs locally via goroutine timer (dev mode, same behavior as cron but no persistence).
If zapAddr is set, ZAP binary transport is preferred over HTTP for submitting tasks (lower latency, same semantics). HTTP is fallback.
Package tasks provides the Hanzo Tasks client for Go applications.
Two methods, two use cases:
client := tasks.New(os.Getenv("TASKS_URL"), os.Getenv("TASKS_ZAP"), nil)
client.Add("settlement.process", "30s", fn) // recurring schedule
client.Now("webhook.deliver", payload) // fire once immediately
Transport priority: ZAP (binary, low-latency) > HTTP > local goroutine. When TASKS_ZAP is set, tasks submit over ZAP binary protocol. When TASKS_URL is set, tasks submit over HTTP as fallback. When neither is set, tasks run locally via goroutine timers (dev mode).
Integration with Hanzo Base:
app.Tasks().Add("cleanup", "1h", fn)
app.Tasks().Now("email.send", payload)
Index ¶
Constants ¶
const ( OpcodeTaskSubmit uint16 = 0x0050 // one-shot task OpcodeTaskSchedule uint16 = 0x0051 // recurring schedule )
ZAP opcodes for task submission.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages both one-shot tasks and recurring schedules.
func New ¶
New creates a Client. If both tasksURL and zapAddr are empty, everything runs locally. If zapAddr is set, ZAP transport is preferred. HTTP is fallback.
func (*Client) Add ¶
Add registers a recurring task. interval is a duration string ("30s", "5m", "1h"). The fn runs every interval. If TASKS_URL is set, creates a durable Temporal schedule. Otherwise runs a local ticker (same as cron but cleaner).
tasks.Add("settlement.process", "30s", func() { processSettlements() })
tasks.Add("oracle.update", "5m", func() { updateOracle() })