subscription

package
v2.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

Variables

This section is empty.

Functions

func BitmaskToFilterPendingsCommands

func BitmaskToFilterPendingsCommands(bitmask FilterBitmask) []pb.GetPendingCommandsRequest_Command

func ConvertToSubjects

func ConvertToSubjects(owner string, filters map[uuid.UUID]*commands.ResourceId, bitmask FilterBitmask) []string

func IsFilteredBit

func IsFilteredBit(filteredEventTypes FilterBitmask, bit FilterBitmask) bool

Types

type ErrFunc

type ErrFunc = func(err error)

type FilterBitmask

type FilterBitmask uint64
const (
	FilterBitmaskResourceCreatePending       FilterBitmask = 1
	FilterBitmaskResourceCreated             FilterBitmask = 1 << 1
	FilterBitmaskResourceRetrievePending     FilterBitmask = 1 << 2
	FilterBitmaskResourceRetrieved           FilterBitmask = 1 << 3
	FilterBitmaskResourceUpdatePending       FilterBitmask = 1 << 4
	FilterBitmaskResourceUpdated             FilterBitmask = 1 << 5
	FilterBitmaskResourceDeletePending       FilterBitmask = 1 << 6
	FilterBitmaskResourceDeleted             FilterBitmask = 1 << 7
	FilterBitmaskDeviceMetadataUpdatePending FilterBitmask = 1 << 8
	FilterBitmaskDeviceMetadataUpdated       FilterBitmask = 1 << 9
	FilterBitmaskDeviceRegistered            FilterBitmask = 1 << 10
	FilterBitmaskDeviceUnregistered          FilterBitmask = 1 << 11
	FilterBitmaskResourceChanged             FilterBitmask = 1 << 12
	FilterBitmaskResourcesPublished          FilterBitmask = 1 << 13
	FilterBitmaskResourcesUnpublished        FilterBitmask = 1 << 14
	FilterBitmaskMax                         FilterBitmask = 0xffffffff
)

func EventsFilterToBitmask

func EventsFilterToBitmask(commandFilter []pb.SubscribeToEvents_CreateSubscription_Event) FilterBitmask

func FilterPendingsCommandsToBitmask

func FilterPendingsCommandsToBitmask(commandFilter []pb.GetPendingCommandsRequest_Command) FilterBitmask

type SendEventFunc

type SendEventFunc = func(e *pb.Event) error

type SendEventWithTypeFunc

type SendEventWithTypeFunc = func(e *pb.Event, typeBit FilterBitmask) error

type Sub

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

func New

func New(send SendEventFunc, correlationID string, req *pb.SubscribeToEvents_CreateSubscription) *Sub

func (*Sub) Close

func (s *Sub) Close() error

Close closes subscription.

func (*Sub) CorrelationId

func (s *Sub) CorrelationId() string

func (*Sub) Id

func (s *Sub) Id() string

func (*Sub) Init

func (s *Sub) Init(owner string, subCache *SubscriptionsCache) error

func (*Sub) ProcessEvent

func (s *Sub) ProcessEvent(e *pb.Event, eventType FilterBitmask) error

type SubscriptionsCache

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

func NewSubscriptionsCache

func NewSubscriptionsCache(conn *nats.Conn, errFunc ErrFunc) *SubscriptionsCache

func (*SubscriptionsCache) Subscribe

func (c *SubscriptionsCache) Subscribe(subject string, onEvent SendEventWithTypeFunc) (closeFn func(), err error)

Subscribe register onEvents handler and creates a NATS subscription, if it does not exist. To free subscription call the returned close function.

Jump to

Keyboard shortcuts

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