Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DecodedSSVMessage ¶
type DecodedSSVMessage struct {
*types.SSVMessage
// Body is the decoded Data.
Body interface{} // *SignedMessage | *SignedPartialSignatureMessage
}
DecodedSSVMessage is a bundle of SSVMessage and it's decoding.
func DecodeSSVMessage ¶
func DecodeSSVMessage(logger *zap.Logger, m *spectypes.SSVMessage) (*DecodedSSVMessage, error)
DecodeSSVMessage decodes an SSVMessage and returns a DecodedSSVMessage.
type MessagePrioritizer ¶
type MessagePrioritizer interface {
// Prior returns true if message A should be prioritized over B.
Prior(a, b *DecodedSSVMessage) bool
}
MessagePrioritizer is an interface for prioritizing messages.
func NewMessagePrioritizer ¶
func NewMessagePrioritizer(state *State) MessagePrioritizer
NewMessagePrioritizer returns a standard implementation for MessagePrioritizer which prioritizes messages according to the given State.
type Metrics ¶ added in v0.4.7
type Metrics interface {
// Dropped increments the number of messages dropped from the Queue.
Dropped()
}
Metrics records metrics about the Queue.
func NewPrometheusMetrics ¶ added in v0.4.7
NewPrometheusMetrics returns a Prometheus implementation of Metrics.
type Queue ¶
type Queue interface {
// Push blocks until the message is pushed to the queue.
Push(*DecodedSSVMessage)
// TryPush returns immediately with true if the message was pushed to the queue,
// or false if the queue is full.
TryPush(*DecodedSSVMessage) bool
// Pop returns and removes the next message in the queue, or blocks until a message is available.
// When the context is canceled, Pop returns immediately with any leftover message or nil.
Pop(context.Context, MessagePrioritizer) *DecodedSSVMessage
// TryPop returns immediately with the next message in the queue, or nil if there is none.
TryPop(MessagePrioritizer) *DecodedSSVMessage
// Empty returns true if the queue is empty.
Empty() bool
}
Queue is a queue of DecodedSSVMessage with dynamic (per-pop) prioritization.
func New ¶
New returns an implementation of Queue optimized for concurrent push and sequential pop. Pops aren't thread-safe, so don't call Pop from multiple goroutines.
func NewDefault ¶ added in v0.4.7
func NewDefault() Queue
NewDefault returns an implementation of Queue optimized for concurrent push and sequential pop, with a capacity of 32 and a PusherDropping.
func WithMetrics ¶ added in v0.4.7
WithMetrics returns a wrapping of the given Queue that records metrics using the given Metrics.