sharedcomponent

package
v0.0.0-...-c4b6d24 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 1, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package sharedcomponent exposes util functionality for receivers and exporters that need to share state between different signal types instances such as net.Listener or os.File.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SharedComponent

type SharedComponent struct {
	component.Component
	// contains filtered or unexported fields
}

SharedComponent ensures that the wrapped component is started and stopped only once. When stopped it is removed from the SharedComponents map.

func (*SharedComponent) Shutdown

func (r *SharedComponent) Shutdown(ctx context.Context) error

Shutdown implements component.Component.

func (*SharedComponent) Start

func (r *SharedComponent) Start(ctx context.Context, host component.Host) error

Start implements component.Component.

func (*SharedComponent) Unwrap

func (r *SharedComponent) Unwrap() component.Component

Unwrap returns the original component.

type SharedComponents

type SharedComponents struct {
	// contains filtered or unexported fields
}

SharedComponents a map that keeps reference of all created instances for a given configuration, and ensures that the shared state is started and stopped only once.

func NewSharedComponents

func NewSharedComponents() *SharedComponents

NewSharedComponents returns a new empty SharedComponents.

func (*SharedComponents) GetOrAdd

func (scs *SharedComponents) GetOrAdd(key interface{}, create func() component.Component) *SharedComponent

GetOrAdd returns the already created instance if exists, otherwise creates a new instance and adds it to the map of references.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL