Documentation
¶
Index ¶
- type Client
- func (client *Client) AddFilter(filter bson.D) *Client
- func (client *Client) Create(id, userID, jobType, version string, args map[string]interface{}) error
- func (client *Client) CreateScheduled(id, userID, jobType, version string, runAfter time.Time, ...) error
- func (client *Client) ExcludeIDs(ids ...string) *Client
- func (client *Client) ExcludeScheduled() *Client
- func (client *Client) ExcludeStatus(status ...string) *Client
- func (client *Client) ExcludeTypes(types ...string) *Client
- func (client *Client) FilterArgs(argName string, filter interface{}) *Client
- func (client *Client) GetNext() (*model.Job, error)
- func (client *Client) GetNextFailed() (*model.Job, error)
- func (client *Client) IncludeStatus(status ...string) *Client
- func (client *Client) IncludeTypes(types ...string) *Client
- func (client *Client) MarkCompleted(jobID string) error
- func (client *Client) MarkFailed(jobID string, runAfter time.Time, attempts int, reason string) error
- func (client *Client) MarkTerminated(jobID string, reason string) error
- func (client *Client) ResetRunning() error
- func (client *Client) UpdateWithParams(id string, params *model.JobUpdateParams) error
- func (client *Client) WithPagination(page, pageSize int) *Client
- func (client *Client) WithSort(field string, order int) *Client
- func (client *Client) WithUserID(userID string) *Client
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { base_clients.ResourceClient[model.Job] RestrictUserID *string }
Client is used to manage jobs in the database.
func (*Client) Create ¶
func (client *Client) Create(id, userID, jobType, version string, args map[string]interface{}) error
Create creates a new job in the database.
func (*Client) CreateScheduled ¶
func (client *Client) CreateScheduled(id, userID, jobType, version string, runAfter time.Time, args map[string]interface{}) error
CreateScheduled creates a new job in the database that will run after the given time.
func (*Client) ExcludeIDs ¶
ExcludeIDs adds a filter to the client to exclude the given IDs.
func (*Client) ExcludeScheduled ¶
ExcludeScheduled adds a filter to the client to exclude scheduled jobs.
func (*Client) ExcludeStatus ¶
ExcludeStatus adds a filter to the client to exclude the given status.
func (*Client) ExcludeTypes ¶
ExcludeTypes adds a filter to the client to exclude the given types.
func (*Client) FilterArgs ¶
FilterArgs adds a filter to the client to only include jobs with the given args.
func (*Client) GetNextFailed ¶
GetNextFailed returns the next job that failed and should be retried.
func (*Client) IncludeStatus ¶
IncludeStatus adds a filter to the client to only include jobs with the given status.
func (*Client) IncludeTypes ¶
IncludeTypes adds a filter to the client to only include jobs with the given types.
func (*Client) MarkCompleted ¶
MarkCompleted marks a job as completed.
func (*Client) MarkFailed ¶
func (client *Client) MarkFailed(jobID string, runAfter time.Time, attempts int, reason string) error
MarkFailed marks a job as failed, meaning it should be retried.
func (*Client) MarkTerminated ¶
MarkTerminated marks a job as terminated, meaning it should not be retried.
func (*Client) ResetRunning ¶
ResetRunning resets all running jobs to pending. This is used when the application is restarted to prevent jobs from being stuck in running state.
func (*Client) UpdateWithParams ¶
func (client *Client) UpdateWithParams(id string, params *model.JobUpdateParams) error
UpdateWithParams updates the job with the given params.
func (*Client) WithPagination ¶
WithPagination adds pagination to the client.
func (*Client) WithUserID ¶
WithUserID adds a filter to the client to only include jobs with the given user ID.