Documentation ¶
Index ¶
- type Registry
- type SimpleWorkerFactory
- func (f *SimpleWorkerFactory[T, C]) DeserializeConfig(configBytes []byte) (WorkerConfig, error)
- func (f *SimpleWorkerFactory[T, C]) IsRetryableError(err error) bool
- func (f *SimpleWorkerFactory[T, C]) NewWorkerImpl(ctx *dcontext.Context, workerID frameModel.WorkerID, ...) (framework.WorkerImpl, error)
- type WorkerConfig
- type WorkerConstructor
- type WorkerFactory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry interface { MustRegisterWorkerType(tp frameModel.WorkerType, factory WorkerFactory) RegisterWorkerType(tp frameModel.WorkerType, factory WorkerFactory) (ok bool) CreateWorker( ctx *dcontext.Context, tp framework.WorkerType, workerID frameModel.WorkerID, masterID frameModel.MasterID, config []byte, epoch frameModel.Epoch, ) (framework.Worker, error) // IsRetryableError returns whether error is treated as retryable from the // perspective of business logic. IsRetryableError(err error, tp framework.WorkerType) (bool, error) }
Registry defines an interface to worker as worker register bridge. Business can register any worker or job master implementation into a registry
func GlobalWorkerRegistry ¶
func GlobalWorkerRegistry() Registry
GlobalWorkerRegistry returns the global worker registry
type SimpleWorkerFactory ¶
type SimpleWorkerFactory[T framework.WorkerImpl, C any] struct { // contains filtered or unexported fields }
SimpleWorkerFactory is a WorkerFactory with built-in JSON codec for WorkerConfig.
func NewSimpleWorkerFactory ¶
func NewSimpleWorkerFactory[T framework.WorkerImpl, Config any]( constructor WorkerConstructor[T, Config], ) *SimpleWorkerFactory[T, Config]
NewSimpleWorkerFactory creates a new WorkerFactory.
func (*SimpleWorkerFactory[T, C]) DeserializeConfig ¶
func (f *SimpleWorkerFactory[T, C]) DeserializeConfig(configBytes []byte) (WorkerConfig, error)
DeserializeConfig implements WorkerFactory.DeserializeConfig
func (*SimpleWorkerFactory[T, C]) IsRetryableError ¶
func (f *SimpleWorkerFactory[T, C]) IsRetryableError(err error) bool
IsRetryableError implements WorkerFactory.IsRetryableError
func (*SimpleWorkerFactory[T, C]) NewWorkerImpl ¶
func (f *SimpleWorkerFactory[T, C]) NewWorkerImpl( ctx *dcontext.Context, workerID frameModel.WorkerID, masterID frameModel.MasterID, config WorkerConfig, ) (framework.WorkerImpl, error)
NewWorkerImpl implements WorkerFactory.NewWorkerImpl
type WorkerConfig ¶
type WorkerConfig = framework.WorkerConfig
WorkerConfig alias to framework.WorkerConfig
type WorkerConstructor ¶
type WorkerConstructor[T framework.WorkerImpl, C any] func( ctx *dcontext.Context, id frameModel.WorkerID, masterID frameModel.MasterID, config C, ) T
WorkerConstructor alias to the function that can construct a WorkerImpl
type WorkerFactory ¶
type WorkerFactory interface { // NewWorkerImpl return an implementation of the worker. its BaseWorker // or BaseJobMaster field can be left nil, framework will fill it in. NewWorkerImpl( ctx *dcontext.Context, workerID frameModel.WorkerID, masterID frameModel.MasterID, config WorkerConfig, ) (framework.WorkerImpl, error) DeserializeConfig(configBytes []byte) (WorkerConfig, error) // IsRetryableError passes in an error to business logic, and returns whether // job should be re-created or terminated permanently when meeting this error. IsRetryableError(err error) bool }
WorkerFactory is an interface that should be implemented by the author of WorkerImpl or JobMasterImpl (JobMaster is the worker of JobManager). It represents a constructor for a given type of worker.