pubsub

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2023 License: MPL-2.0 Imports: 5 Imported by: 4

Documentation

Index

Constants

View Source
const (
	CrossTransferTopic = Topic("cross-transfer")
)

Variables

View Source
var (
	// ErrDuplicateSubscriber is returned when a client tries to subscribe
	// with an existing client ID.
	ErrDuplicateClientID = errors.New("clientID is exist")

	// ErrAlreadySubscribed is returned when a client tries to subscribe twice or
	// more using the same topic.
	ErrAlreadySubscribed = errors.New("already subscribed")

	// ErrSubscriptionNotFound is returned when a client tries to unsubscribe
	// from not existing subscription.
	ErrSubscriptionNotFound = errors.New("subscription not found")

	ErrNilHandler = errors.New("handler is nil")
)

Functions

This section is empty.

Types

type ClientID

type ClientID string

type CrossReceiver

type CrossReceiver struct {
	Addr   string
	Amount int64
}

type CrossTransferEvent

type CrossTransferEvent struct {
	TxHash     string
	ChainId    string
	Type       string
	RelayerFee int64
	From       string
	Denom      string
	Contract   string
	Decimals   int
	To         []CrossReceiver
}

func (CrossTransferEvent) GetTopic

func (event CrossTransferEvent) GetTopic() Topic

type Event

type Event interface {
	GetTopic() Topic
}

type Handler

type Handler func(Event)

type Server

type Server struct {
	common.BaseService
	// contains filtered or unexported fields
}

func NewServer

func NewServer(logger log.Logger) *Server

func (*Server) HasSubscribed

func (server *Server) HasSubscribed(clientID ClientID, topic Topic) bool

func (*Server) NewSubscriber

func (server *Server) NewSubscriber(clientID ClientID, logger log.Logger) (*Subscriber, error)

func (*Server) OnStart

func (server *Server) OnStart() error

func (*Server) OnStop

func (server *Server) OnStop()

func (*Server) Publish

func (server *Server) Publish(e Event)

type Subscriber

type Subscriber struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

func (*Subscriber) Subscribe

func (s *Subscriber) Subscribe(topic Topic, handler Handler) error

func (*Subscriber) Unsubscribe

func (s *Subscriber) Unsubscribe(topic Topic) error

func (*Subscriber) UnsubscribeAll

func (s *Subscriber) UnsubscribeAll() error

func (*Subscriber) Wait

func (s *Subscriber) Wait()

type Topic

type Topic string

Jump to

Keyboard shortcuts

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