Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
type Component interface {
StartTask(*component.TaskConfig)
FromRequestContext(context.Context) context.Context
}
Component contains a minimal component.Component definition.
type Config ¶
type Config struct {
Component
context.Context // The base context of the pool.
Name string // The name of the pool.
CreateHandler HandlerFactory // The function that creates handlers.
MinWorkers int // The minimum number of workers in the pool.
MaxWorkers int // The maximum number of workers in the pool.
QueueSize int // The size of the work queue.
WorkerIdleTimeout time.Duration // The maximum amount of time a worker will stay idle before closing.
}
Config is the configuration of the worker pool.
type HandlerFactory ¶
HandlerFactory is a function that creates a Handler.
func HandlerFactoryFromUplinkHandler ¶
func HandlerFactoryFromUplinkHandler(handler func(context.Context, *ttnpb.ApplicationUp) error) HandlerFactory
HandlerFactoryFromUplinkHandler converts a static uplink handler to a HandlerFactory.
func StaticHandlerFactory ¶
func StaticHandlerFactory(f Handler) HandlerFactory
StaticHandlerFactory creates a HandlerFactory that always returns the same handler.
type WorkerPool ¶
type WorkerPool interface {
// Publish publishes an item to the worker pool to be processed.
// Publish may spawn a worker in order to fullfil the work load.
// Publish does not block.
Publish(ctx context.Context, item interface{}) error
}
WorkerPool is a dynamic pool of workers to which work items can be published. The workers are created on demand and live as long as work is available.
func NewWorkerPool ¶
func NewWorkerPool(cfg Config) (WorkerPool, error)
NewWorkerPool creates a new WorkerPool with the provided configuration.
Click to show internal directories.
Click to hide internal directories.