events

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2020 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitializeEventPubsub

func InitializeEventPubsub(ur string)

InitializeEventPubsub initializes the global pubsub broadcaster server

func Publish

func Publish(event Event)

Publish publishes an event on the pubsub singleton.

Types

type AtxCreated

type AtxCreated struct {
	Created bool
	Id      string
	Layer   uint64
}

func (AtxCreated) GetChannel

func (AtxCreated) GetChannel() ChannelId

type ChannelId

type ChannelId byte

ChannelId is the Id on which subscribers must register in order to listen to messages on the channel.

const (
	EventNewBlock ChannelId = 1 + iota
	EventBlockValid
	EventNewAtx
	EventAtxValid
	EventNewTx
	EventTxValid
	EventRewardReceived
	EventCreatedBlock
	EventCreatedAtx
)

type DoneCreatingBlock

type DoneCreatingBlock struct {
	Eligible bool
	Layer    uint64
	Error    string
}

func (DoneCreatingBlock) GetChannel

func (DoneCreatingBlock) GetChannel() ChannelId

type Event

type Event interface {
	// GetChannel returns the channel on which this message will be published.
	GetChannel() ChannelId
}

Event defines the interface that each message sent by the EventPublisher needs to implemet for it to correctly be routed by topic.

type EventPublisher

type EventPublisher struct {
	*Publisher
}

EventPublisher is the struct that publishes events to subscribers by topics.

func NewEventPublisher

func NewEventPublisher(eventUrl string) (*EventPublisher, error)

NewEventPublisher is a constructor for the event publisher, it received a url string in format of tcp://localhost:56565 to start listening for connections.

func (*EventPublisher) Close

func (p *EventPublisher) Close() error

func (*EventPublisher) PublishEvent

func (p *EventPublisher) PublishEvent(event Event) error

PublishEvent publishes the provided event on pubsub infra. It encodes messages using XDR protocol.

type NewAtx

type NewAtx struct {
	Id      string
	LayerId uint64
}

func (NewAtx) GetChannel

func (NewAtx) GetChannel() ChannelId

type NewBlock

type NewBlock struct {
	Id    string
	Layer uint64
	Atx   string
}

func (NewBlock) GetChannel

func (NewBlock) GetChannel() ChannelId

type NewTx

type NewTx struct {
	Id          string
	Origin      string
	Destination string
	Amount      uint64
	Fee         uint64
}

func (NewTx) GetChannel

func (NewTx) GetChannel() ChannelId

type Publisher

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

type RewardReceived

type RewardReceived struct {
	Coinbase string
	Amount   uint64
}

func (RewardReceived) GetChannel

func (RewardReceived) GetChannel() ChannelId

type Subscriber

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

Subscriber defines the struct of the receiving end of the pubsub messages.

func NewSubscriber

func NewSubscriber(url string) (*Subscriber, error)

NewSubscriber received url string as input on which it will register to receive messages passed by server.

func (*Subscriber) Close

func (sub *Subscriber) Close() error

Close closes the socket which in turn will Close the listener func

func (*Subscriber) StartListening

func (sub *Subscriber) StartListening()

StartListening runs in a go routine and listens to all channels this subscriber is registered to. it then passes the messages received to the appropriate reader channel.

func (*Subscriber) Subscribe

func (sub *Subscriber) Subscribe(topic ChannelId) (chan []byte, error)

Subscribe subscribes to the given topic, returns a channel on which data from the topic is received.

func (*Subscriber) SubscribeToAll

func (sub *Subscriber) SubscribeToAll() (chan []byte, error)

SubscribeAll subscribes to all available topics.

type ValidAtx

type ValidAtx struct {
	Id    string
	Valid bool
}

func (ValidAtx) GetChannel

func (ValidAtx) GetChannel() ChannelId

type ValidBlock

type ValidBlock struct {
	Id    string
	Valid bool
}

func (ValidBlock) GetChannel

func (ValidBlock) GetChannel() ChannelId

type ValidTx

type ValidTx struct {
	Id    string
	Valid bool
}

func (ValidTx) GetChannel

func (ValidTx) GetChannel() ChannelId

Jump to

Keyboard shortcuts

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