Help us shape the future of Go! Take the 2026 Go Developer Survey

request

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Request

type Request struct {
	Body []byte // usually the POST JSON content

	// Passed through to Evaluator.
	// This is expected to be [numInputs][1][batchSize]T.
	// TODO consider scenario when the second slice does not have length 1.
	Feeds []interface{}

	Input *transfer.Input // cache metadata
	// contains filtered or unexported fields
}

Request represents the server-side post-processed information about a request. There is no strict struct for request payload since some of the keys of the request are dynamically generated based on the model inputs. See shared/client.Message for client-side perspective.

func NewRequest

func NewRequest(keyLen int, inputs map[string]*domain.Input) *Request

func (*Request) NKeys

func (r *Request) NKeys() int

implements gojay.UnmarshalJSONObject

func (*Request) Put

func (r *Request) Put(key string, value string) error

Put is used when constructing a request NOT using gojay. Deprecated - no longer support this option.

func (*Request) UnmarshalJSONObject

func (r *Request) UnmarshalJSONObject(dec *gojay.Decoder, key string) error

implements gojay.UnmarshalJSONObject see service.(*Handler).serveHTTP() There is some polymorphism involved, as well as loose-typing. Model inputs aren't strictly typed from the perspective of the request. The primary polymorphism comes from the support for multiple rows worth of inputs. There are 2 optional keys that aren't part of the model input: "batch_size" and "cache_key". If the key "batch_size" is provided, then the keys' values should be an array of scalars; otherwise, the keys' values can be a single scalar. The key "cache_key" is used for caching, and should be an array of strings if "batch_size" is provided.

func (*Request) Validate

func (r *Request) Validate() error

Validate is only used server-side.

Jump to

Keyboard shortcuts

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