Documentation ¶
Index ¶
- Constants
- func NewID() string
- type Manager
- func (m *Manager) CheckIn(ctx context.Context, id string) error
- func (m *Manager) Complete(ctx context.Context, id string) error
- func (m *Manager) Fail(ctx context.Context, id, message string) error
- func (m *Manager) GetTask(ctx context.Context, id string) (*Task, error)
- func (m *Manager) Handler() http.Handler
- func (m *Manager) Log(ctx context.Context, id, message string) error
- func (m *Manager) Start(ctx context.Context, t *Task) error
- type ManagerOption
- func WithRedis(client *redis.Client) ManagerOption
- func WithRedisAddress(address string) ManagerOption
- func WithRedisDatabase(db int) ManagerOption
- func WithRedisPassword(password string) ManagerOption
- func WithRedisUsername(username string) ManagerOption
- func WithTTL(ttl time.Duration) ManagerOption
- func WithoutRedisPing() ManagerOption
- type Task
Constants ¶
const ( STATUS_COMPLETED = "completed" STATUS_CREATED = "created" STATUS_FAILED = "failed" STATUS_RUNNING = "running" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager controls the communication with redis
func NewManager ¶
func NewManager(namespace string, opts ...ManagerOption) (*Manager, error)
NewManager creates a new manager instance used to communicate with the redis storage engine
type ManagerOption ¶
type ManagerOption func(*Manager)
func WithRedis ¶
func WithRedis(client *redis.Client) ManagerOption
WithRedis sets the redis client to support advanced options
func WithRedisAddress ¶
func WithRedisAddress(address string) ManagerOption
WithRedisAddress sets the address for redis in the form <ipaddress|hostname>:<port>. This will be ignored if WithRedis() is passed.
func WithRedisDatabase ¶
func WithRedisDatabase(db int) ManagerOption
WithRedisDatabase sets the redis database to be used. This will be ignored if WithRedis() is passed.
func WithRedisPassword ¶
func WithRedisPassword(password string) ManagerOption
WithRedisPassword sets the redis password to be used. This will be ignored if WithRedis() is passed.
func WithRedisUsername ¶
func WithRedisUsername(username string) ManagerOption
WithRedisUsername sets the redis username to be used. This will be ignored if WithRedis() is passed.
func WithTTL ¶
func WithTTL(ttl time.Duration) ManagerOption
WithTTL sets the amount of time a job will linger in the persistence layer (redis) after the last check-in, log message, completion or failure. This sets a TTL on the redis keys used by the library.
func WithoutRedisPing ¶
func WithoutRedisPing() ManagerOption
WithoutRedisPing disables the initial redis ping check
type Task ¶
type Task struct { CheckinAt string `json:"checkin_at,omitempty"` CompletedAt string `json:"completed_at,omitempty"` CreatedAt string `json:"created_at,omitempty"` ID string `json:"id"` Status string `json:"status"` Events []string `json:"events,omitempty"` FailedAt string `json:"failed_at,omitempty"` Failure string `json:"failure,omitempty"` }
Task is the detail about a task