No description
| queuelang | ||
| go.mod | ||
| LICENSE | ||
| README.md | ||
Qlango (queuelang-go)
Pure-Go library implementing a QueueLang "virtual machine".
No external dependencies. Designed to be embedded in higher-level systems that need a declarative, restartable, queue-oriented pipeline language, such as a Kubernetes operator.
Install
go get forge.heeboo.org/thunerbl/qlango
Usage
import "github.com/QueueLang/queuelang-go/queuelang"
vm, err := queuelang.NewVM(`
ENQUEUE namespace:ensure my-org
ENQUEUE postgres:deploy my-org-db
ENQUEUE app:deploy my-org my-org-db
ENQUEUE health:check https://my-org.example.com
`, 3 /* defaultMaxRetry */)
for !vm.Empty() {
step, _ := vm.Dequeue()
// step.Kind, step.Action, step.Args, step.Attempt, step.MaxRetry
err := execute(step)
if err != nil {
if !vm.Roll(step) {
// step exhausted its retries
return err
}
}
}
Persisting queue state between process restarts
// Export before process exit / between reconcile calls:
snapshot := vm.Snapshot() // []queuelang.SnapshotItem — JSON-friendly
// Restore in the next process / reconcile call:
vm2, _ := queuelang.NewVM(src, defaultMaxRetry)
vm2.Restore(snapshot) // resumes with correct attempt counters
QueueLang syntax
| Instruction | Effect |
|---|---|
ENQUEUE kind:action [args…] |
Append a step to the back of the queue |
ROLL kind:action [args…] |
Same as ENQUEUE but marks the step for at-least-one retry |
DUP kind:action |
Duplicate the last enqueued step |
MAXRETRY N |
Override retry limit for all subsequent steps |
-- text |
Line comment |
Test
go test ./...