Documentation ¶
Overview ¶
Package sharedcomponent exposes functionality for components to register against a shared key, such as a configuration object, in order to be reused across signal types. This is particularly useful when the component relies on a shared resource such as os.File or http.Server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Component ¶
Component ensures that the wrapped component is started and stopped only once. When stopped it is removed from the Map.
type Map ¶
type Map[K comparable, V component.Component] struct { // contains filtered or unexported fields }
Map keeps reference of all created instances for a given shared key such as a component configuration.
func (*Map[K, V]) LoadOrStore ¶
func (m *Map[K, V]) LoadOrStore(key K, create func() (V, error), telemetrySettings *component.TelemetrySettings) (*Component[V], error)
LoadOrStore returns the already created instance if exists, otherwise creates a new instance and adds it to the map of references.