job_repo

package
v0.0.0-...-e71a76f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

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 New

func New() *Client

New returns a new job client.

func (*Client) AddFilter

func (client *Client) AddFilter(filter bson.D) *Client

AddFilter adds a custom filter to the client.

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

func (client *Client) ExcludeIDs(ids ...string) *Client

ExcludeIDs adds a filter to the client to exclude the given IDs.

func (*Client) ExcludeScheduled

func (client *Client) ExcludeScheduled() *Client

ExcludeScheduled adds a filter to the client to exclude scheduled jobs.

func (*Client) ExcludeStatus

func (client *Client) ExcludeStatus(status ...string) *Client

ExcludeStatus adds a filter to the client to exclude the given status.

func (*Client) ExcludeTypes

func (client *Client) ExcludeTypes(types ...string) *Client

ExcludeTypes adds a filter to the client to exclude the given types.

func (*Client) FilterArgs

func (client *Client) FilterArgs(argName string, filter interface{}) *Client

FilterArgs adds a filter to the client to only include jobs with the given args.

func (*Client) GetNext

func (client *Client) GetNext() (*model.Job, error)

GetNext returns the next job that should be executed.

func (*Client) GetNextFailed

func (client *Client) GetNextFailed() (*model.Job, error)

GetNextFailed returns the next job that failed and should be retried.

func (*Client) IncludeStatus

func (client *Client) IncludeStatus(status ...string) *Client

IncludeStatus adds a filter to the client to only include jobs with the given status.

func (*Client) IncludeTypes

func (client *Client) IncludeTypes(types ...string) *Client

IncludeTypes adds a filter to the client to only include jobs with the given types.

func (*Client) MarkCompleted

func (client *Client) MarkCompleted(jobID string) error

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

func (client *Client) MarkTerminated(jobID string, reason string) error

MarkTerminated marks a job as terminated, meaning it should not be retried.

func (*Client) ResetRunning

func (client *Client) ResetRunning() error

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

func (client *Client) WithPagination(page, pageSize int) *Client

WithPagination adds pagination to the client.

func (*Client) WithSort

func (client *Client) WithSort(field string, order int) *Client

WithSort adds sorting to the client.

func (*Client) WithUserID

func (client *Client) WithUserID(userID string) *Client

WithUserID adds a filter to the client to only include jobs with the given user ID.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL