client

package
v0.0.0-...-85902bd Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CacheScopeLocal = CacheScope(1)
	CacheScopeL1    = CacheScope(2)
	CacheScopeL2    = CacheScope(4)
)

Variables

This section is empty.

Functions

func NewReader

func NewReader(data interface{}) ([]byte, error)

NewReader creates a new data reader

Types

type Cachable

type Cachable interface {
	CacheKey() string
}

Cachable returns a cacheable key

type CacheScope

type CacheScope int

func (CacheScope) IsL1

func (c CacheScope) IsL1() bool

func (CacheScope) IsL2

func (c CacheScope) IsL2() bool

func (CacheScope) IsLocal

func (c CacheScope) IsLocal() bool

type Config

type Config struct {
	Hosts       []*Host
	Model       string
	CacheSizeMb int
	CacheScope  *CacheScope
	Datastore   *config.Datastore
	MaxRetry    int
}

Config represents a client config

func (*Config) CacheSize

func (c *Config) CacheSize() int

CacheSize returns cache size

type Host

type Host struct {
	Name string
	Port int
}

Host represents endpoint host

func NewHost

func NewHost(name string, port int) *Host

NewHost returns new host

func NewHosts

func NewHosts(port int, names []string) []*Host

NewHosts creates hosts

type Message

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

Message represents a message

func (*Message) BoolKey

func (m *Message) BoolKey(key string, value bool)

BoolKey sets key/value pair

func (*Message) Bytes

func (m *Message) Bytes() []byte

Bytes returns message bytes

func (*Message) CacheKey

func (m *Message) CacheKey() string

CacheKey returns cache key

func (*Message) FloatKey

func (m *Message) FloatKey(key string, value float32)

FloatKey sets key/value pair

func (*Message) FloatsKey

func (m *Message) FloatsKey(key string, values []float32)

FloatsKey sets key/values pair

func (*Message) IntKey

func (m *Message) IntKey(key string, value int)

IntKey sets key/value pair

func (*Message) IntsKey

func (m *Message) IntsKey(key string, values []int)

IntsKey sets key/values pair

func (*Message) Release

func (m *Message) Release()

Release releases message to the pool

func (*Message) Size

func (m *Message) Size() int

Size returns message size

func (*Message) StringKey

func (m *Message) StringKey(key, value string)

StringKey sets key/value pair

func (*Message) StringsKey

func (m *Message) StringsKey(key string, values []string)

StringsKey sets key/values pair

type Messages

type Messages interface {
	Borrow() *Message
}

Messages represent a message

type Option

type Option interface {
	Apply(c *Service)
}

Option client option

func NewCacheScope

func NewCacheScope(scope CacheScope) Option

NewCacheScope returns cache scope

func NewCacheSize

func NewCacheSize(sizeMB int) Option

NewCacheSize returns cache size MB

func NewGmetric

func NewGmetric(gmetrics *gmetric.Service) Option

NewGmetric returns gmetric options

type Releaser

type Releaser interface {
	Release()
}

Releaser releaser

type Response

type Response struct {
	Status      string        `json:"status"`
	Error       string        `json:"error,omitempty"`
	ServiceTime time.Duration `json:"serviceTime"`
	DictHash    int           `json:"dictHash"`
	Data        interface{}   `json:"data"`
}

Response represents a response

func NewResponse

func NewResponse(data interface{}) *Response

NewResponse creates a new response

func (*Response) NKeys

func (r *Response) NKeys() int

NKeys returns object keys JSON (gojay API)

func (*Response) UnmarshalJSONObject

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

UnmarshalJSONObject unmsrhal JSON (gojay API)

type Service

type Service struct {
	Config
	sync.RWMutex
	// contains filtered or unexported fields
}

Service represent mly client

func New

func New(model string, hosts []*Host, options ...Option) (*Service, error)

New creates new mly client

func (*Service) Close

func (s *Service) Close() error

Close closes the service

func (*Service) NewMessage

func (s *Service) NewMessage() *Message

NewMessage returns a new message

func (*Service) Run

func (s *Service) Run(ctx context.Context, input interface{}, response *Response) error

Run run model prediction

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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