Documentation ¶
Index ¶
- type Cond
- type Queue
- type RPCHeader
- type RPCStream
- type Stream
- func (s *Stream[V]) Add(vs ...V) int
- func (s *Stream[V]) ReadAllNonBlocking(offset int) ([]V, int)
- func (s *Stream[V]) ReadBlocking(ctx context.Context, offset int) ([]V, int)
- func (s *Stream[V]) ReadNonBlocking(offset int) ([]V, int)
- func (s *Stream[V]) Subscribe(ctx context.Context, callback func([]V, int) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cond ¶
type Cond struct {
// contains filtered or unexported fields
}
Cond implements conditional variable with a channel
type Queue ¶
type Queue[V any] struct { // contains filtered or unexported fields }
Queue represents a single instance of the queue data structure.
func (*Queue[V]) Get ¶
Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.
func (*Queue[V]) GetP ¶
GetP returns the pointer to the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.
func (*Queue[V]) Peek ¶
func (q *Queue[V]) Peek() V
Peek returns the element at the head of the queue. This call panics if the queue is empty.
func (*Queue[V]) PeekP ¶
func (q *Queue[V]) PeekP() *V
PeekP returns the element at the head of the queue. This call panics if the queue is empty.
func (*Queue[V]) Remove ¶
func (q *Queue[V]) Remove() V
Remove removes and returns the element from the front of the queue. If the queue is empty, the call will panic.
type RPCStream ¶
type RPCStream struct {
// contains filtered or unexported fields
}
RPCStream provides data streams for newHeads, logs, and pendingTransactions.
func NewRPCStreams ¶
func (*RPCStream) HeaderStream ¶
func (*RPCStream) ListenPendingTx ¶
ListenPendingTx is a callback passed to application to listen for pending transactions in CheckTx.
type Stream ¶
type Stream[V any] struct { // contains filtered or unexported fields }
Stream implements a data stream, user can subscribe the stream in blocking or non-blocking way using offsets. it use a segmented ring buffer to store the items, with a fixed capacity, when buffer is full, the old data get pruned when new data comes.
func (*Stream[V]) Add ¶
Add appends items to the stream and returns the id of last one. item id start with 1.
func (*Stream[V]) ReadAllNonBlocking ¶
ReadAllNonBlocking returns all items in the stream, without blocking.
func (*Stream[V]) ReadBlocking ¶
ReadBlocking returns items with id greater than the last received id reported by user. reads at most one segment at a time. negative offset means read from the end. it also returns the largest id of the items, if there are no new items, returns the id of the last item.
func (*Stream[V]) ReadNonBlocking ¶
ReadNonBlocking returns items with id greater than the last received id reported by user, without blocking. if there are no new items, it also returns the largest id of the items.