Documentation
¶
Index ¶
- func ConnectionID(conn Connection) string
- func ParticipantsAPIData(domainType spectypes.DomainType, msgs ...qbftstorage.Participation) (any, error)
- type Broadcaster
- type Conn
- type Connection
- type Handler
- type Message
- type MessageFilter
- type MessageType
- type NetworkMessage
- type ParticipantsAPI
- type QueryMessageHandler
- type WSClient
- type WebSocketServer
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
func ParticipantsAPIData ¶
func ParticipantsAPIData(domainType spectypes.DomainType, msgs ...qbftstorage.Participation) (any, error)
ParticipantsAPIData creates a new message from the given message in a new format.
Types ¶
type Broadcaster ¶
type Broadcaster interface {
FromFeed(feed *event.Feed) error
Broadcast(msg Message) error
Register(conn broadcasted) bool
Deregister(conn broadcasted) bool
}
Broadcaster is an interface broadcasting stream message across all available connections
type Conn ¶
type Conn interface {
ID() string
ReadNext() []byte
Send(msg []byte)
WriteLoop(logger *zap.Logger)
ReadLoop(logger *zap.Logger)
Close() error
RemoteAddr() net.Addr
}
Conn is a wrapper interface for websocket connections
type Connection ¶
Connection is an interface to abstract the actual websocket connection implementation
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) HandleErrorQuery ¶
func (h *Handler) HandleErrorQuery(nm *NetworkMessage)
HandleErrorQuery handles TypeError queries.
func (*Handler) HandleParticipantsQuery ¶
func (h *Handler) HandleParticipantsQuery(store *storage.ParticipantStores, nm *NetworkMessage, domain spectypes.DomainType)
HandleParticipantsQuery handles TypeParticipants queries.
func (*Handler) HandleUnknownQuery ¶
func (h *Handler) HandleUnknownQuery(nm *NetworkMessage)
HandleUnknownQuery handles unknown queries.
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 any `json:"data,omitempty"`
}
Message represents an exporter message
func NewParticipantsAPIMsg ¶
func NewParticipantsAPIMsg(domainType spectypes.DomainType, msg qbftstorage.Participation) Message
NewParticipantsAPIMsg creates a new message in a new format from the given message.
type MessageFilter ¶
type MessageFilter struct {
// From is the starting index of the desired data
From uint64 `json:"from"`
// To is the ending index of the desired data
To uint64 `json:"to"`
// Role is the duty type, optional as it's relevant for IBFT data
Role string `json:"role,omitempty"`
// PublicKey is optional, used for fetching decided messages or information about specific validator/operator
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" // TypeDecided is an enum for ibft type messages TypeDecided MessageType = "decided" // TypeError is an enum for error type messages TypeError MessageType = "error" // TypeParticipants is an enum for participants type messages TypeParticipants MessageType = "participants" )
type NetworkMessage ¶
type NetworkMessage struct {
Msg Message
Err error
Conn Connection
}
NetworkMessage wraps an actual message with more information
type ParticipantsAPI ¶
type QueryMessageHandler ¶
type QueryMessageHandler func(nm *NetworkMessage)
QueryMessageHandler handles the given message
type WSClient ¶
type WSClient struct {
// contains filtered or unexported fields
}
WSClient represents a client connection to be used in tests
func NewWSClient ¶
NewWSClient creates a new instance of ws client
func (*WSClient) MessageCount ¶
MessageCount returns the count of incoming messages
func (*WSClient) StartQuery ¶
StartQuery initiates query requests
func (*WSClient) StartStream ¶
StartStream initiates stream
type WebSocketServer ¶
type WebSocketServer interface {
Start(addr string) error
BroadcastFeed() *event.Feed
UseQueryHandler(handler QueryMessageHandler)
}
WebSocketServer is responsible for managing all
func NewWsServer ¶
func NewWsServer(ctx context.Context, logger *zap.Logger, handler QueryMessageHandler, mux *http.ServeMux, withPing bool) WebSocketServer
NewWsServer creates a new instance