subs

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MapMessageInfo

func MapMessageInfo(m []byte) (*sdk.WsMessageInfo, error)

Types

type Mapper

type Mapper[T any] interface {
	Map([]byte) (T, error)
}

type MapperFunc

type MapperFunc[T any] func(payload []byte) (T, error)

type MockSubscribersPool

type MockSubscribersPool[T any] struct {
	mock.Mock
}

MockMessagePublisher is an autogenerated mock type for the MessagePublisher type

func (*MockSubscribersPool[T]) CloseSubscription

func (_m *MockSubscribersPool[T]) CloseSubscription(path *Path, id int)

func (*MockSubscribersPool[T]) GetPaths

func (_m *MockSubscribersPool[T]) GetPaths() []string

func (*MockSubscribersPool[T]) HasSubscriptions

func (_m *MockSubscribersPool[T]) HasSubscriptions(path *Path) bool

func (*MockSubscribersPool[T]) NewSubscription

func (_m *MockSubscribersPool[T]) NewSubscription(path *Path) (<-chan T, int)

func (*MockSubscribersPool[T]) Notify

func (_m *MockSubscribersPool[T]) Notify(ctx context.Context, path *Path, payload []byte) error

type Notifier

type Notifier interface {
	Notify(ctx context.Context, path *Path, payload []byte) error
}

type Path

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

func NewPath

func NewPath(chanelName Topic, address *sdk.Address) *Path

func PathFromWsMessageInfo

func PathFromWsMessageInfo(info *sdk.WsMessageInfo) *Path

func (*Path) Address

func (t *Path) Address() *sdk.Address

func (*Path) String

func (t *Path) String() string

func (*Path) Topic

func (t *Path) Topic() Topic

type Publisher

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

func NewPublisher

func NewPublisher() *Publisher

func (*Publisher) AddSubscriber

func (p *Publisher) AddSubscriber(topic Topic, sub Notifier) error

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, data []byte) error

type SubscribersPool

type SubscribersPool[T any] interface {
	Notifier
	NewSubscription(path *Path) (_ <-chan T, id int)
	CloseSubscription(path *Path, id int)
	GetPaths() []string
	HasSubscriptions(path *Path) bool
}

func NewSubscribersPool

func NewSubscribersPool[T any](mapper Mapper[T]) SubscribersPool[T]

type Topic

type Topic string
const (
	TopicBlock              Topic = "block"
	TopicConfirmedAdded     Topic = "confirmedAdded"
	TopicUnconfirmedAdded   Topic = "unconfirmedAdded"
	TopicUnconfirmedRemoved Topic = "unconfirmedRemoved"
	TopicStatus             Topic = "status"
	TopicPartialAdded       Topic = "partialAdded"
	TopicPartialRemoved     Topic = "partialRemoved"
	TopicCosignature        Topic = "cosignature"
	TopicDriveState         Topic = "driveState"
)

Jump to

Keyboard shortcuts

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