C# Class BlueCollar.Worker

Represents an individual worker that dequeues jobs and performs work.
Inheritance: IDisposable
Show file Open project: ChadBurggraf/blue-collar Class Usage Examples

Private Properties

Property Type Description
CancelCurrent void
CreateHistory HistoryRecord
CreateQueueRetry QueueRecord
CreateWorking WorkingRecord
DequeueRecord WorkingRecord
Dispose void
ExecuteJob bool
KillRunThread void
KillSignalThread void
PruneOrphans void
RunLoop void
SetStatus void
SetStatus void
SignalLoop void
Start bool

Public Methods

Method Description
Dispose ( ) : void

Disposes of resources used by this instance.

Stop ( bool force ) : void

Stops the worker.

Worker ( string applicationName, long id, string name, QueueNameFilters queueFilters, int heartbeat, bool schedulerEnabled, IRepositoryFactory repositoryFactory, ILogger logger ) : System

Initializes a new instance of the Worker class.

Worker ( string applicationName, long id, string name, QueueNameFilters queueFilters, int heartbeat, bool schedulerEnabled, IRepositoryFactory repositoryFactory, ILogger logger, IScheduler scheduler ) : System

Initializes a new instance of the Worker class.

Private Methods

Method Description
CancelCurrent ( ) : void

Cancels the current job.

CreateHistory ( WorkingRecord working, HistoryStatus status ) : HistoryRecord

Creates a history record from the given working record and status.

CreateQueueRetry ( WorkingRecord working ) : QueueRecord

Creates a queue retry record from the given working record.

CreateWorking ( QueueRecord queued, long workerId, long scheduleId, System.DateTime startedOn ) : WorkingRecord

Creates a working record from the given queued record.

DequeueRecord ( ) : WorkingRecord

Dequeues a job to do work on.

Dispose ( bool disposing ) : void

Disposes of resources used by this instance.

ExecuteJob ( IJob job, Exception &ex ) : bool
KillRunThread ( ) : void
KillSignalThread ( ) : void
PruneOrphans ( ) : void

Prunes orphaned jobs assigned to this worker that for one reason or another didn't get marked as interrupted.

RunLoop ( ) : void
SetStatus ( WorkerStatus status ) : void

Sets this worker's status.

SetStatus ( WorkerStatus status, IRepository repository, IDbTransaction transaction ) : void

Sets this worker's status.

SignalLoop ( ) : void
Start ( ) : bool

Method Details

Dispose() public method

Disposes of resources used by this instance.
public Dispose ( ) : void
return void

Stop() public method

Stops the worker.
public Stop ( bool force ) : void
force bool A value indicating whether to force the worker to stop, even if work will be abandoned.
return void

Worker() public method

Initializes a new instance of the Worker class.
public Worker ( string applicationName, long id, string name, QueueNameFilters queueFilters, int heartbeat, bool schedulerEnabled, IRepositoryFactory repositoryFactory, ILogger logger ) : System
applicationName string The name of the application the worker belongs to.
id long The ID of the worker in the repository.
name string The name of the worker.
queueFilters QueueNameFilters The queue name filters the worker should use while processing queues..
heartbeat int The number of seconds between poll intervals.
schedulerEnabled bool A value indicating whether the scheduler is enabled.
repositoryFactory IRepositoryFactory The repository factory to use when accessing data.
logger ILogger The logger to use when logging messages.
return System

Worker() public method

Initializes a new instance of the Worker class.
public Worker ( string applicationName, long id, string name, QueueNameFilters queueFilters, int heartbeat, bool schedulerEnabled, IRepositoryFactory repositoryFactory, ILogger logger, IScheduler scheduler ) : System
applicationName string The name of the application the worker belongs to.
id long The ID of the worker in the repository.
name string The name of the worker.
queueFilters QueueNameFilters The queue name filters the worker should use while processing queues..
heartbeat int The number of seconds between poll intervals.
schedulerEnabled bool A value indicating whether the scheduler is enabled.
repositoryFactory IRepositoryFactory The repository factory to use when accessing data.
logger ILogger The logger to use when logging messages.
scheduler IScheduler The scheduler to use when managing schedules and enqueueing scheduled jobs.
return System