Documentation ¶
Index ¶
- Constants
- Variables
- func AsWorker(w any, options ...worker.WorkerExecutionOption) fx.Option
- func GetReturnType(target any) string
- func GetType(target any) string
- func NewFxWorkerPool(p FxWorkerPoolParam) (*worker.WorkerPool, error)
- type FxWorkerModuleInfo
- type FxWorkerPoolParam
- type FxWorkerRegistryParam
- type WorkerDefinition
- type WorkerRegistry
Constants ¶
const ModuleName = "worker"
ModuleName is the module name.
Variables ¶
var FxWorkerModule = fx.Module( ModuleName, fx.Provide( worker.NewDefaultWorkerPoolFactory, NewFxWorkerRegistry, NewFxWorkerPool, fx.Annotate( NewFxWorkerModuleInfo, fx.As(new(interface{})), fx.ResultTags(`group:"core-module-infos"`), ), ), )
FxWorkerModule is the Fx worker module.
Functions ¶
func AsWorker ¶
func AsWorker(w any, options ...worker.WorkerExecutionOption) fx.Option
AsWorker registers a worker.Worker into Fx, with an optional list of worker.WorkerExecutionOption.
func GetReturnType ¶
GetReturnType returns the return type of a target.
func NewFxWorkerPool ¶
func NewFxWorkerPool(p FxWorkerPoolParam) (*worker.WorkerPool, error)
NewFxWorkerPool returns a new worker.WorkerPool.
Types ¶
type FxWorkerModuleInfo ¶
type FxWorkerModuleInfo struct {
// contains filtered or unexported fields
}
FxWorkerModuleInfo is a module info collector for fxcore.
func NewFxWorkerModuleInfo ¶
func NewFxWorkerModuleInfo(pool *worker.WorkerPool) *FxWorkerModuleInfo
NewFxWorkerModuleInfo returns a new FxWorkerModuleInfo.
func (*FxWorkerModuleInfo) Data ¶
func (i *FxWorkerModuleInfo) Data() map[string]interface{}
Data return the data of the module info.
func (*FxWorkerModuleInfo) Name ¶
func (i *FxWorkerModuleInfo) Name() string
Name return the name of the module info.
type FxWorkerPoolParam ¶
type FxWorkerPoolParam struct { fx.In LifeCycle fx.Lifecycle Generator uuid.UuidGenerator TracerProvider oteltrace.TracerProvider Factory worker.WorkerPoolFactory Config *config.Config Registry *WorkerRegistry Logger *log.Logger MetricsRegistry *prometheus.Registry }
FxWorkerPoolParam allows injection of the required dependencies in NewFxWorkerPool.
type FxWorkerRegistryParam ¶
type FxWorkerRegistryParam struct { fx.In Workers []worker.Worker `group:"workers"` Definitions []WorkerDefinition `group:"workers-definitions"` }
FxWorkerRegistryParam allows injection of the required dependencies in NewFxWorkerRegistry.
type WorkerDefinition ¶
type WorkerDefinition interface { ReturnType() string Options() []worker.WorkerExecutionOption }
WorkerDefinition is the interface for workers definitions.
func NewWorkerDefinition ¶
func NewWorkerDefinition(returnType string, options ...worker.WorkerExecutionOption) WorkerDefinition
NewWorkerDefinition returns a new WorkerDefinition.
type WorkerRegistry ¶
type WorkerRegistry struct {
// contains filtered or unexported fields
}
WorkerRegistry is the registry collecting workers and their definitions.
func NewFxWorkerRegistry ¶
func NewFxWorkerRegistry(p FxWorkerRegistryParam) *WorkerRegistry
NewFxWorkerRegistry returns as new WorkerRegistry.
func (*WorkerRegistry) ResolveWorkersRegistrations ¶
func (r *WorkerRegistry) ResolveWorkersRegistrations() ([]*worker.WorkerRegistration, error)
ResolveWorkersRegistrations resolves a list of worker.WorkerRegistration from their definitions.