Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConnectionID ¶
func ConnectionID(conn Connection) string
ConnectionID calculates the id of the given Connection
Types ¶
type AdapterMock ¶
type AdapterMock struct { In chan Message Out chan Message // contains filtered or unexported fields }
AdapterMock is a mock websocket adapter
func (*AdapterMock) IsCloseError ¶
func (am *AdapterMock) IsCloseError(err error) bool
IsCloseError returns true if the error originate as part of some close procedure
func (*AdapterMock) Receive ¶
func (am *AdapterMock) Receive(conn Connection, v interface{}) error
Receive reads a struct from the in channel
func (*AdapterMock) RegisterHandler ¶
func (am *AdapterMock) RegisterHandler(mux *http.ServeMux, endPoint string, handler EndPointHandler)
RegisterHandler not implemented
func (*AdapterMock) Send ¶
func (am *AdapterMock) Send(conn Connection, v interface{}) error
Send sends the given struct to the out channel
type Connection ¶
Connection is an interface to abstract the actual websocket connection implementation
type EndPointHandler ¶
type EndPointHandler = func(conn Connection)
EndPointHandler is an interface to abstract the actual websocket handler implementation
type Message ¶
type Message struct { // Type is the type of message Type MessageType `json:"type"` // Filter Filter MessageFilter `json:"filter"` // Values holds the results, optional as it's relevant for response Data interface{} `json:"data,omitempty"` }
Message represents an exporter message
type MessageFilter ¶
type MessageFilter struct { // From is the starting index of the desired data From int64 `json:"from"` // To is the ending index of the desired data To int64 `json:"to"` // Role is the duty type enum, optional as it's relevant for IBFT data Role DutyRole `json:"role,omitempty"` // PublicKey is optional as it's relevant for IBFT data PublicKey string `json:"publicKey,omitempty"` }
MessageFilter is a criteria for query in request messages and projection in responses
type MessageType ¶
type MessageType string
MessageType is the type of message being sent
const ( // TypeValidator is an enum for validator type messages TypeValidator MessageType = "validator" // TypeOperator is an enum for operator type messages TypeOperator MessageType = "operator" // TypeIBFT is an enum for ibft type messages TypeIBFT MessageType = "ibft" // TypeError is an enum for error type messages TypeError MessageType = "error" )
type NetworkMessage ¶
type NetworkMessage struct { Msg Message Err error Conn Connection }
NetworkMessage wraps an actual message with more information
type OperatorsMessage ¶
type OperatorsMessage struct {
Data []storage.OperatorInformation `json:"data,omitempty"`
}
OperatorsMessage represents message for operators response
type ValidatorsMessage ¶
type ValidatorsMessage struct {
Data []storage.ValidatorInformation `json:"data,omitempty"`
}
ValidatorsMessage represents message for validators response
type WebSocketAdapter ¶
type WebSocketAdapter interface { RegisterHandler(mux *http.ServeMux, endPoint string, handler EndPointHandler) Send(conn Connection, v interface{}) error Receive(conn Connection, v interface{}) error IsCloseError(err error) bool }
WebSocketAdapter is an abstraction to decouple actual library implementation
func NewAdapterMock ¶
func NewAdapterMock(logger *zap.Logger) WebSocketAdapter
NewAdapterMock creates a new adapter for tests
type WebSocketServer ¶
type WebSocketServer interface { Start(addr string) error IncomingSubject() pubsub.Subscriber OutboundSubject() pubsub.Publisher }
WebSocketServer is the interface exposed by this package
func NewWsServer ¶
func NewWsServer(logger *zap.Logger, adapter WebSocketAdapter, mux *http.ServeMux) WebSocketServer
NewWsServer creates a new instance