eas

package
v2.4.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default endpoint is the gateway mode
	EndpointTypeDefault = "DEFAULT"
	// Vipserver endpoint is only used for services which registered
	// vipsever domains in alibaba internal clusters
	EndpointTypeVipserver = "VIPSERVER"
	// Direct endpoint is used for direct accessing to the services' instances
	// both inside a eas service and in user's client ecs
	EndpointTypeDirect = "DIRECT"

	// use eas docker to deploy service, but not use pai eas
	EndpointTypeDocker = "DOCKER"
)
View Source
const (
	ErrorCodeServiceDiscovery = 510
	ErrorCodeCreateRequest    = 511
	ErrorCodePerformRequest   = 512
	ErrorCodeReadResponse     = 513
)
View Source
const (
	HeaderRequestId     = "X-Eas-Queueservice-Request-Id"
	HeaderAuthorization = "Authorization"

	DefaultGroupName = "eas"
)

TfType_DT_INVALID and listed types use ALL_CAPS names here to consist with other language's sdk.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoint

type Endpoint interface {
	Sync()
	TryNext(addr string) string
}

type PredictClient

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

PredictClient for accessing prediction service by creating a fixed size connection pool to perform the request through established persistent connections.

func NewPredictClient

func NewPredictClient(endpointName string, serviceName string) *PredictClient

NewPredictClient returns an instance of PredictClient

func (*PredictClient) AddHeader

func (p *PredictClient) AddHeader(headerName, headerValue string)

func (*PredictClient) BytesPredict

func (p *PredictClient) BytesPredict(requestData []byte) ([]byte, error)

BytesPredict send the raw request data in byte array through http connections, retry the request automatically when an error occurs

func (*PredictClient) Init

func (p *PredictClient) Init() error

Init initializes the predict client to create and enable endpoint discovery

func (*PredictClient) Predict

func (p *PredictClient) Predict(request Request) (Response, error)

Predict for request

func (*PredictClient) SetEndpoint

func (p *PredictClient) SetEndpoint(endpointName string)

SetEndpoint sets service's endpoint for client

func (*PredictClient) SetEndpointType

func (p *PredictClient) SetEndpointType(endpointType string)

SetEndpointType sets endpoint type for client

func (*PredictClient) SetHost

func (p *PredictClient) SetHost(host string)

func (*PredictClient) SetHttpTransport

func (p *PredictClient) SetHttpTransport(transport *http.Transport)

SetHttpTransport sets http transport argument for go http client

func (*PredictClient) SetRetryCount

func (p *PredictClient) SetRetryCount(cnt int)

SetRetryCount sets max retry count for client

func (*PredictClient) SetServiceName

func (p *PredictClient) SetServiceName(serviceName string)

SetServiceName sets target service name for client

func (*PredictClient) SetTimeout

func (p *PredictClient) SetTimeout(timeout int)

SetTimeout set the request timeout for client, 5000ms by default

func (*PredictClient) SetToken

func (p *PredictClient) SetToken(token string)

SetToken function sets service's access token for client

func (*PredictClient) Shutdown

func (p *PredictClient) Shutdown()

Shutdown after called this client instance should not be used again

func (*PredictClient) StringPredict

func (p *PredictClient) StringPredict(str string) (string, error)

StringPredict function send input data and return predicted result

func (*PredictClient) TFPredict

func (p *PredictClient) TFPredict(request TFRequest) (*TFResponse, error)

TFPredict function send input data and return TensorFlow predicted result

func (*PredictClient) TorchPredict

func (p *PredictClient) TorchPredict(request TorchRequest) (*TorchResponse, error)

TorchPredict function send input data and return PyTorch predicted result

type PredictError

type PredictError struct {
	Code       int
	Message    string
	RequestURL string
}

PredictError is a custom err type

func NewPredictError

func NewPredictError(code int, url string, msg string) *PredictError

NewPredictError constructs an error

func (*PredictError) Error

func (err *PredictError) Error() string

Error for error interface

type QueueClient

type QueueClient struct {
	WebsocketWatch bool

	// codecs for data frame and attributes.
	DCodec types.DataFrameCodec
	ACodec types.AttributesCodec
	// contains filtered or unexported fields
}

QueueClient is client of queue server, which also implements queue service interface

func NewQueueClient

func NewQueueClient(endpoint, queueName, token string) (*QueueClient, error)

func (*QueueClient) Attributes

func (q *QueueClient) Attributes() (types.Attributes, error)

func (*QueueClient) Commit

func (q *QueueClient) Commit(ctx context.Context, indexes ...uint64) error

func (*QueueClient) Del

func (q *QueueClient) Del(ctx context.Context, indexes ...uint64) error

func (*QueueClient) End

func (q *QueueClient) End(ctx context.Context, force bool) error

func (*QueueClient) Get

func (q *QueueClient) Get(ctx context.Context, index uint64, length int, timeout time.Duration, autoDelete bool, tags types.Tags) (dfs []types.DataFrame, err error)

func (*QueueClient) GetByIndex

func (q *QueueClient) GetByIndex(ctx context.Context, index uint64) (dfs []types.DataFrame, err error)

func (*QueueClient) GetByRequestId

func (q *QueueClient) GetByRequestId(ctx context.Context, requestId string) (dfs []types.DataFrame, err error)

func (*QueueClient) Put

func (q *QueueClient) Put(ctx context.Context, data []byte, tags types.Tags) (index uint64, requestId string, err error)

func (*QueueClient) Truncate

func (q *QueueClient) Truncate(ctx context.Context, index uint64) error

func (*QueueClient) Watch

func (q *QueueClient) Watch(ctx context.Context, index, window uint64, indexOnly bool, autocommit bool) (types.Watcher, error)

type QueueUser

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

func NewQueueUser

func NewQueueUser(uid, gid, token string) QueueUser

func (QueueUser) Gid

func (c QueueUser) Gid() string

func (QueueUser) Token

func (c QueueUser) Token() string

func (QueueUser) Uid

func (c QueueUser) Uid() string

type Request

type Request interface {
	ToString() (string, error)
}

type Response

type Response interface {
	// contains filtered or unexported methods
}

type TFRequest

type TFRequest struct {
	RequestData tf_predict_protos.PredictRequest
}

TFRequest class for tensorflow data and requests

func (*TFRequest) AddFeedBool

func (tr *TFRequest) AddFeedBool(inputName string, shape []int64, content []bool)

AddFeedBool function adds boolean values input data for TFRequest

func (*TFRequest) AddFeedFloat32

func (tr *TFRequest) AddFeedFloat32(inputName string, shape []int64, content []float32)

AddFeedFloat32 function adds float values input data for TFRequest

func (*TFRequest) AddFeedFloat64

func (tr *TFRequest) AddFeedFloat64(inputName string, shape []int64, content []float64)

AddFeedFloat64 function adds double values input data for TFRequest

func (*TFRequest) AddFeedInt32

func (tr *TFRequest) AddFeedInt32(inputName string, shape []int64, content []int32)

AddFeedInt32 function adds int values input data for TFRequest

func (*TFRequest) AddFeedInt64

func (tr *TFRequest) AddFeedInt64(inputName string, shape []int64, content []int64)

AddFeedInt64 function adds int64 values input data for TFRequest

func (*TFRequest) AddFeedString

func (tr *TFRequest) AddFeedString(inputName string, shape []int64, content [][]byte)

AddFeedString function adds string values input data for TFRequest

func (*TFRequest) AddFetch

func (tr *TFRequest) AddFetch(outName string)

AddFetch adds output filter (outname) for TensorFlow request

func (*TFRequest) SetSignatureName

func (tr *TFRequest) SetSignatureName(sigName string)

SetSignatureName set signature name for TensorFlow request

func (TFRequest) ToString

func (tr TFRequest) ToString() (string, error)

ToString for interface

type TFResponse

type TFResponse struct {
	Response tf_predict_protos.PredictResponse
}

TFResponse class for Pytf predicted results

func (*TFResponse) GetBoolVal

func (tresp *TFResponse) GetBoolVal(outputName string) []bool

GetBoolVal returns []bool slice as output data

func (*TFResponse) GetDoubleVal

func (tresp *TFResponse) GetDoubleVal(outputName string) []float64

GetDoubleVal returns []float64 slice as output data

func (*TFResponse) GetFloatVal

func (tresp *TFResponse) GetFloatVal(outputName string) []float32

GetFloatVal returns []float32 slice as output data

func (*TFResponse) GetInt64Val

func (tresp *TFResponse) GetInt64Val(outputName string) []int64

GetInt64Val returns []int64 slice as output data

func (*TFResponse) GetIntVal

func (tresp *TFResponse) GetIntVal(outputName string) []int32

GetIntVal returns []int32 slice as output data

func (*TFResponse) GetStringVal

func (tresp *TFResponse) GetStringVal(outputName string) [][]byte

GetStringVal returns []string slice as output data

func (*TFResponse) GetTensorShape

func (tresp *TFResponse) GetTensorShape(outputName string) []int64

GetTensorShape returns []int64 slice as shape of tensor outindexed

type TorchRequest

type TorchRequest struct {
	RequestData torch_predict_protos.PredictRequest
}

TorchRequest class for PyTorch data and requests

func (*TorchRequest) AddFeedFloat32

func (tr *TorchRequest) AddFeedFloat32(index int, shape []int64, content []float32)

AddFeedFloat32 function adds float values input data for torchrequest

func (*TorchRequest) AddFeedFloat64

func (tr *TorchRequest) AddFeedFloat64(index int, shape []int64, content []float64)

AddFeedFloat64 function adds double values input data for torchrequest

func (*TorchRequest) AddFeedInt32

func (tr *TorchRequest) AddFeedInt32(index int, shape []int64, content []int32)

AddFeedInt32 function adds int values input data for torchrequest

func (*TorchRequest) AddFeedInt64

func (tr *TorchRequest) AddFeedInt64(index int, shape []int64, content []int64)

AddFeedInt64 function adds int64 values input data for torchrequest

func (*TorchRequest) AddFetch

func (tr *TorchRequest) AddFetch(outIndex int32)

AddFetch add OutputFilter (outIndex) for response

func (TorchRequest) ToString

func (tr TorchRequest) ToString() (string, error)

ToString for interface

type TorchResponse

type TorchResponse struct {
	Response torch_predict_protos.PredictResponse
}

TorchResponse class for PyTorch predicted results

func (*TorchResponse) GetDoubleVal

func (resp *TorchResponse) GetDoubleVal(outIndex int) []float64

GetDoubleVal returns []float64 slice as output data

func (*TorchResponse) GetFloatVal

func (resp *TorchResponse) GetFloatVal(outIndex int) []float32

GetFloatVal returns []float32 slice as output data

func (*TorchResponse) GetInt64Val

func (resp *TorchResponse) GetInt64Val(outIndex int) []int64

GetInt64Val returns []int64 slice as output data

func (*TorchResponse) GetIntVal

func (resp *TorchResponse) GetIntVal(outIndex int) []int32

GetIntVal returns []int32 slice as output data

func (*TorchResponse) GetTensorShape

func (resp *TorchResponse) GetTensorShape(outIndex int) []int64

GetTensorShape returns []int64 slice as shape of tensor outindexed

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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