Documentation
¶
Index ¶
- func ClearSchedulers()
- func RegisterSchedulerConstructor(taskType string, constructor Constructor, opts ...RegisterOption)
- func RegisterSubtaskExectorConstructor(taskType string, constructor SubtaskExecutorConstructor, ...)
- type Constructor
- type InternalScheduler
- type InternalSchedulerImpl
- type Manager
- type ManagerBuilder
- type MockInternalScheduler
- type MockMinimalTask
- type MockPool
- type MockScheduler
- func (m *MockScheduler) CleanupSubtaskExecEnv(ctx context.Context) error
- func (m *MockScheduler) InitSubtaskExecEnv(ctx context.Context) error
- func (m *MockScheduler) OnSubtaskFinished(ctx context.Context, subtask []byte) error
- func (m *MockScheduler) Rollback(ctx context.Context) error
- func (m *MockScheduler) SplitSubtask(ctx context.Context, subtask []byte) ([]proto.MinimalTask, error)
- type MockSubtaskExecutor
- type MockTaskTable
- func (t *MockTaskTable) GetGlobalTaskByID(id int64) (*proto.Task, error)
- func (t *MockTaskTable) GetGlobalTasksInStates(states ...interface{}) ([]*proto.Task, error)
- func (t *MockTaskTable) GetSubtaskInStates(instanceID string, taskID int64, states ...interface{}) (*proto.Subtask, error)
- func (t *MockTaskTable) HasSubtasksInStates(instanceID string, taskID int64, states ...interface{}) (bool, error)
- func (t *MockTaskTable) UpdateSubtaskStateAndError(id int64, state string, _ string) error
- type Pool
- type RegisterOption
- type Scheduler
- type SubtaskExecutor
- type SubtaskExecutorConstructor
- type SubtaskExecutorRegisterOption
- type TaskTable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterSchedulerConstructor ¶
func RegisterSchedulerConstructor(taskType string, constructor Constructor, opts ...RegisterOption)
RegisterSchedulerConstructor registers the constructor of Scheduler.
func RegisterSubtaskExectorConstructor ¶
func RegisterSubtaskExectorConstructor(taskType string, constructor SubtaskExecutorConstructor, opts ...SubtaskExecutorRegisterOption)
RegisterSubtaskExectorConstructor registers the constructor of SubtaskExecutor.
Types ¶
type Constructor ¶
Constructor is the constructor of Scheduler.
type InternalScheduler ¶
type InternalScheduler interface { Start() Stop() Run(context.Context, *proto.Task) error Rollback(context.Context, *proto.Task) error }
InternalScheduler defines the interface of an internal scheduler.
func NewInternalScheduler ¶
func NewInternalScheduler(ctx context.Context, id string, taskID int64, taskTable TaskTable, pool Pool) InternalScheduler
NewInternalScheduler creates a new InternalScheduler.
type InternalSchedulerImpl ¶
type InternalSchedulerImpl struct {
// contains filtered or unexported fields
}
InternalSchedulerImpl is the implementation of InternalScheduler.
func (*InternalSchedulerImpl) Start ¶
func (*InternalSchedulerImpl) Start()
Start starts the scheduler.
func (*InternalSchedulerImpl) Stop ¶
func (s *InternalSchedulerImpl) Stop()
Stop stops the scheduler.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager monitors the global task table and manages the schedulers.
type ManagerBuilder ¶
type ManagerBuilder struct {
// contains filtered or unexported fields
}
ManagerBuilder is used to build a Manager.
func NewManagerBuilder ¶
func NewManagerBuilder() *ManagerBuilder
NewManagerBuilder creates a new ManagerBuilder.
func (*ManagerBuilder) BuildManager ¶
func (b *ManagerBuilder) BuildManager(ctx context.Context, id string, taskTable TaskTable) (*Manager, error)
BuildManager builds a Manager.
type MockInternalScheduler ¶
MockInternalScheduler is a mock of InternalScheduler.
func (*MockInternalScheduler) Start ¶
func (m *MockInternalScheduler) Start()
Start implements InternalScheduler.Start.
func (*MockInternalScheduler) Stop ¶
func (m *MockInternalScheduler) Stop()
Stop implements InternalScheduler.Stop.
type MockMinimalTask ¶
type MockMinimalTask struct{}
MockMinimalTask is a mock of MinimalTask.
func (MockMinimalTask) IsMinimalTask ¶
func (MockMinimalTask) IsMinimalTask()
IsMinimalTask implements MinimalTask.IsMinimalTask.
type MockPool ¶
MockPool is a mock of Pool.
func (*MockPool) ReleaseAndWait ¶
func (m *MockPool) ReleaseAndWait()
ReleaseAndWait implements Pool.ReleaseAndWait.
func (*MockPool) RunWithConcurrency ¶
RunWithConcurrency implements Pool.RunWithConcurrency.
type MockScheduler ¶
MockScheduler is a mock of Scheduler.
func (*MockScheduler) CleanupSubtaskExecEnv ¶
func (m *MockScheduler) CleanupSubtaskExecEnv(ctx context.Context) error
CleanupSubtaskExecEnv implements Scheduler.CleanupSubtaskExecEnv.
func (*MockScheduler) InitSubtaskExecEnv ¶
func (m *MockScheduler) InitSubtaskExecEnv(ctx context.Context) error
InitSubtaskExecEnv implements Scheduler.InitSubtaskExecEnv.
func (*MockScheduler) OnSubtaskFinished ¶
func (m *MockScheduler) OnSubtaskFinished(ctx context.Context, subtask []byte) error
OnSubtaskFinished implements Scheduler.OnSubtaskFinished.
func (*MockScheduler) Rollback ¶
func (m *MockScheduler) Rollback(ctx context.Context) error
Rollback implements Scheduler.Rollback.
func (*MockScheduler) SplitSubtask ¶
func (m *MockScheduler) SplitSubtask(ctx context.Context, subtask []byte) ([]proto.MinimalTask, error)
SplitSubtask implements Scheduler.SplitSubtask.
type MockSubtaskExecutor ¶
MockSubtaskExecutor is a mock of SubtaskExecutor.
type MockTaskTable ¶
MockTaskTable is a mock of TaskTable. TODO(gmhdbjd): move this to storage package.
func (*MockTaskTable) GetGlobalTaskByID ¶
func (t *MockTaskTable) GetGlobalTaskByID(id int64) (*proto.Task, error)
GetGlobalTaskByID implements TaskTable.GetTaskByID.
func (*MockTaskTable) GetGlobalTasksInStates ¶
func (t *MockTaskTable) GetGlobalTasksInStates(states ...interface{}) ([]*proto.Task, error)
GetGlobalTasksInStates implements TaskTable.GetTasksInStates.
func (*MockTaskTable) GetSubtaskInStates ¶
func (t *MockTaskTable) GetSubtaskInStates(instanceID string, taskID int64, states ...interface{}) (*proto.Subtask, error)
GetSubtaskInStates implements SubtaskTable.GetSubtaskInStates.
func (*MockTaskTable) HasSubtasksInStates ¶
func (t *MockTaskTable) HasSubtasksInStates(instanceID string, taskID int64, states ...interface{}) (bool, error)
HasSubtasksInStates implements SubtaskTable.HasSubtasksInStates.
func (*MockTaskTable) UpdateSubtaskStateAndError ¶
func (t *MockTaskTable) UpdateSubtaskStateAndError(id int64, state string, _ string) error
UpdateSubtaskStateAndError implements SubtaskTable.UpdateSubtaskState.
type Pool ¶
type Pool interface { Run(func()) error RunWithConcurrency(chan func(), uint32) error ReleaseAndWait() }
Pool defines the interface of a pool.
type RegisterOption ¶
type RegisterOption func(opts *schedulerRegisterOptions)
RegisterOption is the register option of Scheduler.
type Scheduler ¶
type Scheduler interface { // InitSubtaskExecEnv is used to initialize the environment for the subtask executor. InitSubtaskExecEnv(context.Context) error // SplitSubtask is used to split the subtask into multiple minimal tasks. SplitSubtask(ctx context.Context, subtask []byte) ([]proto.MinimalTask, error) // CleanupSubtaskExecEnv is used to clean up the environment for the subtask executor. CleanupSubtaskExecEnv(context.Context) error // OnSubtaskFinished is used to handle the subtask when it is finished. OnSubtaskFinished(ctx context.Context, subtask []byte) error // Rollback is used to rollback all subtasks. Rollback(context.Context) error }
Scheduler defines the interface of a scheduler. User should implement this interface to define their own scheduler.
type SubtaskExecutor ¶
SubtaskExecutor defines the interface of a subtask executor. User should implement this interface to define their own subtask executor.
type SubtaskExecutorConstructor ¶
type SubtaskExecutorConstructor func(minimalTask proto.MinimalTask, step int64) (SubtaskExecutor, error)
SubtaskExecutorConstructor is the constructor of SubtaskExecutor.
type SubtaskExecutorRegisterOption ¶
type SubtaskExecutorRegisterOption func(opts *subtaskExecutorRegisterOptions)
SubtaskExecutorRegisterOption is the register option of SubtaskExecutor.
type TaskTable ¶
type TaskTable interface { GetGlobalTasksInStates(states ...interface{}) (task []*proto.Task, err error) GetGlobalTaskByID(taskID int64) (task *proto.Task, err error) GetSubtaskInStates(instanceID string, taskID int64, states ...interface{}) (*proto.Subtask, error) UpdateSubtaskStateAndError(id int64, state string, err string) error HasSubtasksInStates(instanceID string, taskID int64, states ...interface{}) (bool, error) }
TaskTable defines the interface to access task table.