Documentation
¶
Index ¶
- Constants
- func NextRunAt(rule RecurrenceRule, now *carbon.Carbon) (*carbon.Carbon, error)
- type DayOfWeek
- type Frequency
- type MonthOfYear
- type NewStoreOptions
- type QueueInterface
- type QueueQueryInterface
- type RecurrenceRule
- type ScheduleDefinition
- type ScheduleInterface
- type Store
- func (st *Store) AutoMigrate() error
- func (st *Store) EnableDebug(debugEnabled bool) StoreInterface
- func (store *Store) QueueCount(options QueueQueryInterface) (int64, error)
- func (store *Store) QueueCreate(queue QueueInterface) error
- func (store *Store) QueueDelete(queue QueueInterface) error
- func (st *Store) QueueDeleteByID(id string) error
- func (st *Store) QueueFail(queue QueueInterface) error
- func (store *Store) QueueFindByID(id string) (QueueInterface, error)
- func (store *Store) QueueFindNextQueuedTask() (QueueInterface, error)
- func (store *Store) QueueFindRunning(limit int) []QueueInterface
- func (store *Store) QueueList(query QueueQueryInterface) ([]QueueInterface, error)
- func (store *Store) QueueProcessNext() error
- func (store *Store) QueueRunGoroutine(processSeconds int, unstuckMinutes int)
- func (store *Store) QueueSoftDelete(queue QueueInterface) error
- func (store *Store) QueueSoftDeleteByID(id string) error
- func (st *Store) QueueSuccess(queue QueueInterface) error
- func (store *Store) QueueUnstuck(waitMinutes int)
- func (store *Store) QueueUpdate(queue QueueInterface) error
- func (store *Store) QueuedTaskForceFail(queuedTask QueueInterface, waitMinutes int) error
- func (store *Store) QueuedTaskProcess(queuedTask QueueInterface) (bool, error)
- func (st *Store) SqlCreateQueueTable() string
- func (st *Store) SqlCreateTaskTable() string
- func (store *Store) TaskCount(options TaskQueryInterface) (int64, error)
- func (store *Store) TaskCreate(task TaskInterface) error
- func (store *Store) TaskDelete(task TaskInterface) error
- func (store *Store) TaskDeleteByID(id string) error
- func (st *Store) TaskEnqueueByAlias(taskAlias string, parameters map[string]interface{}) (QueueInterface, error)
- func (store *Store) TaskExecuteCli(alias string, args []string) bool
- func (store *Store) TaskFindByAlias(alias string) (task TaskInterface, err error)
- func (store *Store) TaskFindByID(id string) (task TaskInterface, err error)
- func (store *Store) TaskHandlerAdd(taskHandler TaskHandlerInterface, createIfMissing bool) error
- func (store *Store) TaskHandlerList() []TaskHandlerInterface
- func (store *Store) TaskList(query TaskQueryInterface) ([]TaskInterface, error)
- func (store *Store) TaskSoftDelete(task TaskInterface) error
- func (store *Store) TaskSoftDeleteByID(id string) error
- func (store *Store) TaskUpdate(task TaskInterface) error
- type StoreInterface
- type TaskHandlerBase
- func (handler *TaskHandlerBase) ErrorMessage() string
- func (handler *TaskHandlerBase) GetParam(paramName string) string
- func (handler *TaskHandlerBase) GetParamArray(paramName string) []string
- func (handler *TaskHandlerBase) HasQueuedTask() bool
- func (handler *TaskHandlerBase) InfoMessage() string
- func (handler *TaskHandlerBase) LogError(message string)
- func (handler *TaskHandlerBase) LogInfo(message string)
- func (handler *TaskHandlerBase) LogSuccess(message string)
- func (handler *TaskHandlerBase) Options() map[string]string
- func (handler *TaskHandlerBase) QueuedTask() QueueInterface
- func (handler *TaskHandlerBase) SetOptions(options map[string]string)
- func (handler *TaskHandlerBase) SetQueuedTask(queuedTask QueueInterface)
- func (handler *TaskHandlerBase) SuccessMessage() string
- type TaskHandlerInterface
- type TaskInterface
- type TaskQueryInterface
Constants ¶
const ASC = "asc"
const COLUMN_ALIAS = "alias"
const COLUMN_ATTEMPTS = "attempts"
const COLUMN_COMPLETED_AT = "completed_at"
const COLUMN_CREATED_AT = "created_at"
const COLUMN_DELETED_AT = "deleted_at"
const COLUMN_DESCRIPTION = "description"
const COLUMN_DETAILS = "details"
const COLUMN_ID = "id"
const COLUMN_MEMO = "memo"
const COLUMN_METAS = "metas"
const COLUMN_OUTPUT = "output"
const COLUMN_PARAMETERS = "parameters"
const COLUMN_STARTED_AT = "started_at"
const COLUMN_STATUS = "status"
const COLUMN_TASK_ID = "task_id"
const COLUMN_TITLE = "title"
const COLUMN_UPDATED_AT = "updated_at"
const DESC = "desc"
const QueueStatusCanceled = "canceled"
const QueueStatusDeleted = "deleted"
const QueueStatusFailed = "failed"
const QueueStatusPaused = "paused"
const QueueStatusQueued = "queued"
const QueueStatusRunning = "running"
const QueueStatusSuccess = "success"
const TaskStatusActive = "active"
const TaskStatusCanceled = "canceled"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Frequency ¶ added in v1.3.0
type Frequency string
Define a string type alias
const ( FrequencyNone Frequency = "none" FrequencySecondly Frequency = "secondly" FrequencyMinutely Frequency = "minutely" FrequencyHourly Frequency = "hourly" FrequencyDaily Frequency = "daily" FrequencyWeekly Frequency = "weekly" FrequencyMonthly Frequency = "monthly" FrequencyYearly Frequency = "yearly" )
Define the constants as strings
type MonthOfYear ¶ added in v1.3.0
type MonthOfYear string
const ( MonthOfYearJanuary MonthOfYear = "JANUARY" MonthOfYearFebruary MonthOfYear = "FEBRUARY" MonthOfYearMarch MonthOfYear = "MARCH" MonthOfYearApril MonthOfYear = "APRIL" MonthOfYearMay MonthOfYear = "MAY" MonthOfYearJune MonthOfYear = "JUNE" MonthOfYearJuly MonthOfYear = "JULY" MonthOfYearAugust MonthOfYear = "AUGUST" MonthOfYearSeptember MonthOfYear = "SEPTEMBER" MonthOfYearOctober MonthOfYear = "OCTOBER" MonthOfYearNovember MonthOfYear = "NOVEMBER" MonthOfYearDecember MonthOfYear = "DECEMBER" )
type NewStoreOptions ¶ added in v0.0.6
type NewStoreOptions struct {
TaskTableName string
QueueTableName string
DB *sql.DB
DbDriverName string
AutomigrateEnabled bool
DebugEnabled bool
}
NewStoreOptions define the options for creating a new task store
type QueueInterface ¶ added in v1.1.0
type QueueInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
IsCanceled() bool
IsDeleted() bool
IsFailed() bool
IsQueued() bool
IsPaused() bool
IsRunning() bool
IsSuccess() bool
IsSoftDeleted() bool
Attempts() int
SetAttempts(attempts int) QueueInterface
CompletedAt() string
CompletedAtCarbon() *carbon.Carbon
SetCompletedAt(completedAt string) QueueInterface
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) QueueInterface
Details() string
AppendDetails(details string) QueueInterface
SetDetails(details string) QueueInterface
ID() string
SetID(id string) QueueInterface
Output() string
SetOutput(output string) QueueInterface
Parameters() string
SetParameters(parameters string) QueueInterface
ParametersMap() (map[string]string, error)
SetParametersMap(parameters map[string]string) (QueueInterface, error)
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(deletedAt string) QueueInterface
StartedAt() string
StartedAtCarbon() *carbon.Carbon
SetStartedAt(startedAt string) QueueInterface
Status() string
SetStatus(status string) QueueInterface
TaskID() string
SetTaskID(taskID string) QueueInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) QueueInterface
}
func NewQueue ¶ added in v1.1.0
func NewQueue() QueueInterface
func NewQueueFromExistingData ¶ added in v1.1.0
func NewQueueFromExistingData(data map[string]string) QueueInterface
type QueueQueryInterface ¶ added in v1.1.0
type QueueQueryInterface interface {
Validate() error
Columns() []string
SetColumns(columns []string) QueueQueryInterface
HasCountOnly() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) QueueQueryInterface
HasCreatedAtGte() bool
CreatedAtGte() string
SetCreatedAtGte(createdAtGte string) QueueQueryInterface
HasCreatedAtLte() bool
CreatedAtLte() string
SetCreatedAtLte(createdAtLte string) QueueQueryInterface
HasID() bool
ID() string
SetID(id string) QueueQueryInterface
HasIDIn() bool
IDIn() []string
SetIDIn(idIn []string) QueueQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) QueueQueryInterface
HasOffset() bool
Offset() int
SetOffset(offset int) QueueQueryInterface
HasSortOrder() bool
SortOrder() string
SetSortOrder(sortOrder string) QueueQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) QueueQueryInterface
HasSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(withDeleted bool) QueueQueryInterface
HasStatus() bool
Status() string
SetStatus(status string) QueueQueryInterface
HasStatusIn() bool
StatusIn() []string
SetStatusIn(statusIn []string) QueueQueryInterface
HasTaskID() bool
TaskID() string
SetTaskID(taskID string) QueueQueryInterface
}
func QueueQuery ¶ added in v1.1.0
func QueueQuery() QueueQueryInterface
type RecurrenceRule ¶ added in v1.3.0
type RecurrenceRule interface {
GetFrequency() Frequency
SetFrequency(Frequency) RecurrenceRule
GetStartsAt() string
SetStartsAt(dateTimeUTC string) RecurrenceRule
GetEndsAt() string
SetEndsAt(dateTimeUTC string) RecurrenceRule
GetInterval() int
SetInterval(int) RecurrenceRule
GetDaysOfWeek() []DayOfWeek
SetDaysOfWeek([]DayOfWeek) RecurrenceRule
GetDaysOfMonth() []int
SetDaysOfMonth([]int) RecurrenceRule
GetMonthsOfYear() []MonthOfYear
SetMonthsOfYear([]MonthOfYear) RecurrenceRule
}
func NewRecurrenceRule ¶ added in v1.3.0
func NewRecurrenceRule() RecurrenceRule
type ScheduleDefinition ¶ added in v1.3.0
type ScheduleDefinition interface {
GetID() string
SetID(string) ScheduleDefinition
GetRecurrenceRule() string
SetRecurrenceRule(dateTimeUtc string) ScheduleDefinition
GetStartsAt() string
SetStartsAt(dateTimeUtc string)
GetEndsAt() string
SetEndsAt(string)
IsValid() bool
GetNextRunTime(string) (string, error)
}
type ScheduleInterface ¶ added in v1.3.0
type ScheduleInterface interface {
ScheduleDefinitionID() string
SetScheduleDefinition(ScheduleDefinition)
}
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines a session store
func NewStore ¶
func NewStore(opts NewStoreOptions) (*Store, error)
NewStore creates a new task store
func (*Store) EnableDebug ¶
func (st *Store) EnableDebug(debugEnabled bool) StoreInterface
EnableDebug - enables the debug option
func (*Store) QueueCount ¶ added in v0.4.0
func (store *Store) QueueCount(options QueueQueryInterface) (int64, error)
func (*Store) QueueCreate ¶ added in v0.0.6
func (store *Store) QueueCreate(queue QueueInterface) error
QueueCreate creates a queued task
func (*Store) QueueDelete ¶ added in v1.1.0
func (store *Store) QueueDelete(queue QueueInterface) error
func (*Store) QueueDeleteByID ¶ added in v0.6.0
func (*Store) QueueFail ¶ added in v0.0.6
func (st *Store) QueueFail(queue QueueInterface) error
QueueFail fails a queued task
func (*Store) QueueFindByID ¶ added in v0.0.6
func (store *Store) QueueFindByID(id string) (QueueInterface, error)
QueueFindByID finds a Queue by ID
func (*Store) QueueFindNextQueuedTask ¶ added in v0.2.1
func (store *Store) QueueFindNextQueuedTask() (QueueInterface, error)
func (*Store) QueueFindRunning ¶ added in v0.2.1
func (store *Store) QueueFindRunning(limit int) []QueueInterface
func (*Store) QueueList ¶ added in v0.0.6
func (store *Store) QueueList(query QueueQueryInterface) ([]QueueInterface, error)
func (*Store) QueueProcessNext ¶ added in v0.2.2
func (*Store) QueueRunGoroutine ¶ added in v0.2.3
QueueRunGoroutine goroutine to run the queue
Example: go myTaskStore.QueueRunGoroutine(10, 2)
Params: - processSeconds int - time to wait until processing the next task (i.e. 10s) - unstuckMinutes int - time to wait before mark running tasks as failed
func (*Store) QueueSoftDelete ¶ added in v1.1.0
func (store *Store) QueueSoftDelete(queue QueueInterface) error
func (*Store) QueueSoftDeleteByID ¶ added in v0.5.0
func (*Store) QueueSuccess ¶ added in v0.0.6
func (st *Store) QueueSuccess(queue QueueInterface) error
QueueSuccess completes a queued task successfully
func (*Store) QueueUnstuck ¶ added in v0.2.1
QueueUnstuck clears the queue of tasks running for more than the specified wait time as most probably these have abnormally exited (panicked) and stop the rest of the queue from being processed
The tasks are marked as failed. However, if they are still running in the background and they are successfully completed, they will be marked as success
================================================================= Business Logic 1. Checks is there are running tasks in progress 2. If running for more than the specified wait minutes mark as failed =================================================================
func (*Store) QueueUpdate ¶ added in v0.0.6
func (store *Store) QueueUpdate(queue QueueInterface) error
QueueUpdate creates a Queue
func (*Store) QueuedTaskForceFail ¶ added in v0.2.1
func (store *Store) QueuedTaskForceFail(queuedTask QueueInterface, waitMinutes int) error
func (*Store) QueuedTaskProcess ¶ added in v0.0.7
func (store *Store) QueuedTaskProcess(queuedTask QueueInterface) (bool, error)
func (*Store) SqlCreateQueueTable ¶ added in v0.0.6
SqlCreateQueueTable returns a SQL string for creating the Queue table
func (*Store) SqlCreateTaskTable ¶
SqlCreateTaskTable returns a SQL string for creating the Task table
func (*Store) TaskCount ¶ added in v1.1.0
func (store *Store) TaskCount(options TaskQueryInterface) (int64, error)
func (*Store) TaskCreate ¶
func (store *Store) TaskCreate(task TaskInterface) error
func (*Store) TaskDelete ¶ added in v1.1.0
func (store *Store) TaskDelete(task TaskInterface) error
func (*Store) TaskDeleteByID ¶ added in v1.1.0
func (*Store) TaskEnqueueByAlias ¶ added in v0.0.6
func (st *Store) TaskEnqueueByAlias(taskAlias string, parameters map[string]interface{}) (QueueInterface, error)
TaskEnqueueByAlias finds a task by its alias and appends it to the queue
func (*Store) TaskExecuteCli ¶ added in v0.3.0
TaskExecuteCli - CLI tool to find a task by its alias and execute its handler - alias "list" is reserved. it lists all the available commands
func (*Store) TaskFindByAlias ¶ added in v0.0.6
func (store *Store) TaskFindByAlias(alias string) (task TaskInterface, err error)
func (*Store) TaskFindByID ¶
func (store *Store) TaskFindByID(id string) (task TaskInterface, err error)
func (*Store) TaskHandlerAdd ¶ added in v0.0.7
func (store *Store) TaskHandlerAdd(taskHandler TaskHandlerInterface, createIfMissing bool) error
func (*Store) TaskHandlerList ¶ added in v0.0.8
func (store *Store) TaskHandlerList() []TaskHandlerInterface
func (*Store) TaskList ¶
func (store *Store) TaskList(query TaskQueryInterface) ([]TaskInterface, error)
func (*Store) TaskSoftDelete ¶ added in v1.1.0
func (store *Store) TaskSoftDelete(task TaskInterface) error
func (*Store) TaskSoftDeleteByID ¶ added in v1.1.0
func (*Store) TaskUpdate ¶
func (store *Store) TaskUpdate(task TaskInterface) error
type StoreInterface ¶ added in v1.1.0
type StoreInterface interface {
AutoMigrate() error
EnableDebug(debug bool) StoreInterface
QueueCount(options QueueQueryInterface) (int64, error)
QueueCreate(Queue QueueInterface) error
QueueDelete(Queue QueueInterface) error
QueueDeleteByID(id string) error
QueueFindByID(QueueID string) (QueueInterface, error)
QueueList(query QueueQueryInterface) ([]QueueInterface, error)
QueueSoftDelete(Queue QueueInterface) error
QueueSoftDeleteByID(id string) error
QueueUpdate(Queue QueueInterface) error
QueueRunGoroutine(processSeconds int, unstuckMinutes int)
QueuedTaskProcess(queuedTask QueueInterface) (bool, error)
TaskEnqueueByAlias(alias string, parameters map[string]interface{}) (QueueInterface, error)
TaskExecuteCli(alias string, args []string) bool
TaskCount(options TaskQueryInterface) (int64, error)
TaskCreate(Task TaskInterface) error
TaskDelete(Task TaskInterface) error
TaskDeleteByID(id string) error
TaskFindByAlias(alias string) (TaskInterface, error)
TaskFindByID(id string) (TaskInterface, error)
TaskList(options TaskQueryInterface) ([]TaskInterface, error)
TaskSoftDelete(Task TaskInterface) error
TaskSoftDeleteByID(id string) error
TaskUpdate(Task TaskInterface) error
TaskHandlerList() []TaskHandlerInterface
TaskHandlerAdd(taskHandler TaskHandlerInterface, createIfMissing bool) error
}
type TaskHandlerBase ¶ added in v0.0.10
type TaskHandlerBase struct {
// contains filtered or unexported fields
}
func (*TaskHandlerBase) ErrorMessage ¶ added in v0.0.10
func (handler *TaskHandlerBase) ErrorMessage() string
func (*TaskHandlerBase) GetParam ¶ added in v0.0.10
func (handler *TaskHandlerBase) GetParam(paramName string) string
func (*TaskHandlerBase) GetParamArray ¶ added in v0.0.10
func (handler *TaskHandlerBase) GetParamArray(paramName string) []string
func (*TaskHandlerBase) HasQueuedTask ¶ added in v0.0.10
func (handler *TaskHandlerBase) HasQueuedTask() bool
func (*TaskHandlerBase) InfoMessage ¶ added in v0.0.10
func (handler *TaskHandlerBase) InfoMessage() string
func (*TaskHandlerBase) LogError ¶ added in v0.0.10
func (handler *TaskHandlerBase) LogError(message string)
func (*TaskHandlerBase) LogInfo ¶ added in v0.0.10
func (handler *TaskHandlerBase) LogInfo(message string)
func (*TaskHandlerBase) LogSuccess ¶ added in v0.0.10
func (handler *TaskHandlerBase) LogSuccess(message string)
func (*TaskHandlerBase) Options ¶ added in v0.2.0
func (handler *TaskHandlerBase) Options() map[string]string
func (*TaskHandlerBase) QueuedTask ¶ added in v0.0.10
func (handler *TaskHandlerBase) QueuedTask() QueueInterface
func (*TaskHandlerBase) SetOptions ¶ added in v0.2.0
func (handler *TaskHandlerBase) SetOptions(options map[string]string)
func (*TaskHandlerBase) SetQueuedTask ¶ added in v0.2.0
func (handler *TaskHandlerBase) SetQueuedTask(queuedTask QueueInterface)
func (*TaskHandlerBase) SuccessMessage ¶ added in v0.0.10
func (handler *TaskHandlerBase) SuccessMessage() string
type TaskHandlerInterface ¶ added in v0.0.7
type TaskInterface ¶ added in v1.1.0
type TaskInterface interface {
Data() map[string]string
DataChanged() map[string]string
MarkAsNotDirty()
IsActive() bool
IsCanceled() bool
IsSoftDeleted() bool
Alias() string
SetAlias(alias string) TaskInterface
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) TaskInterface
Description() string
SetDescription(description string) TaskInterface
ID() string
SetID(id string) TaskInterface
Memo() string
SetMemo(memo string) TaskInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(deletedAt string) TaskInterface
Status() string
SetStatus(status string) TaskInterface
Title() string
SetTitle(title string) TaskInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) TaskInterface
}
func NewTask ¶ added in v1.1.0
func NewTask() TaskInterface
func NewTaskFromExistingData ¶ added in v1.1.0
func NewTaskFromExistingData(data map[string]string) TaskInterface
type TaskQueryInterface ¶ added in v1.1.0
type TaskQueryInterface interface {
Validate() error
Columns() []string
SetColumns(columns []string) TaskQueryInterface
HasCountOnly() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) TaskQueryInterface
HasAlias() bool
Alias() string
SetAlias(alias string) TaskQueryInterface
HasCreatedAtGte() bool
CreatedAtGte() string
SetCreatedAtGte(createdAtGte string) TaskQueryInterface
HasCreatedAtLte() bool
CreatedAtLte() string
SetCreatedAtLte(createdAtLte string) TaskQueryInterface
HasID() bool
ID() string
SetID(id string) TaskQueryInterface
HasIDIn() bool
IDIn() []string
SetIDIn(idIn []string) TaskQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) TaskQueryInterface
HasOffset() bool
Offset() int
SetOffset(offset int) TaskQueryInterface
HasSortOrder() bool
SortOrder() string
SetSortOrder(sortOrder string) TaskQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) TaskQueryInterface
HasSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(withDeleted bool) TaskQueryInterface
HasStatus() bool
Status() string
SetStatus(status string) TaskQueryInterface
HasStatusIn() bool
StatusIn() []string
SetStatusIn(statusIn []string) TaskQueryInterface
}
func TaskQuery ¶ added in v1.1.0
func TaskQuery() TaskQueryInterface