GisilaQueue class

The central application object, analogous to a Celery Celery() app.

It owns the task registry, the Broker, and the optional ResultBackend, and is the single thing both producers and workers construct. Register tasks with task; enqueue them through the returned TaskRef; process them by building a worker.

final app = GisilaQueue(
  broker: RedisBroker(host: 'localhost'),
  backend: RedisResultBackend(host: 'localhost'),
);

final add = app.task<int>('math.add', (ctx) async =>
    (ctx.arg(0) as int) + (ctx.arg(1) as int));

// producer
final r = await add.delay([2, 3]);
print(await r.get()); // 5  (once a worker has run)

// worker process
await app.worker().run();

Constructors

GisilaQueue({required Broker broker, ResultBackend? backend, String defaultQueue = 'default', QueueEventSink? events, QueueLogger? logger, Uuid? idGenerator, ControlChannel? controlChannel, Router? router})

Properties

backend ResultBackend?
Optional store for task states / return values. When null, tasks run fire-and-forget and AsyncResult.get is unavailable.
final
broker Broker
Transport used to move messages between producers and workers.
final
controlChannel ControlChannel
Broadcast channel for AsyncResult.revoke and Worker queue pause/resume. Defaults to NoopControlChannel (zero overhead); supply an InMemoryControlChannel or RedisControlChannel to enable it — see ControlChannel.
final
defaultQueue String
Queue used when a task / call specifies none and router (if any) doesn't match.
final
events QueueEventSink
Observability sink fed lifecycle QueueEvents by producers and workers. Defaults to NoopEventSink (zero overhead); supply an InMemoryEventBus or RedisEventSink to drive a GisilaRose dashboard.
final
hashCode int
The hash code for this object.
no setterinherited
logger QueueLogger
final
registry Map<String, Task>
Registered tasks, keyed by name (read-only view).
no setter
router Router?
Optional declarative routing consulted by send whenever a call doesn't pin an explicit queue — see Router.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

chain<T>(List<Signature> signatures) Chain<T>
Builds a sequential pipeline of signatures — see Chain. Call Chain.apply to enqueue it; the returned AsyncResult resolves once the last step finishes.
chord<T>(List<Signature> signatures, Signature callback) Chord<T>
Builds a Group of signatures plus a callback that fires once every member has finished — see Chord. Call Chord.apply to enqueue it; the returned AsyncResult resolves once the callback itself finishes, with the member results passed as its first argument.
close() Future<void>
Closes the broker, backend, and event-sink connections.
group<T>(List<Signature> signatures) Group<T>
Builds a parallel set of signatures — see Group. Call Group.apply to enqueue every member at once and get back a GroupResult handle for awaiting all of them.
lookup(String name) Task?
Looks up a registered task by name, or null.
newTaskId() String
Generates a fresh unique id — e.g. so chain can pre-assign every step's id before enqueuing any of them.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resultFor<T>(String id) AsyncResult<T>
Returns an AsyncResult handle for a known task id (e.g. one persisted elsewhere) without enqueuing anything.
send<T>(String taskName, {List<Object?> args = const [], Map<String, Object?> kwargs = const {}, String? queue, DateTime? eta, int maxRetries = 0, DateTime? expires, String? id, List<Map<String, Object?>>? chain, Map<String, Object?>? chord}) Future<AsyncResult<T>>
Low-level enqueue used by TaskRef. Produces a TaskMessage, records a pending (or scheduled) state in the backend, and hands it to the broker.
task<T>(String name, TaskHandler handler, {String? queue, int maxRetries = 0, Duration retryBackoff = const Duration(seconds: 1), Duration retryBackoffMax = const Duration(minutes: 10), bool retryJitter = true, bool autoRetry = false, Duration? timeLimit, Duration? softTimeLimit, RateLimit? rateLimit}) TaskRef<T>
Registers a task handler under name and returns a typed TaskRef for enqueuing it. T is the handler's result type, surfaced through AsyncResult.
toString() String
A string representation of this object.
inherited
worker({List<String>? queues, int concurrency = 1, Duration reserveTimeout = const Duration(seconds: 5), String? id}) Worker
Builds a Worker bound to this app.

Operators

operator ==(Object other) bool
The equality operator.
inherited