Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BlockMsg ¶
type BlockMsg struct { Height uint64 Hash string Timestamp int64 Txs []string // BlocksGeneratedCount is number of blocks generated last 24 hours. BlocksGeneratedCount uint }
BlockMsg represents the data need by Explorer UI on each new block accepted.
type Broker ¶
type Broker struct { // ConnectionChan is a shared queue to buffer incoming websocket connections // closing connChan will terminate the broker. ConnectionChan chan wsConn // contains filtered or unexported fields }
Broker is a pub/sub broker that keeps updated all subscribers (websocket connections) with latest block accepted published by node layer.
IMPL Notes: Broker is implemented in a non-blocking manner. That means it should not be blocked on mutex-lock, chan push or any I/O operation. It should not expose anything than a channel.
type BrokerPool ¶
type BrokerPool struct { QuitChan chan bool ConnectionsChan chan wsConn // contains filtered or unexported fields }
BrokerPool is a set of broker workers to provide a simple load balancing. Running multiple broker workers also could provide failover.
func NewPool ¶
func NewPool(eventBus *eventbus.EventBus, brokersNum, clientsPerBroker uint) *BrokerPool
NewPool intantiates the specified amount of brokers and run them in separate goroutines. Thus it returns a new BrokerPool instance populated with said brokers.
func (*BrokerPool) Close ¶
func (bp *BrokerPool) Close()
Close the BrokerPool by closing the underlying connection channel.
func (*BrokerPool) PushConn ¶
func (bp *BrokerPool) PushConn(conn *websocket.Conn)
PushConn pushes a websocket connection to the broker pool.