subscriber

package
v0.0.0-...-01af507 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package subscriber provides types and data structures for subscribers.

Index

Constants

View Source
const (
	// Subscribed set by a subscriber in a message when it first connects.
	Subscribed reason = "Subscribed"
	// Unsubscribed set by a subscriber when it leaves.
	Unsubscribed reason = "Unsubscribed"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Message

type Message struct {
	// NodeName name of the node for which we want to receive the resources.
	// All the resources that are associated to that node will be sent to the
	// subscriber.
	NodeName string
	// UID identifies the subscriber.
	UID string
	// Reason of the message. If it is subscribing or unsubscribing.
	Reason reason
}

Message sent by a subscriber to communicate its presence/absence.

type SubsChan

type SubsChan chan Message

SubsChan a channel used to communicate when new subscribers arrive or existing ones leave.

type Subscribers

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

Subscribers for generic items.

func NewSubscribers

func NewSubscribers() *Subscribers

NewSubscribers creates a new Subscribers.

func (*Subscribers) AddSubscriberPerNode

func (gc *Subscribers) AddSubscriberPerNode(node, sub string)

AddSubscriberPerNode adds a new subscriber for the given node.

func (*Subscribers) DeleteSubscriberPerNode

func (gc *Subscribers) DeleteSubscriberPerNode(node, sub string)

DeleteSubscriberPerNode given the node and the subscribers UID it removes it.

func (*Subscribers) GetSubscribersPerNode

func (gc *Subscribers) GetSubscribersPerNode(node string) fields.Subscribers

GetSubscribersPerNode returns the subscribers for a given node. It's a copy, safe to save it for later use or modify it.

func (*Subscribers) HasNode

func (gc *Subscribers) HasNode(node string) bool

HasNode returns true if a node has subscribers.

func (*Subscribers) Len

func (gc *Subscribers) Len() int

Len returns the number of subscribers.

Jump to

Keyboard shortcuts

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