batcher

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BatchNotFull = batchFull(0)
	BatchIsFull  = batchFull(1)
)
View Source
const (
	Closing   = "closing"
	FullBatch = "full"
	InstantQ  = "instant"
)

Variables

This section is empty.

Functions

func NewDispatcherP

func NewDispatcherP() counter.Provider

Types

type Service

type Service struct {
	*adjust.Adjust
	config.BatcherConfig
	ServiceMeta
	// contains filtered or unexported fields
}

Service sits on top of an Evaluator and collects predictions calls and attempts to merge multiple calls into a single call, if they occur rapidly enough. This *can* be refactored into smaller types; but it's really more annoying than convenient.

func NewBatcher

func NewBatcher(evaluator evaluator.Evaluator, inputLen int, batchConfig config.BatcherConfig, serviceMeta ServiceMeta) *Service

func (*Service) Close

func (s *Service) Close() error

Waits for any queued batches to complete then closes underlying resources.

func (*Service) Evaluate

func (s *Service) Evaluate(ctx context.Context, inputs []interface{}) ([]interface{}, error)

Evaluate will queue a batch and wait for results. This is safe to run in any number of goroutines.

Evaluate will send the input to be (further) batched to a dispatcher, via the inputQ. See dispatcher.dispatch(), which will then call Service.queueBatch(), which pushes to batchQ. dispatcher also determines if waiting to send to batchQ is appropriate. See queueService.dispatch(), which reads from batchQ which will then finally run evaluator.Evaluator.Evaluate() when appropriate and return the response via a dedicated channel for the goroutine that called Service.Evaluate.

func (*Service) Start added in v0.13.1

func (s *Service) Start()

func (*Service) Stats added in v0.13.1

func (s *Service) Stats(r map[string]interface{})

type ServiceMeta

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

ServiceMeta contains things that should live longer than the life of a Service.

func NewServiceMeta

func NewServiceMeta(m *stat.GMeter, id string) ServiceMeta

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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