requests

package
v0.7.1-ccip Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConsensusRequest

type ConsensusRequest[T any, R ConsensusResponse] interface {
	ID() string
	Copy() T
	ExpiryTime() time.Time
	SendResponse(ctx context.Context, response R)
	SendTimeout(ctx context.Context)
}

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, R], clock clockwork.Clock, responseExpiryTime time.Duration) *Handler[T, R]

func (*Handler[T, R]) SendRequest

func (h *Handler[T, R]) SendRequest(ctx context.Context, r T)

func (*Handler[T, R]) SendResponse

func (h *Handler[T, R]) SendResponse(ctx context.Context, resp R)

type Store

type Store[T ConsensusRequest[T, R], R ConsensusResponse] 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 ConsensusRequest[T, R], R ConsensusResponse]() *Store[T, R]

func (*Store[T, R]) Add

func (s *Store[T, R]) Add(req T) error

Add adds a new request to the store.

func (*Store[T, R]) Evict

func (s *Store[T, R]) Evict(requestID string) (T, bool)

Evict removes a request from the store by its ID.

func (*Store[T, R]) FirstN

func (s *Store[T, R]) FirstN(batchSize int) ([]T, error)

FirstN retrieves up to `batchSize` requests. The method deep-copies requests before returning them.

func (*Store[T, R]) Get

func (s *Store[T, R]) Get(requestID string) T

Get retrieves a request by its ID. The method deep-copies the request before returning it.

func (*Store[T, R]) GetByIDs

func (s *Store[T, R]) GetByIDs(requestIDs []string) []T

GetByIDs retrieves requests by their IDs. The method deep-copies requests before returning them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL