SynchronousDriver class
Synchronous queue driver that executes jobs immediately
This driver executes jobs synchronously without queuing. Perfect for:
- Testing and development
- Jobs that must run immediately
- Debugging job logic
- Simple applications without async requirements
Features:
- Immediate execution
- No queuing overhead
- Full metrics tracking
- Middleware support
- Exception handling
Example:
final driver = SynchronousDriver(
config: DriverConfig(name: 'sync'),
middleware: middleware,
);
// Job executes immediately on push
await driver.push(SendEmailJob('user@example.com'));
- Inheritance
-
- Object
- BaseQueueDriver
- SynchronousDriver
Constructors
- SynchronousDriver({required DriverConfig config, QueueMetrics? metrics, FailedJobHandler? dlqHandler, QueueMiddlewarePipeline? middleware})
Properties
- config → DriverConfig
-
finalinherited
- dlqHandler → FailedJobHandler?
-
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- metrics → QueueMetrics?
-
finalinherited
- middleware → QueueMiddlewarePipeline?
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clear(
) → Future< void> -
Clear all jobs (for testing)
override
-
createJobContext(
QueueJob job, {Duration? delay}) → JobContext -
Create job context
inherited
-
dispose(
) → Future< void> -
Dispose resources
inherited
-
executeJob(
JobContext context) → Future< void> -
Execute job with full lifecycle
inherited
-
generateJobId(
) → String -
Generate unique job ID
inherited
-
getStats(
) → Future< Map< String, dynamic> > -
Get driver statistics
override
-
handleJobFailure(
JobContext context) → Future< void> -
Handle job failure with retry logic
inherited
-
isHealthy(
) → Future< bool> -
Health check
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onJobCompleted(
JobContext context) → Future< void> -
Called when a job is successfully completed
inherited
-
onJobFailed(
JobContext context) → Future< void> -
Called when a job fails permanently
inherited
-
onJobRetried(
JobContext context) → Future< void> -
Called when a job is retried
inherited
-
process(
) → Future< void> -
Starts processing queued jobs.
override
-
push(
QueueJob job, {Duration? delay}) → Future< void> -
Pushes a QueueJob to the queue with optional
delay.override -
retryJob(
JobContext context, {required Duration delay}) → Future< void> -
Retry a failed job
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited