batch

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	// contains filtered or unexported fields
}

Batch allows us to buffer multiple request/response structures into a single batch request. NOT thread safe

func NewBatch

func NewBatch(client Client) *Batch

NewBatch creates a new batch object

func (*Batch) AddRequest

func (b *Batch) AddRequest(request types.RPCRequest)

AddRequest adds a new request onto the batch

func (*Batch) Clear

func (b *Batch) Clear() int

Clear empties out the request batch

func (*Batch) Count

func (b *Batch) Count() int

Count returns the number of enqueued requests waiting to be sent

func (*Batch) Send

func (b *Batch) Send(ctx context.Context) (types.RPCResponses, error)

Send will attempt to send the current batch of enqueued requests, and then will clear out the requests once done

type Client

type Client interface {
	SendBatch(context.Context, types.RPCRequests) (types.RPCResponses, error)
}

Jump to

Keyboard shortcuts

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