subscription_manager

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

File: internal/subscription_manager/subscription_manager.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SubscriptionManager

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

SubscriptionManager manages subscriptions for a specific chain.

func NewSubscriptionManager

func NewSubscriptionManager(cfg SubscriptionManagerConfig) *SubscriptionManager

NewSubscriptionManager initializes a new SubscriptionManager.

func (*SubscriptionManager) BroadcastLog

func (sm *SubscriptionManager) BroadcastLog(eventKey internal.EventKey, log api.Log)

BroadcastLog sends the log event to all relevant subscribers.

func (*SubscriptionManager) Close

func (sm *SubscriptionManager) Close()

Close gracefully shuts down the SubscriptionManager by closing all subscriber channels.

func (*SubscriptionManager) GetAddressesAndTopics

func (sm *SubscriptionManager) GetAddressesAndTopics() []internal.EventKey

GetAddressesAndTopics retrieves all unique EventKeys. Implements caching: caches the result after the first call and invalidates it upon subscription changes. Returns a slice of EventKeys, each containing a unique address-topic pair.

func (*SubscriptionManager) Subscribe

func (sm *SubscriptionManager) Subscribe(address common.Address, topic common.Hash) (chan api.Log, error)

Subscribe registers a new subscription and returns a channel for events.

func (*SubscriptionManager) Unsubscribe

func (sm *SubscriptionManager) Unsubscribe(address common.Address, topic common.Hash, ch chan api.Log) error

Unsubscribe removes a subscription and closes the channel.

type SubscriptionManagerConfig

type SubscriptionManagerConfig struct {
	Logger  *zerolog.Logger
	ChainID int64
}

Jump to

Keyboard shortcuts

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