Documentation
¶
Index ¶
- type BaseClient
- type CertProcessor
- type Dispatcher
- func (bm *Dispatcher) ClientDomainsCount() (count int64)
- func (bm *Dispatcher) ClientFullCount() (count int64)
- func (bm *Dispatcher) ClientLiteCount() (count int64)
- func (bm *Dispatcher) GetSkippedCerts() map[string]uint64
- func (bm *Dispatcher) RegisterClient(c CertProcessor)
- func (bm *Dispatcher) Start()
- func (bm *Dispatcher) UnregisterClient(clientName string)
- type KafkaClient
- type NSQClient
- type SubscriptionType
- type WebsocketClient
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) 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 ¶
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) UnregisterClient ¶
func (bm *Dispatcher) UnregisterClient(clientName string)
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.