batcher

package
v0.8.100 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SleepTime    = time.Microsecond * 100
	MaxBatchSize = 32
	MaxLatency   = 5000
)

Variables

This section is empty.

Functions

func GenerateUUID

func GenerateUUID() string

func GetNowTime

func GetNowTime() time.Time

Types

type BatchHandler

type BatchHandler struct {
	MaxBatchSize int
	MaxLatency   int
	// contains filtered or unexported fields
}

func New

func New(maxBatchSize int, maxLatency int, handler http.Handler, logger *zap.SugaredLogger) *BatchHandler

func (*BatchHandler) Consume

func (handler *BatchHandler) Consume()

func (*BatchHandler) ServeHTTP

func (handler *BatchHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type BatcherInfo

type BatcherInfo struct {
	Path               string
	BatchID            string
	Request            *http.Request
	Instances          []interface{}
	PredictionResponse PredictionResponse
	ContextMap         map[*context.Context]InputInfo
	Start              time.Time
	Now                time.Time
	CurrentInputLen    int
}

func (*BatcherInfo) InitializeInfo

func (batcherInfo *BatcherInfo) InitializeInfo()

type Input

type Input struct {
	ContextInput *context.Context
	Path         string
	Instances    *[]interface{}
	ChannelOut   *chan Response
}

type InputInfo

type InputInfo struct {
	ChannelOut *chan Response
	Index      []int
}

type PredictionResponse

type PredictionResponse struct {
	Predictions []interface{} `json:"predictions"`
}

type Request

type Request struct {
	Instances []interface{} `json:"instances"`
}

type Response

type Response struct {
	Message     string        `json:"message"`
	BatchID     string        `json:"batchId"`
	Predictions []interface{} `json:"predictions"`
}

type ResponseError

type ResponseError struct {
	Message string `json:"message"`
}

Jump to

Keyboard shortcuts

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