Namespaces and logging
import 'package:gisila_queue/gisila_queue.dart';Namespaces
Section titled “Namespaces”Every Redis or RabbitMQ component keeps its keys, queues and channels under a prefix.
Two apps on the same Redis database or RabbitMQ vhost must use different prefixes;
every component of one app must use the same one. See
Namespaces.
Namespaced
Section titled “Namespaced”abstract interface class Namespaced { String get prefix;}Implemented by RedisBroker, RabbitBroker, RedisResultBackend, RedisControlChannel,
RedisEventSink, RedisEventSource, RedisBeatLock and RedisBeatStateStore.
When to use: implement it on your own Redis-backed component so GisilaQueue and
Beat include it in their prefix check.
defaultNamespace
Section titled “defaultNamespace”const defaultNamespace = 'gq';The prefix every component uses when none is given. Workers and beats running on it log
defaultNamespaceWarning(...) at startup.
checkNamespaces()
Section titled “checkNamespaces()”String? checkNamespaces(Map<String, Object?> components)Returns the single prefix shared by the Namespaced values (and plain String values) in
components, null if there are none, or throws ArgumentError listing each prefix when
they differ. GisilaQueue and Beat call it in their constructors.
Other exports
Section titled “Other exports”| Symbol | Description |
|---|---|
defaultNamespaceWarning(String who) |
The warning text logged for a component on gq. |
Logging
Section titled “Logging”QueueLogger
Section titled “QueueLogger”Minimal logging seam; the package has no logging dependency.
abstract class QueueLogger { void log(LogLevel level, String message, {Object? error, StackTrace? stack}); void debug(String m); void info(String m); void warning(String m); void error(String m, {Object? error, StackTrace? stack});}When to use: implement log to forward to your app’s logger, and pass it as
GisilaQueue(logger: ...).
class ForwardingLogger extends QueueLogger { ForwardingLogger(this.sink); final void Function(String level, String message) sink;
@override void log(LogLevel level, String message, {Object? error, StackTrace? stack}) => sink(level.name, error == null ? message : '$message: $error');}LogLevel
Section titled “LogLevel”enum LogLevel { debug, info, warning, error }Enqueue and retry-chain details are logged at debug; worker start/stop and successful
tasks at info; retries, rejections, expiries at warning; failures at error.
ConsoleQueueLogger
Section titled “ConsoleQueueLogger”class ConsoleQueueLogger extends QueueLogger { ConsoleQueueLogger({LogLevel minLevel = LogLevel.info});}Default logger. Writes [gisila_queue] LEVEL message lines to stderr, with the cause and
(for errors) the stack trace.
SilentQueueLogger
Section titled “SilentQueueLogger”Drops everything. Use it in tests.
See also: GisilaQueue, Testing.