startWorker method
Future<void>
startWorker({
- int? maxJobs,
- Duration delay = const Duration(seconds: 1),
- Duration? timeout,
- bool runInBackground = false,
- void onError(
- dynamic error,
- StackTrace stack
- void onJobStart(
- QueueJob job
- void onJobComplete(
- QueueJob job,
- dynamic result
- void onJobError(
- QueueJob job,
- dynamic error,
- StackTrace stack
Starts a queue worker with the specified configuration.
Implementation
Future<void> startWorker({
int? maxJobs,
Duration delay = const Duration(seconds: 1),
Duration? timeout,
bool runInBackground = false,
void Function(dynamic error, StackTrace stack)? onError,
void Function(QueueJob job)? onJobStart,
void Function(QueueJob job, dynamic result)? onJobComplete,
void Function(QueueJob job, dynamic error, StackTrace stack)? onJobError,
}) async {
final config = QueueWorkerConfig(
maxJobs: maxJobs,
delay: delay,
timeout: timeout,
runInBackground: runInBackground,
onError: onError,
onJobStart: onJobStart,
onJobComplete: onJobComplete,
onJobError: onJobError,
);
final worker = QueueWorker(_defaultDriver!, config);
await worker.start();
}