Documentation
¶
Index ¶
- Constants
- func ExecuteTask(task TaskExecutor, instance TaskInstance, c chan<- ExecuteTaskErr)
- func NewTaskId() string
- func ReadTaskData[T any](jsonData []byte) (T, error)
- func UnwrapChannel(c chan ExecuteTaskErr) []error
- type ExecuteTaskErr
- type MasterQ
- type Path
- func (pth Path) Copy() Path
- func (pth Path) Exists() bool
- func (pth Path) HasError() bool
- func (pth Path) IsDir() bool
- func (pth Path) IsFile() bool
- func (pth Path) Join(paths ...string) Path
- func (pth Path) MkDir() error
- func (pth Path) MkDirs() error
- func (pth Path) ModTime() (time.Time, error)
- func (pth Path) Name() string
- func (pth Path) Parent() Path
- func (pth Path) Read() ([]byte, error)
- func (pth Path) ReadDir() ([]Path, error)
- func (pth Path) Remove() error
- func (pth Path) Resolve() Path
- func (pth Path) SetErr(err error) Path
- func (pth Path) SetPath(path string) Path
- func (pth Path) Stat() (os.FileInfo, error)
- func (pth Path) Stem() string
- func (pth Path) String() string
- func (pth Path) Suffix() string
- func (pth Path) Write(data []byte) error
- type TaskErrors
- type TaskExecutionError
- type TaskExecutor
- type TaskHandler
- type TaskInstance
- func (tq TaskInstance) ApplyLock() error
- func (tq TaskInstance) ErrorFile() Path
- func (tq TaskInstance) Exists() bool
- func (tq TaskInstance) GetErrors() (TaskErrors, error)
- func (tq TaskInstance) HasError() bool
- func (ti TaskInstance) Initialize() error
- func (tq TaskInstance) IsLocked() bool
- func (tq TaskInstance) IsReady() bool
- func (tq TaskInstance) LockFile() Path
- func (ti TaskInstance) ReleaseLock() error
- func (tq TaskInstance) Remove() error
- func (tq TaskInstance) String() string
- func (tq TaskInstance) TaskDir() Path
- func (tq TaskInstance) TaskFile() Path
- func (tq TaskInstance) WriteError(msg string, traceback string) error
- type TaskQueue
- func (tq TaskQueue) CreateTaskInstance() TaskInstance
- func (tq TaskQueue) GetTaskInstances() ([]TaskInstance, error)
- func (tq TaskQueue) Initialize() error
- func (tq TaskQueue) IterTaskInstances(handler TaskHandler) error
- func (tq TaskQueue) LoadTaskInstance(taskDir Path) TaskInstance
- func (tq TaskQueue) Run(opt any) (TaskInstance, error)
- func (tq TaskQueue) Send(opt any) (TaskInstance, error)
- func (tq TaskQueue) Task() TaskExecutor
Constants ¶
const FOO = 100
Variables ¶
This section is empty.
Functions ¶
func ExecuteTask ¶ added in v0.2.0
func ExecuteTask(task TaskExecutor, instance TaskInstance, c chan<- ExecuteTaskErr)
func ReadTaskData ¶ added in v0.2.0
func UnwrapChannel ¶ added in v0.2.0
func UnwrapChannel(c chan ExecuteTaskErr) []error
Types ¶
type ExecuteTaskErr ¶ added in v0.2.0
func NewExecutTaskErr ¶ added in v0.2.0
func NewExecutTaskErr(name string, err error) ExecuteTaskErr
type MasterQ ¶ added in v0.2.0
type MasterQ struct {
// contains filtered or unexported fields
}
MasterQ has two tasks: first, it's a repository of registered task instances; second, it's the primary interface to the file system saving and retrieving of task execution instances.
func New ¶ added in v0.2.0
New will retrieve the queue if the path already exists, or else create a new queue and register it. **rootDir** must be a valid path.
func (*MasterQ) Register ¶ added in v0.2.0
func (q *MasterQ) Register(task TaskExecutor, name string) error
Register the given instance of the task interface. The task is registered by the derrived name.
func (*MasterQ) RunAllTasks ¶ added in v0.2.0
type TaskErrors ¶ added in v0.2.0
type TaskErrors struct {
Errors []TaskExecutionError `json:"errors"`
}
func (*TaskErrors) Add ¶ added in v0.2.0
func (te *TaskErrors) Add(err TaskExecutionError)
func (*TaskErrors) Count ¶ added in v0.2.0
func (te *TaskErrors) Count() int
func (*TaskErrors) ReadFrom ¶ added in v0.2.0
func (te *TaskErrors) ReadFrom(errFile Path) error
func (*TaskErrors) WriteTo ¶ added in v0.2.0
func (te *TaskErrors) WriteTo(errFile Path) error
type TaskExecutionError ¶ added in v0.2.0
type TaskExecutor ¶ added in v0.2.0
TaskExecutor interface is what must be implemented for loq to register and execute a defined task.
type TaskHandler ¶ added in v0.2.0
type TaskHandler func(instance TaskInstance)
type TaskInstance ¶ added in v0.2.0
type TaskInstance struct {
// contains filtered or unexported fields
}
TaskInstance represents a unique task and is represented on a file system as a directory that contains at least a single json file with that task's execution arguments. The task directory can also contain a lock file and/or an error file.
func (TaskInstance) ApplyLock ¶ added in v0.2.0
func (tq TaskInstance) ApplyLock() error
ApplyLock create a .lock file in the task folder.
func (TaskInstance) ErrorFile ¶ added in v0.2.0
func (tq TaskInstance) ErrorFile() Path
ErrorFile returns the Path object of the task error file.
func (TaskInstance) Exists ¶ added in v0.2.0
func (tq TaskInstance) Exists() bool
Exists is true if the task folder exists.
func (TaskInstance) GetErrors ¶ added in v0.2.0
func (tq TaskInstance) GetErrors() (TaskErrors, error)
func (TaskInstance) HasError ¶ added in v0.2.0
func (tq TaskInstance) HasError() bool
HasError is true if the task folder contains a .error ffile.
func (TaskInstance) Initialize ¶ added in v0.2.0
func (ti TaskInstance) Initialize() error
Initialize creates the task directory and applies a lock.
func (TaskInstance) IsLocked ¶ added in v0.2.0
func (tq TaskInstance) IsLocked() bool
IsLocked is true if the task folder contains a .lock file.
func (TaskInstance) IsReady ¶ added in v0.2.0
func (tq TaskInstance) IsReady() bool
IsReady is true if the task folder has a task file and is not locked and has no errors.
func (TaskInstance) LockFile ¶ added in v0.2.0
func (tq TaskInstance) LockFile() Path
LockFile returns the Path object of the task lock file.
func (TaskInstance) ReleaseLock ¶ added in v0.2.0
func (ti TaskInstance) ReleaseLock() error
ReleaseLock deletes the .lock file in the task folder.
func (TaskInstance) Remove ¶ added in v0.2.0
func (tq TaskInstance) Remove() error
Remove deletes the task folder and all it's files.
func (TaskInstance) String ¶ added in v0.2.0
func (tq TaskInstance) String() string
func (TaskInstance) TaskDir ¶ added in v0.2.0
func (tq TaskInstance) TaskDir() Path
TaskDir returns the Path object for the task dir.
func (TaskInstance) TaskFile ¶ added in v0.2.0
func (tq TaskInstance) TaskFile() Path
TaskFile returns the Path object fof the task file.
func (TaskInstance) WriteError ¶ added in v0.2.0
func (tq TaskInstance) WriteError(msg string, traceback string) error
WriteError writes an error message to the tasks error file.
type TaskQueue ¶
type TaskQueue struct {
// contains filtered or unexported fields
}
func NewTaskQueue ¶
func NewTaskQueue(master Path, name string, task TaskExecutor) (TaskQueue, error)
func (TaskQueue) CreateTaskInstance ¶ added in v0.2.0
func (tq TaskQueue) CreateTaskInstance() TaskInstance
func (TaskQueue) GetTaskInstances ¶ added in v0.2.0
func (tq TaskQueue) GetTaskInstances() ([]TaskInstance, error)
func (TaskQueue) Initialize ¶ added in v0.2.0
func (TaskQueue) IterTaskInstances ¶ added in v0.2.0
func (tq TaskQueue) IterTaskInstances(handler TaskHandler) error
func (TaskQueue) LoadTaskInstance ¶ added in v0.2.0
func (tq TaskQueue) LoadTaskInstance(taskDir Path) TaskInstance
func (TaskQueue) Run ¶ added in v0.2.0
func (tq TaskQueue) Run(opt any) (TaskInstance, error)
Run creates a new TaskInstance on disk with the given task arguments, and then immediately executes.
func (TaskQueue) Send ¶
func (tq TaskQueue) Send(opt any) (TaskInstance, error)
Send creates a new TaskInstance on disk with the given task arguments.
func (TaskQueue) Task ¶ added in v0.2.0
func (tq TaskQueue) Task() TaskExecutor