subscription

package
v0.24.3 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ForwardFromChannels added in v0.24.0

func ForwardFromChannels[R any](inputChannels []chan R, onMessage func(R) error, onBackendDisconnect func(), backendDisconnected *atomic.Bool, stopped *atomic.Bool, timeoutInterval time.Duration, logger gethlog.Logger)

ForwardFromChannels - reads messages from all input channels, and calls the `onMessage` callback. Exits when the "stopped" flag is true or when the connection times out. Must be called as a go routine!

func HandleUnsubscribe added in v0.24.0

func HandleUnsubscribe(connectionSub *rpc.Subscription, onUnsub func())

HandleUnsubscribe - when the client calls "unsubscribe" or the subscription times out, it calls `onSub` Must be called as a go routine!

func HandleUnsubscribeErrChan added in v0.24.1

func HandleUnsubscribeErrChan(errChan []<-chan error, onUnsub func())

HandleUnsubscribeErrChan - when the client calls "unsubscribe" or the subscription times out, it calls `onSub` Must be called as a go routine!

Types

type Manager

type Manager[T any] struct {
	// contains filtered or unexported fields
}

Manager is a subscription manager - allows for thread-safe registering/unregistering subscribers of type T

func NewManager

func NewManager[T any]() *Manager[T]

NewManager creates a new subscription manager

func (*Manager[T]) Subscribe

func (m *Manager[T]) Subscribe(subscriber T) func()

Subscribe adds a new subscriber, returns an unsubscribe function

func (*Manager[T]) Subscribers

func (m *Manager[T]) Subscribers() []T

Subscribers returns a list of all subscribers

type NewHeadsService added in v0.24.0

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

NewHeadsService multiplexes new batch header messages from an input channel into multiple subscribers also handles unsubscribe Note: this is a service which must be Started and Stopped

func NewNewHeadsService added in v0.24.0

func NewNewHeadsService(connect func() (chan *common.BatchHeader, <-chan error, error), convertToEthHeader bool, logger gethlog.Logger, onMessage func(*common.BatchHeader) error) *NewHeadsService

connect - function that returns the input channel

func (*NewHeadsService) HealthStatus added in v0.24.0

func (nhs *NewHeadsService) HealthStatus(context.Context) host.HealthStatus

func (*NewHeadsService) RegisterNotifier added in v0.24.0

func (nhs *NewHeadsService) RegisterNotifier(notifier *rpc.Notifier, subscription *rpc.Subscription)

func (*NewHeadsService) Start added in v0.24.0

func (nhs *NewHeadsService) Start() error

func (*NewHeadsService) Stop added in v0.24.0

func (nhs *NewHeadsService) Stop() error

Jump to

Keyboard shortcuts

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