distributor

package
v0.33.20-find-mismatch... Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultGossipSubInspectorNotificationQueueCacheSize is the default cache size for the gossipsub rpc inspector notification queue.
	DefaultGossipSubInspectorNotificationQueueCacheSize = 10_000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GossipSubInspectorNotifDistributor added in v0.31.0

type GossipSubInspectorNotifDistributor struct {
	component.Component
	// contains filtered or unexported fields
}

GossipSubInspectorNotifDistributor is a component that distributes gossipsub rpc inspector notifications to registered consumers in a non-blocking manner and asynchronously. It is thread-safe and can be used concurrently from multiple goroutines. The distribution is done by a worker pool. The worker pool is configured with a queue that has a fixed size. If the queue is full, the notification is discarded. The queue size and the number of workers can be configured.

func DefaultGossipSubInspectorNotificationDistributor

func DefaultGossipSubInspectorNotificationDistributor(logger zerolog.Logger, opts ...queue.HeroStoreConfigOption) *GossipSubInspectorNotifDistributor

DefaultGossipSubInspectorNotificationDistributor returns a new GossipSubInspectorNotifDistributor component with the default configuration.

func NewGossipSubInspectorNotificationDistributor

func NewGossipSubInspectorNotificationDistributor(log zerolog.Logger, store engine.MessageStore) *GossipSubInspectorNotifDistributor

NewGossipSubInspectorNotificationDistributor returns a new GossipSubInspectorNotifDistributor component. It takes a message store to store the notifications in memory and process them asynchronously.

func (*GossipSubInspectorNotifDistributor) AddConsumer added in v0.31.0

AddConsumer adds a consumer to the distributor. The consumer will be called when distributor distributes a new event. AddConsumer must be concurrency safe. Once a consumer is added, it must be called for all future events. There is no guarantee that the consumer will be called for events that were already received by the distributor.

func (*GossipSubInspectorNotifDistributor) Distribute added in v0.31.0

func (g *GossipSubInspectorNotifDistributor) Distribute(notification *p2p.InvCtrlMsgNotif) error

Distribute distributes the gossipsub rpc inspector notification to all registered consumers. The distribution is done asynchronously and non-blocking. The notification is added to a queue and processed by a worker pool. DistributeEvent in this implementation does not return an error, but it logs a warning if the queue is full.

Jump to

Keyboard shortcuts

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