model

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Job statuses before processing
	JobStatusQueued    = "QUEUED"
	JobStatusScheduled = "SCHEDULED"
	// Running status is used when the job is being processed by a worker.
	JobStatusRunning = "RUNNING"
	// Job statuses after processing
	JobStatusFailed    = "FAILED"
	JobStatusSucceeded = "SUCCEEDED"
	JobStatusCancelled = "CANCELLED"
)
View Source
const (
	RETRY_BACKOFF_NONE        = "none"
	RETRY_BACKOFF_LINEAR      = "linear"
	RETRY_BACKOFF_EXPONENTIAL = "exponential"
)
View Source
const (
	WorkerStatusRunning = "RUNNING"
	WorkerStatusFailed  = "FAILED"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BatchJob

type BatchJob struct {
	Task       interface{}
	Parameters []interface{}
	Options    *Options
}

type DBTime

type DBTime struct {
	time.Time
}

func (*DBTime) IsSet

func (ct *DBTime) IsSet() bool

func (DBTime) MarshalJSON

func (ct DBTime) MarshalJSON() ([]byte, error)

func (*DBTime) UnmarshalJSON

func (ct *DBTime) UnmarshalJSON(b []byte) error

type Job

type Job struct {
	ID            int        `json:"id"`
	RID           uuid.UUID  `json:"rid"`
	WorkerID      int        `json:"worker_id"`
	WorkerRID     uuid.UUID  `json:"worker_rid"`
	Options       *Options   `json:"options"`
	TaskName      string     `json:"task_name"`
	Parameters    Parameters `json:"parameters"`
	Status        string     `json:"status"`
	ScheduledAt   *time.Time `json:"scheduled_at"`
	StartedAt     *time.Time `json:"started_at"`
	ScheduleCount int        `json:"schedule_count"`
	Attempts      int        `json:"attempts"`
	Results       Parameters `json:"result"`
	Error         string     `json:"error"`
	CreatedAt     time.Time  `json:"created_at"`
	UpdatedAt     time.Time  `json:"updated_at"`
}

func NewJob

func NewJob(task interface{}, options *Options, parameters ...interface{}) (*Job, error)

type JobFromNotification

type JobFromNotification struct {
	ID          int        `json:"id"`
	RID         uuid.UUID  `json:"rid"`
	WorkerID    int        `json:"worker_id"`
	WorkerRID   uuid.UUID  `json:"worker_rid"`
	Options     *Options   `json:"options"`
	TaskName    string     `json:"task_name"`
	Parameters  Parameters `json:"parameters"`
	Status      string     `json:"status"`
	ScheduledAt DBTime     `json:"scheduled_at"`
	StartedAt   DBTime     `json:"started_at"`
	Attempts    int        `json:"attempts"`
	Results     Parameters `json:"result"`
	Error       string     `json:"error"`
	CreatedAt   DBTime     `json:"created_at"`
	UpdatedAt   DBTime     `json:"updated_at"`
}

func (*JobFromNotification) ToJob

func (jn *JobFromNotification) ToJob() *Job

type NextIntervalFunc

type NextIntervalFunc func(start time.Time, currentCount int) time.Time

NextIntervalFunc defines a function type that calculates the next interval based on the start time and the current count of executions.

type OnError

type OnError struct {
	Timeout      float64 `json:"timeout"`
	MaxRetries   int     `json:"max_retries"`
	RetryDelay   float64 `json:"retry_delay"`
	RetryBackoff string  `json:"retry_backoff"`
}

func (*OnError) IsValid

func (c *OnError) IsValid() error

func (OnError) Marshal

func (r OnError) Marshal() ([]byte, error)

func (*OnError) Scan

func (c *OnError) Scan(value interface{}) error

func (*OnError) Unmarshal

func (r *OnError) Unmarshal(value interface{}) error

func (OnError) Value

func (c OnError) Value() (driver.Value, error)

type Options

type Options struct {
	OnError  *OnError  `json:"on_error,omitempty"`
	Schedule *Schedule `json:"schedule,omitempty"`
}

func (*Options) IsValid

func (c *Options) IsValid() error

func (Options) Marshal

func (r Options) Marshal() ([]byte, error)

func (*Options) Scan

func (c *Options) Scan(value interface{}) error

func (*Options) Unmarshal

func (r *Options) Unmarshal(value interface{}) error

func (Options) Value

func (c Options) Value() (driver.Value, error)

type Parameters

type Parameters []interface{}

func (Parameters) Marshal

func (r Parameters) Marshal() ([]byte, error)

func (*Parameters) Scan

func (c *Parameters) Scan(value interface{}) error

func (*Parameters) ToInterfaceSlice

func (r *Parameters) ToInterfaceSlice() []interface{}

func (*Parameters) ToReflectValues

func (r *Parameters) ToReflectValues() []reflect.Value

func (*Parameters) Unmarshal

func (r *Parameters) Unmarshal(value interface{}) error

func (Parameters) Value

func (c Parameters) Value() (driver.Value, error)

type Schedule

type Schedule struct {
	Start        time.Time     `json:"start"`
	MaxCount     int           `json:"max_count"`
	Interval     time.Duration `json:"interval"`
	NextInterval string        `json:"next_interval,omitempty"`
}

func (*Schedule) IsValid

func (c *Schedule) IsValid() error

func (Schedule) Marshal

func (r Schedule) Marshal() ([]byte, error)

func (*Schedule) Scan

func (c *Schedule) Scan(value interface{}) error

func (*Schedule) Unmarshal

func (r *Schedule) Unmarshal(value interface{}) error

func (Schedule) Value

func (c Schedule) Value() (driver.Value, error)

type Task

type Task struct {
	Task             interface{}
	Name             string
	InputParameters  []reflect.Type
	OutputParameters []reflect.Type
}

func NewTask

func NewTask(task interface{}) (*Task, error)

func NewTaskWithName

func NewTaskWithName(task interface{}, taskName string) (*Task, error)

type Worker

type Worker struct {
	ID                         int       `json:"id"`
	RID                        uuid.UUID `json:"rid"`
	Name                       string    `json:"name"`
	Options                    *OnError  `json:"options,omitempty"`
	MaxConcurrency             int       `json:"max_concurrency"`
	AvailableTasks             []string  `json:"available_tasks,omitempty"`
	AvailableNextIntervalFuncs []string  `json:"available_next_interval,omitempty"`
	Status                     string    `json:"status"`
	CreatedAt                  time.Time `json:"created_at"`
	UpdatedAt                  time.Time `json:"updated_at"`
}

func NewWorker

func NewWorker(name string, maxConcurrency int) (*Worker, error)

func NewWorkerWithOptions

func NewWorkerWithOptions(name string, maxConcurrency int, options *OnError) (*Worker, error)

Jump to

Keyboard shortcuts

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