Documentation ¶
Index ¶
- func Apply[T any](initial *T, callbacks []func(*T)) *T
- func Or[T comparable](first, second T) T
- func Pool[T any](ctx context.Context, count int, consumer func(*T)) chan *T
- type Context
- type CreateTask
- type Engine
- type Handler
- type HandlerStruct
- type Job
- type JobConfig
- type JobEngine
- type JobHandler
- type MiddlewareFunc
- type MiddlewareHandler
- type PublishOption
- type Service
- func (s *Service) Listen(ctx context.Context) error
- func (s *Service) ListenJobs(ctx context.Context) error
- func (s *Service) ListenTasks(ctx context.Context) error
- func (s *Service) ListenWaitingJobs(ctx context.Context) error
- func (s *Service) ListenWaitingTasks(ctx context.Context) error
- func (s *Service) Publish(ctx context.Context, name string, data []byte, options ...PublishOption) error
- func (s *Service) RegisterJob(ctx context.Context, config *JobConfig, h JobHandler) HandlerStruct
- func (s *Service) TaskHandler(name string, h Handler, middlewares ...MiddlewareHandler) HandlerStruct
- func (s *Service) UpdateTask(ctx context.Context, name string, updatedLaunchAt time.Time) error
- func (s *Service) UseMiddleware(h MiddlewareHandler)
- type Stepper
- type Task
- type TaskEngine
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Or ¶
func Or[T comparable](first, second T) T
Types ¶
type CreateTask ¶
type Engine ¶
type Engine interface { TaskEngine JobEngine }
type HandlerStruct ¶
type HandlerStruct interface { OnFinish(h Handler) HandlerStruct Subtask(handler Handler) HandlerStruct UseMiddleware(middlewares ...MiddlewareHandler) DependOnCustomId() HandlerStruct }
type Job ¶
type Job struct { Status string `json:"status"` Name string `json:"name"` Pattern string `json:"pattern"` NextLaunchAt time.Time `json:"naxtLaunchAt"` EngineContext context.Context `json:"-"` }
func (*Job) CalculateNextLaunch ¶
type JobEngine ¶
type JobEngine interface { FindNextJob(ctx context.Context, statuses []string) (*Job, error) GetUnreleasedJobChildren(ctx context.Context, name string) (*Task, error) Release(ctx context.Context, job *Job, nextLaunchAt time.Time) error WaitForSubtasks(ctx context.Context, job *Job) error RegisterJob(ctx context.Context, cfg *JobConfig) error Init(ctx context.Context) error }
type JobHandler ¶
type MiddlewareFunc ¶
type MiddlewareHandler ¶
type MiddlewareHandler func(t MiddlewareFunc) MiddlewareFunc
type PublishOption ¶
type PublishOption func(c *CreateTask)
func LaunchAt ¶
func LaunchAt(t time.Time) PublishOption
func SetDelay ¶
func SetDelay(d time.Duration) PublishOption
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ListenWaitingTasks ¶
func (*Service) RegisterJob ¶
func (s *Service) RegisterJob(ctx context.Context, config *JobConfig, h JobHandler) HandlerStruct
func (*Service) TaskHandler ¶
func (s *Service) TaskHandler(name string, h Handler, middlewares ...MiddlewareHandler) HandlerStruct
func (*Service) UpdateTask ¶ added in v0.0.2
func (*Service) UseMiddleware ¶
func (s *Service) UseMiddleware(h MiddlewareHandler)
type Stepper ¶
type Stepper interface { TaskHandler(name string, handler Handler, middlewares ...MiddlewareHandler) HandlerStruct Listen(ctx context.Context) error Publish(ctx context.Context, name string, data []byte, options ...PublishOption) error UpdateTask(ctx context.Context, name string, updatedLaunchAt time.Time) error RegisterJob(ctx context.Context, config *JobConfig, h JobHandler) HandlerStruct UseMiddleware(h MiddlewareHandler) }
func NewService ¶
type Task ¶
type Task struct { ID string `json:"_id"` CustomId string `bson:"custom_id"` Name string `json:"name"` Data []byte `json:"data"` JobId string `json:"jobId"` Parent string `json:"parent"` LaunchAt time.Time `json:"launchAt"` Status string `json:"status"` LockAt *time.Time `json:"lock_at"` State []byte `json:"state"` MiddlewaresState map[string][]byte `json:"middlewares_state"` EngineContext context.Context `json:"-"` }
type TaskEngine ¶
type TaskEngine interface { GetRelatedTask(ctx context.Context, task *Task) (*Task, error) FindNextTask(ctx context.Context, statuses []string) (*Task, error) ReleaseTask(ctx context.Context, task *Task) error WaitTaskForSubtasks(ctx context.Context, task *Task) error FailTask(ctx context.Context, task *Task, err error, timeout time.Duration) error CreateTask(ctx context.Context, task *Task) error UpdateTask(ctx context.Context, name string, updatedLaunchAt time.Time) error FindTask(ctx context.Context, name string) (*Task, error) GetUnreleasedTaskChildren(ctx context.Context, task *Task) (*Task, error) SetState(ctx context.Context, task *Task, state []byte) error CollectMetrics(ctx context.Context) error }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.