Documentation ¶
Index ¶
- Variables
- type BaseRequest
- type ExecutorResponse
- type Handler
- func (h *Handler) Close()
- func (h *Handler) CloseChan() <-chan struct{}
- func (h *Handler) KillTaskById(id string) (*HandlerResponse, error)
- func (h *Handler) KillTaskByType(taskType tasks.Task) (*HandlerResponse, error)
- func (h *Handler) ScheduleTask(task tasks.Task, id string) (*HandlerResponse, error)
- func (h *Handler) Start()
- type HandlerResponse
- type InternalTaskState
- type ManagerRequestInfo
- type ManagerResponseChannel
- type ManagerResponseInfo
- type TaskAction
- type TaskExecutor
- type TaskHandler
- type TaskManager
- type TaskResponse
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotScheduled = errors.New("scheduled task not found") ErrWrongParams = errors.New("wrong start/end height for the task") ErrTaskExpired = errors.New("the task is already expired") ErrTaskNotAllowMultipleExecutions = errors.New("a task of the same type is already scheduled and allowed multiple execution for this type is false") ErrTaskIsNil = errors.New("the task in the request is nil") ErrTaskTypeNotInRegistry = errors.New("the task type is not in registry") ErrTaskIdEmpty = errors.New("the task id is empty") ErrTaskKilledBeforeExecution = errors.New("the task killed by request before execution") ErrReceivedRequestClosedChan = errors.New("received a request on a closed channel") ErrReceivedResponseClosedChan = errors.New("received a taskResponse on a closed channel") )
Functions ¶
This section is empty.
Types ¶
type BaseRequest ¶
type BaseRequest struct { Id string `json:"id"` Name string `json:"name"` Start uint64 `json:"start"` End uint64 `json:"end"` AllowMultiExecution bool `json:"allowMultiExecution"` SubscribeOptions *transaction.SubscribeOptions `json:"subscribeOptions"` InternalState InternalTaskState `json:"internalState"` }
BaseRequest information needed to start managing a task request.
type ExecutorResponse ¶ added in v0.0.7
ExecutorResponse used inside executorResponseChan to store the task execution result.
type Handler ¶ added in v0.0.7
type Handler struct {
// contains filtered or unexported fields
}
func (*Handler) Close ¶ added in v0.0.7
func (h *Handler) Close()
Close the Handler and the subsequent pieces such as TaskManager.
func (*Handler) CloseChan ¶ added in v0.0.8
func (h *Handler) CloseChan() <-chan struct{}
CloseChan returns a channel that is closed when the Handler is shutting down.
func (*Handler) KillTaskById ¶ added in v0.0.7
func (h *Handler) KillTaskById(id string) (*HandlerResponse, error)
KillTaskById sends the KillById Task request to the TaskManager.
func (*Handler) KillTaskByType ¶ added in v0.0.7
func (h *Handler) KillTaskByType(taskType tasks.Task) (*HandlerResponse, error)
KillTaskByType sends the KillByType Task request to the TaskManager.
func (*Handler) ScheduleTask ¶ added in v0.0.7
ScheduleTask sends the Schedule Task request to the TaskManager.
type HandlerResponse ¶ added in v0.0.7
type HandlerResponse struct {
// contains filtered or unexported fields
}
HandlerResponse returned from the Handler to the external clients.
func (*HandlerResponse) GetResponseBlocking ¶ added in v0.0.7
func (r *HandlerResponse) GetResponseBlocking(ctx context.Context) error
GetResponseBlocking blocking function to get the execution status of a task. This function will block until the task is finished and the final result is returned.
func (*HandlerResponse) IsReady ¶ added in v0.0.7
func (r *HandlerResponse) IsReady() bool
IsReady to check if the response from the task is ready to share with Handler client.
type InternalTaskState ¶
type InternalTaskState int
InternalTaskState is an enumeration indicating the possible states of a task.
const ( NotStarted InternalTaskState = iota Running Killed )
func (InternalTaskState) String ¶
func (state InternalTaskState) String() string
type ManagerRequestInfo ¶ added in v0.0.7
type ManagerRequestInfo struct { BaseRequest Task tasks.Task // contains filtered or unexported fields }
ManagerRequestInfo used for controlling, recovering and managing a task request. It's a unified struct that contains the request TaskManager receives from the Handler, the data is used in order to manage the task and the response from the TaskExecutor.
type ManagerResponseChannel ¶ added in v0.0.7
type ManagerResponseChannel struct {
// contains filtered or unexported fields
}
ManagerResponseChannel is a non-blocking channel that can only be written and closed once. It's used for communication between TaskManager and Handler.
func NewManagerResponseChannel ¶ added in v0.0.7
func NewManagerResponseChannel() *ManagerResponseChannel
NewManagerResponseChannel creates ManagerResponseChannel.
type ManagerResponseInfo ¶ added in v0.0.7
type ManagerResponseInfo struct { ExecutorResponse HandlerResponse *HandlerResponse `json:"-"` ReceivedOnBlock uint64 `json:"receivedOnBlock"` }
ManagerResponseInfo used to cache the responses from the TaskExecutor and to the Handler.
type TaskAction ¶ added in v0.0.7
type TaskAction int
TaskAction is an enumeration indicating the actions that the scheduler can do with a task during a request:
const ( KillByType TaskAction = iota KillById Schedule )
The possible actions that the scheduler can do with a task during a request: * KillByType - To kill/prune all the tasks with the same type immediately * KillById - To kill/prune a task by id immediately * Schedule - To schedule a new task
func (TaskAction) String ¶ added in v0.0.7
func (action TaskAction) String() string
type TaskExecutor ¶ added in v0.0.7
type TaskExecutor struct { sync.RWMutex TxsBackup map[string]*types.Transaction `json:"transactionsBackup"` // contains filtered or unexported fields }
type TaskHandler ¶ added in v0.0.7
type TaskHandler interface { ScheduleTask(task tasks.Task, id string) (*HandlerResponse, error) KillTaskByType(task tasks.Task) (*HandlerResponse, error) KillTaskById(id string) (*HandlerResponse, error) Start() Close() CloseChan() <-chan struct{} }
TaskHandler to be implemented by the Handler that receives requests to schedule or kill a Task.
func NewTaskHandler ¶ added in v0.0.7
func NewTaskHandler(database *db.Database, eth layer1.Client, contracts layer1.AllSmartContracts, adminHandler monitorInterfaces.AdminHandler, txWatcher transaction.Watcher) (TaskHandler, error)
NewTaskHandler creates a new Handler instance.
type TaskManager ¶ added in v0.0.7
type TaskManager struct { Schedule map[string]ManagerRequestInfo `json:"schedule"` Responses map[string]ManagerResponseInfo `json:"responses"` LastHeightSeen uint64 `json:"lastHeightSeen"` // contains filtered or unexported fields }
func (*TaskManager) MarshalJSON ¶ added in v0.0.7
func (tm *TaskManager) MarshalJSON() ([]byte, error)
MarshalJSON implements the json.Marshaler interface.
func (*TaskManager) UnmarshalJSON ¶ added in v0.0.7
func (tm *TaskManager) UnmarshalJSON(raw []byte) error
UnmarshalJSON implements the json.Unmarshaler interface.