Documentation
¶
Index ¶
- type ConsensusRequest
- type ConsensusResponse
- type Handler
- type Store
- func (s *Store[T]) Add(req T) error
- func (s *Store[T]) Evict(requestID string) (T, bool)
- func (s *Store[T]) FirstN(batchSize int) ([]T, error)
- func (s *Store[T]) Get(requestID string) T
- func (s *Store[T]) GetByIDs(requestIDs []string) []T
- func (s *Store[T]) Len() int
- func (s *Store[T]) RangeN(start, batchSize int) ([]T, error)
- type StoredRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConsensusRequest ¶
type ConsensusResponse ¶
type ConsensusResponse interface {
RequestID() string
}
type Handler ¶
type Handler[T ConsensusRequest[T, R], R ConsensusResponse] struct { services.Service // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler[T ConsensusRequest[T, R], R ConsensusResponse](lggr logger.Logger, s *Store[T], clock clockwork.Clock, responseExpiryTime time.Duration) *Handler[T, R]
func (*Handler[T, R]) SendRequest ¶
func (*Handler[T, R]) SendResponse ¶
type Store ¶
type Store[T StoredRequest[T]] struct { // contains filtered or unexported fields }
Store is a generic store for ongoing consensus requests. It is thread-safe and uses a map to store requests.
func NewStore ¶
func NewStore[T StoredRequest[T]]() *Store[T]
func NewStoreWithStatsCollector ¶ added in v0.9.0
func NewStoreWithStatsCollector[T StoredRequest[T]](statsCollector statsCollector) *Store[T]
func (*Store[T]) FirstN ¶
FirstN retrieves up to `batchSize` requests. The method deep-copies requests before returning them.
func (*Store[T]) Get ¶
Get retrieves a request by its ID. The method deep-copies the request before returning it.
type StoredRequest ¶
Click to show internal directories.
Click to hide internal directories.