batch

package
v1.40.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const RequestBufferSize = 1 << 17

RequestBufferSize is the amount of requests users can dispatch that haven't been processed yet before dispatching new ones would start blocking.

View Source
const SkipBatchContextKey contextKey = "skip_batch"

SkipBatchContextKey existence on a context will eliminate the request batching

Variables

This section is empty.

Functions

This section is empty.

Types

type Batcher

type Batcher interface {
	BatchFor(ctx context.Context, key string, dur time.Duration, exec Executer) (interface{}, error)
}

type ConditionalExecutor added in v0.70.3

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

ConditionalExecutor will batch requests only if SkipBatchContextKey is not on the context of the batch request.

func NewConditionalExecutor added in v0.70.3

func NewConditionalExecutor(logger logging.Logger) *ConditionalExecutor

func (*ConditionalExecutor) BatchFor added in v0.70.3

func (c *ConditionalExecutor) BatchFor(ctx context.Context, key string, timeout time.Duration, exec Executer) (interface{}, error)

func (*ConditionalExecutor) Run added in v0.70.3

func (c *ConditionalExecutor) Run(ctx context.Context)

type DelayFn

type DelayFn func(dur time.Duration)

type Executer added in v0.40.0

type Executer interface {
	Execute() (interface{}, error)
}

type ExecuterFunc added in v0.97.0

type ExecuterFunc func() (interface{}, error)

func (ExecuterFunc) Execute added in v0.97.0

func (b ExecuterFunc) Execute() (interface{}, error)

type Executor

type Executor struct {
	Logger logging.Logger
	Delay  DelayFn
	// contains filtered or unexported fields
}

func NewExecutor

func NewExecutor(logger logging.Logger) *Executor

func (*Executor) BatchFor

func (e *Executor) BatchFor(ctx context.Context, key string, timeout time.Duration, exec Executer) (interface{}, error)

func (*Executor) Run

func (e *Executor) Run(ctx context.Context)

type NoOpBatchingExecutor added in v0.97.0

type NoOpBatchingExecutor struct{}

func NopExecutor

func NopExecutor() *NoOpBatchingExecutor

func (*NoOpBatchingExecutor) BatchFor added in v0.97.0

func (n *NoOpBatchingExecutor) BatchFor(_ context.Context, _ string, _ time.Duration, exec Executer) (interface{}, error)

type Tracker added in v0.97.0

type Tracker interface {
	// Batched is called when a request is added to an existing batch.
	Batched()
}

type WaitFor added in v1.25.0

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

WaitFor holds a request and its original context.

type Waiters added in v1.25.0

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

Waiters holds waiting requests.

Jump to

Keyboard shortcuts

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