Documentation ¶
Overview ¶
Package manager implements the types.Manager interface used for creating and sharing resources across a Benthos service.
Index ¶
- func Spec() docs.FieldSpecs
- type APIReg
- type ErrResourceNotFound
- type OptFunc
- func OptSetAPIReg(r APIReg) OptFunc
- func OptSetBloblangEnvironment(env *bloblang.Environment) OptFunc
- func OptSetEnvironment(e *bundle.Environment) OptFunc
- func OptSetLogger(logger log.Modular) OptFunc
- func OptSetMetrics(stats *metrics.Namespaced) OptFunc
- func OptSetStreamHTTPNamespacing(enabled bool) OptFunc
- func OptSetStreamsMode(b bool) OptFunc
- func OptSetTracer(tracer trace.TracerProvider) OptFunc
- type ResourceConfig
- type Type
- func (t *Type) AccessCache(ctx context.Context, name string, fn func(cache.V1)) error
- func (t *Type) AccessInput(ctx context.Context, name string, fn func(input.Streamed)) error
- func (t *Type) AccessOutput(ctx context.Context, name string, fn func(output.Sync)) error
- func (t *Type) AccessProcessor(ctx context.Context, name string, fn func(processor.V1)) error
- func (t *Type) AccessRateLimit(ctx context.Context, name string, fn func(ratelimit.V1)) error
- func (t *Type) BloblEnvironment() *bloblang.Environment
- func (t *Type) Environment() *bundle.Environment
- func (t *Type) ForStream(id string) bundle.NewManagement
- func (t *Type) GetDocs(name string, ctype docs.Type) (docs.ComponentSpec, bool)
- func (t *Type) GetPipe(name string) (<-chan message.Transaction, error)
- func (t *Type) IntoPath(segments ...string) bundle.NewManagement
- func (t *Type) Label() string
- func (t *Type) Logger() log.Modular
- func (t *Type) Metrics() metrics.Type
- func (t *Type) NewBuffer(conf buffer.Config) (buffer.Streamed, error)
- func (t *Type) NewCache(conf cache.Config) (cache.V1, error)
- func (t *Type) NewInput(conf input.Config) (input.Streamed, error)
- func (t *Type) NewOutput(conf output.Config, pipelines ...processor.PipelineConstructorFunc) (output.Streamed, error)
- func (t *Type) NewProcessor(conf processor.Config) (processor.V1, error)
- func (t *Type) NewRateLimit(conf ratelimit.Config) (ratelimit.V1, error)
- func (t *Type) Path() []string
- func (t *Type) ProbeCache(name string) bool
- func (t *Type) ProbeInput(name string) bool
- func (t *Type) ProbeOutput(name string) bool
- func (t *Type) ProbeProcessor(name string) bool
- func (t *Type) ProbeRateLimit(name string) bool
- func (t *Type) RegisterEndpoint(apiPath, desc string, h http.HandlerFunc)
- func (t *Type) SetPipe(name string, tran <-chan message.Transaction)
- func (t *Type) StoreCache(ctx context.Context, name string, conf cache.Config) error
- func (t *Type) StoreInput(ctx context.Context, name string, conf input.Config) error
- func (t *Type) StoreOutput(ctx context.Context, name string, conf output.Config) error
- func (t *Type) StoreProcessor(ctx context.Context, name string, conf processor.Config) error
- func (t *Type) StoreRateLimit(ctx context.Context, name string, conf ratelimit.Config) error
- func (t *Type) Tracer() trace.TracerProvider
- func (t *Type) TriggerCloseNow()
- func (t *Type) TriggerStopConsuming()
- func (t *Type) UnsetPipe(name string, tran <-chan message.Transaction)
- func (t *Type) WaitForClose(ctx context.Context) error
- func (t *Type) WithAddedMetrics(m metrics.Type) bundle.NewManagement
- func (t *Type) WithMetricsMapping(m *metrics.Mapping) *Type
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIReg ¶
type APIReg interface {
RegisterEndpoint(path, desc string, h http.HandlerFunc)
}
APIReg is an interface representing an API builder.
type ErrResourceNotFound ¶
type ErrResourceNotFound string
ErrResourceNotFound represents an error where a named resource could not be accessed because it was not found by the manager.
func (ErrResourceNotFound) Error ¶
func (e ErrResourceNotFound) Error() string
Error implements the standard error interface.
type OptFunc ¶
type OptFunc func(*Type)
OptFunc is an opt setting for a manager type.
func OptSetAPIReg ¶ added in v4.3.0
OptSetAPIReg sets the multiplexer used by components of this manager for registering their own HTTP endpoints.
func OptSetBloblangEnvironment ¶
func OptSetBloblangEnvironment(env *bloblang.Environment) OptFunc
OptSetBloblangEnvironment determines the environment from which the manager parses bloblang functions and methods. This option is for internal use only.
func OptSetEnvironment ¶
func OptSetEnvironment(e *bundle.Environment) OptFunc
OptSetEnvironment determines the environment from which the manager initializes components and resources. This option is for internal use only.
func OptSetLogger ¶ added in v4.3.0
OptSetLogger sets the logger from which the manager emits log events for components.
func OptSetMetrics ¶ added in v4.3.0
func OptSetMetrics(stats *metrics.Namespaced) OptFunc
OptSetMetrics sets the metrics exporter from which the manager creates metrics for components.
func OptSetStreamHTTPNamespacing ¶ added in v4.4.0
OptSetStreamHTTPNamespacing determines whether HTTP endpoints registered from within a stream should be prefixed with the stream name.
func OptSetStreamsMode ¶ added in v4.1.0
OptSetStreamsMode marks the manager as being created for running streams mode resources. This ensures that a label "stream" is added to metrics.
func OptSetTracer ¶ added in v4.3.0
func OptSetTracer(tracer trace.TracerProvider) OptFunc
OptSetTracer sets the tracer provider from which the manager creates tracing spans.
type ResourceConfig ¶
type ResourceConfig struct { ResourceInputs []input.Config `json:"input_resources,omitempty" yaml:"input_resources,omitempty"` ResourceProcessors []processor.Config `json:"processor_resources,omitempty" yaml:"processor_resources,omitempty"` ResourceOutputs []output.Config `json:"output_resources,omitempty" yaml:"output_resources,omitempty"` ResourceCaches []cache.Config `json:"cache_resources,omitempty" yaml:"cache_resources,omitempty"` ResourceRateLimits []ratelimit.Config `json:"rate_limit_resources,omitempty" yaml:"rate_limit_resources,omitempty"` }
ResourceConfig contains fields for specifying resource components at the root of a Benthos config.
func NewResourceConfig ¶
func NewResourceConfig() ResourceConfig
NewResourceConfig creates a ResourceConfig with default values.
func (*ResourceConfig) AddFrom ¶
func (r *ResourceConfig) AddFrom(extra *ResourceConfig) error
AddFrom takes another Config and adds all of its resources to itself. If there are any resource name collisions an error is returned.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type is an implementation of types.Manager, which is expected by Benthos components that need to register service wide behaviours such as HTTP endpoints and event listeners, and obtain service wide shared resources such as caches and other resources.
func New ¶ added in v4.1.0
func New(conf ResourceConfig, opts ...OptFunc) (*Type, error)
New returns an instance of manager.Type, which can be shared amongst components and logical threads of a Benthos service.
func (*Type) AccessCache ¶
AccessCache attempts to access a cache resource by a unique identifier and executes a closure function with the cache as an argument. Returns an error if the cache does not exist (or is otherwise inaccessible).
During the execution of the provided closure it is guaranteed that the resource will not be closed or removed. However, it is possible for the resource to be accessed by any number of components in parallel.
func (*Type) AccessInput ¶
AccessInput attempts to access an input resource by a unique identifier and executes a closure function with the input as an argument. Returns an error if the input does not exist (or is otherwise inaccessible).
During the execution of the provided closure it is guaranteed that the resource will not be closed or removed. However, it is possible for the resource to be accessed by any number of components in parallel.
func (*Type) AccessOutput ¶
AccessOutput attempts to access an output resource by a unique identifier and executes a closure function with the output as an argument. Returns an error if the output does not exist (or is otherwise inaccessible).
During the execution of the provided closure it is guaranteed that the resource will not be closed or removed. However, it is possible for the resource to be accessed by any number of components in parallel.
func (*Type) AccessProcessor ¶
AccessProcessor attempts to access a processor resource by a unique identifier and executes a closure function with the processor as an argument. Returns an error if the processor does not exist (or is otherwise inaccessible).
During the execution of the provided closure it is guaranteed that the resource will not be closed or removed. However, it is possible for the resource to be accessed by any number of components in parallel.
func (*Type) AccessRateLimit ¶
AccessRateLimit attempts to access a rate limit resource by a unique identifier and executes a closure function with the rate limit as an argument. Returns an error if the rate limit does not exist (or is otherwise inaccessible).
During the execution of the provided closure it is guaranteed that the resource will not be closed or removed. However, it is possible for the resource to be accessed by any number of components in parallel.
func (*Type) BloblEnvironment ¶
func (t *Type) BloblEnvironment() *bloblang.Environment
BloblEnvironment returns a Bloblang environment used by the manager. This is for internal use only.
func (*Type) Environment ¶
func (t *Type) Environment() *bundle.Environment
Environment returns a bundle environment used by the manager. This is for internal use only.
func (*Type) ForStream ¶
func (t *Type) ForStream(id string) bundle.NewManagement
ForStream returns a variant of this manager to be used by a particular stream identifer, where APIs registered will be namespaced by that id.
func (*Type) GetPipe ¶
func (t *Type) GetPipe(name string) (<-chan message.Transaction, error)
GetPipe attempts to obtain and return a named output Pipe
func (*Type) IntoPath ¶
func (t *Type) IntoPath(segments ...string) bundle.NewManagement
IntoPath returns a variant of this manager to be used by a particular component path, which is a child of the current component, where observability components will be automatically tagged with the new path.
func (*Type) NewOutput ¶
func (t *Type) NewOutput(conf output.Config, pipelines ...processor.PipelineConstructorFunc) (output.Streamed, error)
NewOutput attempts to create a new output component from a config.
func (*Type) NewProcessor ¶
NewProcessor attempts to create a new processor component from a config.
func (*Type) NewRateLimit ¶
NewRateLimit attempts to create a new rate limit component from a config.
func (*Type) ProbeCache ¶
ProbeCache returns true if a cache resource exists under the provided name.
func (*Type) ProbeInput ¶
ProbeInput returns true if an input resource exists under the provided name.
func (*Type) ProbeOutput ¶
ProbeOutput returns true if an output resource exists under the provided name.
func (*Type) ProbeProcessor ¶
ProbeProcessor returns true if a processor resource exists under the provided name.
func (*Type) ProbeRateLimit ¶
ProbeRateLimit returns true if a rate limit resource exists under the provided name.
func (*Type) RegisterEndpoint ¶
func (t *Type) RegisterEndpoint(apiPath, desc string, h http.HandlerFunc)
RegisterEndpoint registers a server wide HTTP endpoint.
func (*Type) SetPipe ¶
func (t *Type) SetPipe(name string, tran <-chan message.Transaction)
SetPipe registers a new transaction chan to a named pipe.
func (*Type) StoreCache ¶
StoreCache attempts to store a new cache resource. If an existing resource has the same name it is closed and removed _before_ the new one is initialized in order to avoid duplicate connections.
func (*Type) StoreInput ¶
StoreInput attempts to store a new input resource. If an existing resource has the same name it is closed and removed _before_ the new one is initialized in order to avoid duplicate connections.
func (*Type) StoreOutput ¶
StoreOutput attempts to store a new output resource. If an existing resource has the same name it is closed and removed _before_ the new one is initialized in order to avoid duplicate connections.
func (*Type) StoreProcessor ¶
StoreProcessor attempts to store a new processor resource. If an existing resource has the same name it is closed and removed _before_ the new one is initialized in order to avoid duplicate connections.
func (*Type) StoreRateLimit ¶
StoreRateLimit attempts to store a new rate limit resource. If an existing resource has the same name it is closed and removed _before_ the new one is initialized in order to avoid duplicate connections.
func (*Type) Tracer ¶ added in v4.3.0
func (t *Type) Tracer() trace.TracerProvider
Tracer returns a tracer provider with the current component context.
func (*Type) TriggerCloseNow ¶ added in v4.6.0
func (t *Type) TriggerCloseNow()
TriggerCloseNow triggers the absolute shut down of this component but should not block the calling goroutine.
func (*Type) TriggerStopConsuming ¶ added in v4.6.0
func (t *Type) TriggerStopConsuming()
TriggerStopConsuming instructs the manager to stop resource inputs and outputs from consuming data. This call does not block.
func (*Type) UnsetPipe ¶
func (t *Type) UnsetPipe(name string, tran <-chan message.Transaction)
UnsetPipe removes a named pipe transaction chan.
func (*Type) WaitForClose ¶
WaitForClose is a blocking call to wait until the component has finished shutting down and cleaning up resources.
func (*Type) WithAddedMetrics ¶
func (t *Type) WithAddedMetrics(m metrics.Type) bundle.NewManagement
WithAddedMetrics returns a modified version of the manager where metrics are registered to both the current metrics target as well as the provided one.