Interface IJobService
Represents a service for managing background jobs
Namespace: DataWeb.Worker
Assembly: DataWeb.Core.dll
Syntax
public interface IJobService
Methods
GetJobAsync(string, CancellationToken)
Gets a background job with the specified unique identifier
Declaration
Task<Job> GetJobAsync(string id, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | id | The unique identifier of the job to retrieve |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Job> | An asynchronous operation that retrieves the job with the specified Id |
GetJobLogAsync(string, CancellationToken)
Gets the text log for a background job with the specified unique identifier
Declaration
Task<string> GetJobLogAsync(string id, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | id | The unique identifier of the job to retrieve the text log for |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<string> | An asynchronous operation that retrieves the text log for the job with the specified Id |
GetLatestJobsAsync(string, CancellationToken)
Gets a collection of the latest background jobs with the specified name
Declaration
Task<IEnumerable<Job>> GetLatestJobsAsync(string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the jobs to retrieve |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<IEnumerable<Job>> | An asynchronous operation that retrieves the latest jobs with the specified name |
GetWorkingJobAsync(string, CancellationToken)
Gets the working job with the specified name, if one exists
Declaration
Task<Job> GetWorkingJobAsync(string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the job to retrieve |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Job> | An asynchronous operation that retrieves the working job with the specified name, or null if no such job exists |
IsWorkingJobAsync(string, CancellationToken)
Checks whether a working job with the specified name exists
Declaration
Task<bool> IsWorkingJobAsync(string name, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the job to check for |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> | An asynchronous operation that returns true if a working job with the specified name exists, false otherwise |
SetJobStatusAsync(string, JobStatus, CancellationToken)
Sets the status of a background job with the specified unique identifier
Declaration
Task SetJobStatusAsync(string id, JobStatus status, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | id | The unique identifier of the job to update |
JobStatus | status | The new JobStatus to set for the job |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task | An asynchronous operation that sets the status of the job with the specified Id |
StartNewJobAsync(string, int, int, List<Parameter>, CancellationToken)
Starts a new background job with the specified name, total units of work, and optional parameters
Declaration
Task<Job> StartNewJobAsync(string name, int total, int startOffset = 0, List<Parameter> parameters = null, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the job to start |
int | total | The total number of units of work for the job |
int | startOffset | The starting progress offset for the job |
List<Parameter> | parameters | Optional parameters for the job |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<Job> | An asynchronous operation that starts a new job with the specified parameters and returns the newly created job |