Documentation ¶
Index ¶
- type BackgroundWorker
- type CleanUpConfig
- type Client
- func (c *Client) CleanUp(config CleanUpConfig) error
- func (c *Client) DestroyAllWorkers()
- func (c *Client) EnqueueJob(name string, args interface{}, config JobConfig) error
- func (c *Client) NamedJobInfo(name string) (JobInfo, error)
- func (c *Client) NewBackgroundWorker() *BackgroundWorker
- func (c *Client) PendingJobs() ([]*Job, error)
- func (c *Client) RegisterWorker(name string, wf WorkerFunc)
- func (c *Client) StartAllWorkers()
- func (c *Client) StopAllWorkers()
- func (c *Client) StopAllWorkersBlocking()
- type ClientConfig
- type InternalClient
- type Job
- type JobConfig
- type JobInfo
- type JobRef
- type WorkerFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BackgroundWorker ¶
type BackgroundWorker struct {
// contains filtered or unexported fields
}
BackgroundWorker represents a worker thread that runs in the background
func (*BackgroundWorker) IsRunning ¶
func (bw *BackgroundWorker) IsRunning() bool
IsRunning returns whether or not the background worker is running.
func (*BackgroundWorker) Start ¶
func (bw *BackgroundWorker) Start()
Start starts the background worker. If it is already running, nothing happens.
func (*BackgroundWorker) Stop ¶
func (bw *BackgroundWorker) Stop()
Stop stops the background worker. This is non blocking, so it may take some time before the background worker is fully stopped. Use IsRunning() to see if it's still running.
func (*BackgroundWorker) StopBlocking ¶
func (bw *BackgroundWorker) StopBlocking()
StopBlocking stops the background worker. It will block until the background worker has stopped running.
type CleanUpConfig ¶
CleanUpConfig includes options for CleanUp methods
type Client ¶
type Client struct { InternalClient // contains filtered or unexported fields }
Client is the main handle for a jobinator instance. It is where you will perform most actions.
func NewClient ¶
func NewClient(ic InternalClient, config ClientConfig) *Client
NewClient will wrap a client implementation and return the resulting client. Meant to be used for implementing storage backends.
func (*Client) CleanUp ¶
func (c *Client) CleanUp(config CleanUpConfig) error
CleanUp deletes all jobs that have been finished (or optionally failed jobs) older than specified in the CleanUpConfig
func (*Client) DestroyAllWorkers ¶
func (c *Client) DestroyAllWorkers()
DestroyAllWorkers stops all workers registered with the client and destroys them.
func (*Client) EnqueueJob ¶
EnqueueJob queues up a job to be run by a worker.
func (*Client) NewBackgroundWorker ¶
func (c *Client) NewBackgroundWorker() *BackgroundWorker
NewBackgroundWorker returns a background worker handle, as well as registers it in the client. You can either keep it to start it yourself or use the client to start all background worker threads.
func (*Client) PendingJobs ¶
PendingJobs returns the number of pending jobs.
func (*Client) RegisterWorker ¶
func (c *Client) RegisterWorker(name string, wf WorkerFunc)
RegisterWorker registers a new workerfunc against it's identifier(name)
func (*Client) StartAllWorkers ¶
func (c *Client) StartAllWorkers()
StartAllWorkers starts all workers registered with the client.
func (*Client) StopAllWorkers ¶
func (c *Client) StopAllWorkers()
StopAllWorkers stops all workers registered with the client. This is non blocking, so you may need to wait before they are all finished.
func (*Client) StopAllWorkersBlocking ¶
func (c *Client) StopAllWorkersBlocking()
StopAllWorkersBlocking stops all workers registered with the client. This is blocking.
type ClientConfig ¶
ClientConfig is settings that the client uses during runtime
type InternalClient ¶
type InternalClient interface { InternalEnqueueJob(*Job) error InternalSelectJob() (*Job, error) InternalPendingJobs() ([]*Job, error) InternalRegisterWorker(string, WorkerFunc) IncRetryCount(*Job) error SetStatus(*Job, int) error SetFinishedAt(*Job, int64) error SetNextRun(*Job, int64) error SetError(*Job, string, string) error InternalCleanup(CleanUpConfig) error GetNamedJob(string) (*Job, error) }
InternalClient is the interface a storage backend has to implement. See memoryclient or gormclient for details.
type Job ¶
type Job struct { ID string Name string `gorm:"index"` Args []byte CreatedAt int64 Status int `gorm:"index"` RetryCount int MaxRetry int Error string ErrorStack string FinishedAt int64 Repeat bool RepeatInterval time.Duration NextRun int64 NamedJob string `gorm:"index"` //named jobs should be unique but we don't want to require a name, so I'm not using unique_index }
Job is the internal representation of a job
type JobRef ¶
type JobRef struct {
// contains filtered or unexported fields
}
JobRef is a reference to a job (and it's client). It is passed to a WorkerFunc to get the job args
type WorkerFunc ¶
WorkerFunc is the type of function that must be implemented to be a worker