sharedcomponent

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 any, 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