broadcast

package
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package broadcast contains the functions for creating a broadcaster to send updates to consumers. It is used to send nginx configuration for an nginx Deployment to all pod subscribers for that Deployment.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Broadcaster

type Broadcaster interface {
	Subscribe() SubscriberChannels
	Send(NginxAgentMessage) bool
	CancelSubscription(string)
}

Broadcaster defines an interface for consumers to subscribe to File updates.

type DeploymentBroadcaster

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

DeploymentBroadcaster sends out a signal when an nginx Deployment has updated configuration files. The signal is received by any agent Subscription that cares about this Deployment. The agent Subscription will then send a response of whether or not the configuration was successfully applied.

func NewDeploymentBroadcaster

func NewDeploymentBroadcaster(ctx context.Context, stopCh chan struct{}) *DeploymentBroadcaster

NewDeploymentBroadcaster returns a new instance of a DeploymentBroadcaster.

func (*DeploymentBroadcaster) CancelSubscription

func (b *DeploymentBroadcaster) CancelSubscription(id string)

CancelSubscription removes a Subscriber from the channel list.

func (*DeploymentBroadcaster) Send

func (b *DeploymentBroadcaster) Send(message NginxAgentMessage) bool

Send the message to all listeners. Wait for all listeners to respond. Returns true if there were listeners that received the message.

func (*DeploymentBroadcaster) Subscribe

Subscribe allows a listener to subscribe to broadcast messages. It returns the channel to listen on for messages, as well as a channel to respond on.

type MessageType

type MessageType int

MessageType is the type of message to be sent.

const (
	// ConfigApplyRequest sends files to update nginx configuration.
	ConfigApplyRequest MessageType = iota
	// APIRequest sends an NGINX Plus API request to update configuration.
	APIRequest
)

type NginxAgentMessage

type NginxAgentMessage struct {
	// ConfigVersion is the hashed configuration version of the included files.
	ConfigVersion string
	// NGINXPlusAction is an NGINX Plus API action to be sent.
	NGINXPlusAction *pb.NGINXPlusAction
	// FileOverviews contain the overviews of all files to be sent.
	FileOverviews []*pb.File
	// Type defines the type of message to be sent.
	Type MessageType
}

NginxAgentMessage is sent to all subscribers to send to the nginx agents for either a ConfigApplyRequest or an APIActionRequest.

type SubscriberChannels

type SubscriberChannels struct {
	ListenCh   <-chan NginxAgentMessage
	ResponseCh chan<- struct{}
	ID         string
}

SubscriberChannels are the channels sent to the subscriber to listen and respond on. The ID is used for map lookup to delete a subscriber when it's gone.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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