signal

package
v0.0.0-...-0c66be6 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultBroker = &Broker{}
View Source
var Known = struct {
	CacheInvalidationAll            Signal
	GenericCacheInvalidation        Signal
	DeviceCacheInvalidation         Signal
	DeviceTypeCacheInvalidation     Signal
	ConceptCacheInvalidation        Signal
	CharacteristicCacheInvalidation Signal
	FunctionCacheInvalidation       Signal
	AspectCacheInvalidation         Signal
	DeviceClassCacheInvalidation    Signal
	HubCacheInvalidation            Signal
	DeviceGroupInvalidation         Signal
	ProtocolInvalidation            Signal
	LocationInvalidation            Signal

	UpdateDone Signal
}{
	CacheInvalidationAll:            0,
	GenericCacheInvalidation:        1,
	DeviceCacheInvalidation:         2,
	DeviceTypeCacheInvalidation:     3,
	ConceptCacheInvalidation:        4,
	CharacteristicCacheInvalidation: 5,
	FunctionCacheInvalidation:       6,
	AspectCacheInvalidation:         7,
	DeviceClassCacheInvalidation:    8,
	HubCacheInvalidation:            9,
	DeviceGroupInvalidation:         10,
	ProtocolInvalidation:            11,
	LocationInvalidation:            12,

	UpdateDone: 13,
}

Functions

func Pub

func Pub(signal Signal, value string)

func Sub

func Sub(id string, signal Signal, f func(value string, wg *sync.WaitGroup)) string

Sub returns id, if id == "", one will be created wg will be done as soon as all subscription functions returned on wg only Wait() may be called. and only within a separate go routine, to prevent a deadlock

func Unsub

func Unsub(id string)

func Wait

func Wait(ctx context.Context, sig Signal, is func(value string) bool, broker *Broker) error

Wait waits until a signal matching 'sig' and 'is' is received from 'broker' broke may be nil (defaults to signal.DefaultBroker) returns context.DeadlineExceeded if ctx exceeds a timeout or deadline returns nil if ctx is cancelled or the signal is received

Types

type Broker

type Broker struct {
	Debug bool
	// contains filtered or unexported fields
}

func (*Broker) Pub

func (this *Broker) Pub(signal Signal, value string)

func (*Broker) Sub

func (this *Broker) Sub(id string, signal Signal, f func(value string, wg *sync.WaitGroup)) string

Sub returns id, if id == "", one will be created wg will be done as soon as all subscription functions returned on wg only Wait() may be called. and only within a separate go routine, to prevent a deadlock

func (*Broker) Unsub

func (this *Broker) Unsub(id string)

func (*Broker) Wait

func (this *Broker) Wait(ctx context.Context, sig Signal, is func(value string) bool) error

type Signal

type Signal uint

func (Signal) Pub

func (this Signal) Pub(value string)

func (Signal) Sub

func (this Signal) Sub(id string, f func(value string, wg *sync.WaitGroup)) string

Sub returns id, if id == "", one will be created wg will be done as soon as all subscription functions returned on wg only Wait() may be called. and only within a separate go routine, to prevent a deadlock

func (Signal) Wait

func (this Signal) Wait(ctx context.Context, is func(value string) bool, broker *Broker) error

type Subscription

type Subscription struct {
	Id     string
	Signal Signal
	F      func(value string, wg *sync.WaitGroup)
}

Jump to

Keyboard shortcuts

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