common

package
v0.14.5 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//CacheKey cache key
	CacheKey = "cache_key"
	//BatchSizeKey batch size key
	BatchSizeKey = "batch_size"
)
View Source
const (
	//ModelURI represents model eval URI template
	ModelURI = "/v1/api/model/%s/eval"
	//MetaURI represents model meta URI template
	MetaURI = "/v1/api/model/%s/meta/"
	//MetaConfigURI represents model meta config URI template
	MetaConfigURI = "/v1/api/model/%s/meta/config"
	//MetaDictionaryURI represents model meta dictionary URI template
	MetaDictionaryURI = "/v1/api/model/%s/meta/dictionary"
)
View Source
const (
	//StatusOK response status ok
	StatusOK = "ok"
	//StatusError represents error status
	StatusError = "error"
	//StatusCached represents cache status
	StatusCached = "cached"
)
View Source
const (
	//HashBin represents hash bin
	HashBin = "dictHash"
)
View Source
const KeyDelimiter = '/'

KeyDelimiter key delimiter

View Source
const (
	//MetricURI represents metric URI
	MetricURI = "/v1/api/metric/"
)

Variables

View Source
var ErrNodeDown = errors.New("node is down")

ErrNodeDown node down error

Functions

func DataType

func DataType(dataType string) (reflect.Type, error)

DataType return reflect.Type for supplied data type

func GetHostIPv4

func GetHostIPv4(hostname string) (string, error)

GetHostIPv4 return host ipv4 address or error

func Hash

func Hash(source interface{}) int

Hash returns hash or zero

func IsAuthorized

func IsAuthorized(request *http.Request, allowedSubset []string) bool

IsAuthorized checks if request is authorized

func IsConnectionError

func IsConnectionError(err error) bool

IsConnectionError returns true if error is connection errpr

func IsInvalidNode

func IsInvalidNode(err error) bool

IsInvalidNode returns true is node/cluster is down

func IsKeyNotFound

func IsKeyNotFound(err error) bool

IsKeyNotFound returns true if key not found error

func IsTimeout

func IsTimeout(err error) bool

IsTimeout returns true if timeout error

func IsTransientError

func IsTransientError(err error) bool

IsTransientError returns if transient error

func SetHash

func SetHash(dest interface{}, hash int)

SetHash sets hash

Types

type Dictionary

type Dictionary struct {
	Layers []Layer
	Hash   int // used to check if a model updated
}

Contains information for bounding cardinality

func (*Dictionary) UpdateHash added in v0.2.1

func (d *Dictionary) UpdateHash(fsHash int64) int

TODO this should use a fixed size integer? UpdateHash will memoize dictionary hashing. Since wildcard fields don't provide an actual dictionary, we use the modification time information to generate a hash based on the file, passed in as fsHash.

type Hashed

type Hashed interface {
	Hash() int
	SetHash(hash int)
}

Hashed represent dictionary hash holder

type Iterator

type Iterator func(pair Pair) error

Iterator represents iterator

func MapToIterator

func MapToIterator(aMap map[string]interface{}) Iterator

MapToIterator create an iterator for supplied map

func (Iterator) ToMap

func (r Iterator) ToMap() (map[string]interface{}, error)

ToMap coverts iterator to map

type Layer

type Layer struct {
	Name string // should be the name of the input

	Strings []string
	Ints    []int

	Hash int // memoization; used to check if a model updated
}

Layer represents an encoding layer and its bound cardinality

func (*Layer) Encode

func (l *Layer) Encode(stream io.Stream)

implements github.com/viant/tapper/io.Encoder

type Pair

type Pair func(key string, value interface{}) error

Pair represents a pair

type Storable

type Storable interface {
	Iterator() Iterator
	Set(iter Iterator) error
}

Storable represents storable interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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