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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
func NewQueue() QueueInterface
func NewQueueFromExistingData ¶
func NewQueueFromExistingData(data map[string]string) QueueInterface
type QueueQueryInterface ¶
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 ¶
func QueueQuery() QueueQueryInterface
type RecurrenceRule ¶
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 ¶
func NewRecurrenceRule() RecurrenceRule
type ScheduleDefinition ¶
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 ¶
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 ¶
func (store *Store) QueueCount(options QueueQueryInterface) (int64, error)
func (*Store) QueueCreate ¶
func (store *Store) QueueCreate(queue QueueInterface) error
QueueCreate creates a queued task
func (*Store) QueueDelete ¶
func (store *Store) QueueDelete(queue QueueInterface) error
func (*Store) QueueDeleteByID ¶
func (*Store) QueueFail ¶
func (st *Store) QueueFail(queue QueueInterface) error
QueueFail fails a queued task
func (*Store) QueueFindByID ¶
func (store *Store) QueueFindByID(id string) (QueueInterface, error)
QueueFindByID finds a Queue by ID
func (*Store) QueueFindNextQueuedTask ¶
func (store *Store) QueueFindNextQueuedTask() (QueueInterface, error)
func (*Store) QueueFindRunning ¶
func (store *Store) QueueFindRunning(limit int) []QueueInterface
func (*Store) QueueList ¶
func (store *Store) QueueList(query QueueQueryInterface) ([]QueueInterface, error)
func (*Store) QueueProcessNext ¶
func (*Store) QueueRunGoroutine ¶
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 ¶
func (store *Store) QueueSoftDelete(queue QueueInterface) error
func (*Store) QueueSoftDeleteByID ¶
func (*Store) QueueSuccess ¶
func (st *Store) QueueSuccess(queue QueueInterface) error
QueueSuccess completes a queued task successfully
func (*Store) QueueUnstuck ¶
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 ¶
func (store *Store) QueueUpdate(queue QueueInterface) error
QueueUpdate creates a Queue
func (*Store) QueuedTaskForceFail ¶
func (store *Store) QueuedTaskForceFail(queuedTask QueueInterface, waitMinutes int) error
func (*Store) QueuedTaskProcess ¶
func (store *Store) QueuedTaskProcess(queuedTask QueueInterface) (bool, error)
func (*Store) SqlCreateQueueTable ¶
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) TaskCreate ¶
func (store *Store) TaskCreate(task TaskInterface) error
func (*Store) TaskDelete ¶
func (store *Store) TaskDelete(task TaskInterface) error
func (*Store) TaskDeleteByID ¶
func (*Store) TaskEnqueueByAlias ¶
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 ¶
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 ¶
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 ¶
func (store *Store) TaskHandlerAdd(taskHandler TaskHandlerInterface, createIfMissing bool) error
func (*Store) TaskHandlerList ¶
func (store *Store) TaskHandlerList() []TaskHandlerInterface
func (*Store) TaskList ¶
func (store *Store) TaskList(query TaskQueryInterface) ([]TaskInterface, error)
func (*Store) TaskSoftDelete ¶
func (store *Store) TaskSoftDelete(task TaskInterface) error
func (*Store) TaskSoftDeleteByID ¶
func (*Store) TaskUpdate ¶
func (store *Store) TaskUpdate(task TaskInterface) error
type StoreInterface ¶
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 ¶
type TaskHandlerBase struct {
// contains filtered or unexported fields
}
func (*TaskHandlerBase) ErrorMessage ¶
func (handler *TaskHandlerBase) ErrorMessage() string
func (*TaskHandlerBase) GetParam ¶
func (handler *TaskHandlerBase) GetParam(paramName string) string
func (*TaskHandlerBase) GetParamArray ¶
func (handler *TaskHandlerBase) GetParamArray(paramName string) []string
func (*TaskHandlerBase) HasQueuedTask ¶
func (handler *TaskHandlerBase) HasQueuedTask() bool
func (*TaskHandlerBase) InfoMessage ¶
func (handler *TaskHandlerBase) InfoMessage() string
func (*TaskHandlerBase) LogError ¶
func (handler *TaskHandlerBase) LogError(message string)
func (*TaskHandlerBase) LogInfo ¶
func (handler *TaskHandlerBase) LogInfo(message string)
func (*TaskHandlerBase) LogSuccess ¶
func (handler *TaskHandlerBase) LogSuccess(message string)
func (*TaskHandlerBase) Options ¶
func (handler *TaskHandlerBase) Options() map[string]string
func (*TaskHandlerBase) QueuedTask ¶
func (handler *TaskHandlerBase) QueuedTask() QueueInterface
func (*TaskHandlerBase) SetOptions ¶
func (handler *TaskHandlerBase) SetOptions(options map[string]string)
func (*TaskHandlerBase) SetQueuedTask ¶
func (handler *TaskHandlerBase) SetQueuedTask(queuedTask QueueInterface)
func (*TaskHandlerBase) SuccessMessage ¶
func (handler *TaskHandlerBase) SuccessMessage() string
type TaskHandlerInterface ¶
type TaskInterface ¶
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 ¶
func NewTask() TaskInterface
func NewTaskFromExistingData ¶
func NewTaskFromExistingData(data map[string]string) TaskInterface
type TaskQueryInterface ¶
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 ¶
func TaskQuery() TaskQueryInterface