distributor

package
v0.31.9-HCU-test Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultDisallowListNotificationQueueCacheSize is the default size of the disallow list notification queue.
	DefaultDisallowListNotificationQueueCacheSize = 100
)
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 DisallowListNotificationDistributor

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

DisallowListNotificationDistributor is a component that distributes disallow list updates to registered consumers in an asynchronous, fan-out manner. It is thread-safe and can be used concurrently from multiple goroutines.

func DefaultDisallowListNotificationDistributor

func DefaultDisallowListNotificationDistributor(logger zerolog.Logger, opts ...queue.HeroStoreConfigOption) *DisallowListNotificationDistributor

DefaultDisallowListNotificationDistributor creates a new disallow list notification distributor with default configuration.

func NewDisallowListConsumer

func NewDisallowListConsumer(logger zerolog.Logger, store engine.MessageStore) *DisallowListNotificationDistributor

NewDisallowListConsumer creates a new disallow list notification distributor. It takes a message store as a parameter, which is used to store the events that are distributed to the consumers. The message store is used to ensure that DistributeBlockListNotification is non-blocking.

func (*DisallowListNotificationDistributor) AddConsumer

AddConsumer adds a consumer to the distributor. The consumer will be called the 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 (*DisallowListNotificationDistributor) DistributeBlockListNotification

func (d *DisallowListNotificationDistributor) DistributeBlockListNotification(disallowList flow.IdentifierList) error

DistributeBlockListNotification distributes the event to all the consumers. Implementation is non-blocking, it submits the event to the worker pool and returns immediately. The event will be distributed to the consumers in the order it was submitted but asynchronously. If the worker pool is full, the event will be dropped and a warning will be logged. This implementation returns no error.

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