broadcast

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseClient

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

BaseClient defines the basic structure for a client that can receive broadcast messages. Other client types can embed this struct to inherit its functionality.

func (*BaseClient) Close

func (c *BaseClient) Close()

Close cleans up the client's resources by closing the stop and broadcast channels.

func (*BaseClient) Name

func (c *BaseClient) Name() string

Name returns the name of the client.

func (*BaseClient) SkippedCerts

func (c *BaseClient) SkippedCerts() uint64

SkippedCerts returns the number of certificates that were skipped due to the client's broadcast channel being full.

func (*BaseClient) SubType

func (c *BaseClient) SubType() SubscriptionType

SubType returns the subscription type of the client.

func (*BaseClient) Write

func (c *BaseClient) Write(data []byte)

Write sends a message to the client's broadcast channel. If the channel is full, it increments the skippedCerts counter and logs a message.

type CertProcessor

type CertProcessor interface {
	// Write sends a message to the client's broadcast channel.
	Write(message []byte)
	// Close closes the client's connection and cleans up resources.
	Close()

	// To obtain client details, there are getter methods for several values
	Name() string
	SubType() SubscriptionType
	SkippedCerts() uint64
}

CertProcessor defines the interface for processing certificate messages. Different implementations can be used for different types of clients, such as WebSocket clients, kafka, or other message queues for example.

type Dispatcher

type Dispatcher struct {
	MessageQueue chan models.Entry
	// contains filtered or unexported fields
}
var ClientHandler *Dispatcher

ClientHandler dispatches certificate entries to registered clients.

func NewDispatcher

func NewDispatcher() *Dispatcher

NewDispatcher creates a new Dispatcher instance and assigns it to the ClientHandler variable.

func (*Dispatcher) ClientDomainsCount

func (bm *Dispatcher) ClientDomainsCount() (count int64)

ClientDomainsCount returns the current number of clients connected to the service on the `domains-only` endpoint.

func (*Dispatcher) ClientFullCount

func (bm *Dispatcher) ClientFullCount() (count int64)

ClientFullCount returns the current number of clients connected to the service on the `full` endpoint.

func (*Dispatcher) ClientLiteCount

func (bm *Dispatcher) ClientLiteCount() (count int64)

ClientLiteCount returns the current number of clients connected to the service on the `lite` endpoint.

func (*Dispatcher) GetSkippedCerts

func (bm *Dispatcher) GetSkippedCerts() map[string]uint64

GetSkippedCerts returns a map of client names to the number of skipped certificates for each client.

func (*Dispatcher) RegisterClient

func (bm *Dispatcher) RegisterClient(c CertProcessor)

RegisterClient adds a client to the list of clients of the Dispatcher. The client will receive certificate broadcasts right after registration.

func (*Dispatcher) Start

func (bm *Dispatcher) Start()

Start starts the broadcaster goroutine.

func (*Dispatcher) UnregisterClient

func (bm *Dispatcher) UnregisterClient(clientToRemove CertProcessor)

UnregisterClient removes a client from the list of clients of the Dispatcher. The client will no longer receive certificate broadcasts right after unregistering.

type KafkaClient

type KafkaClient struct {
	BaseClient
	// contains filtered or unexported fields
}

KafkaClient connects to a Kafka server in order to provide it with certificates.

func NewKafkaClient

func NewKafkaClient(subType SubscriptionType, addr, name, topic, compression string, certBufferSize int) *KafkaClient

NewKafkaClient creates a new Kafka client that immediately connects to the configured Kafka server.

type NSQClient

type NSQClient struct {
	BaseClient
	// contains filtered or unexported fields
}

NSQClient connects to a NSQ server in order to provide it with certificates.

func NewNSQClient

func NewNSQClient(subType SubscriptionType, addr, name, topic string, certBufferSize int) *NSQClient

NewNSQClient creates a new NSQ client that immediately connects to the configured NSQ server

type SubscriptionType

type SubscriptionType int
const (
	// SubTypeFull represents full certificate updates.
	SubTypeFull SubscriptionType = iota
	// SubTypeLite represents certificate updates with less details.
	SubTypeLite
	// SubTypeDomain represents updates that only include domain information.
	SubTypeDomain
)

type WebsocketClient

type WebsocketClient struct {
	*BaseClient
	// contains filtered or unexported fields
}

WebsocketClient represents a single WebSocket client's connection to the server.

func NewWebsocketClient

func NewWebsocketClient(conn *websocket.Conn, subType SubscriptionType, name, userAgent, hostIP, hostPort, realIPFromHeader string, certBufferSize int) *WebsocketClient

NewWebsocketClient creates a new WebSocket client from the given connection.

func (*WebsocketClient) Name

func (c *WebsocketClient) Name() string

Name returns the name/identifier for this client.

Jump to

Keyboard shortcuts

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