core

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2023 License: Apache-2.0 Imports: 22 Imported by: 6

Documentation

Index

Constants

View Source
const (
	MaxWriteItemCount = 2000

	MaxImportItemCount = 10000

	// StatusCodeSuccess The request was executed successfully without any exception
	StatusCodeSuccess = 0

	// StatusCodeIdempotent A Request with the same "Request-ID" was already received. This Request was rejected
	StatusCodeIdempotent = 409

	// StatusCodeOperationLoss Operation information is missing due to an unknown exception
	StatusCodeOperationLoss = 410

	// StatusCodeTooManyRequest The server hope slow down request frequency, and this request was rejected
	StatusCodeTooManyRequest = 429
)

Variables

This section is empty.

Functions

func AsyncExecute

func AsyncExecute(runnable func())

func IsNetError

func IsNetError(err error) bool

func IsTimeoutError

func IsTimeoutError(err error) bool

func VolcSign

func VolcSign(req *fasthttp.Request, cred Credential) *fasthttp.Request

Types

type Context

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

func NewContext

func NewContext(param *ContextParam) (*Context, error)

func (*Context) AK

func (receiver *Context) AK() string

func (*Context) CustomerHeaders

func (receiver *Context) CustomerHeaders() map[string]string

func (*Context) HostAvailablerConfig added in v0.1.16

func (receiver *Context) HostAvailablerConfig() *HostAvailablerConfig

func (*Context) HostHeader

func (receiver *Context) HostHeader() string

func (*Context) Hosts

func (receiver *Context) Hosts() []string

func (*Context) MetricsConfig added in v0.1.16

func (receiver *Context) MetricsConfig() *metrics.Config

func (*Context) SK

func (receiver *Context) SK() string

func (*Context) Schema

func (receiver *Context) Schema() string

func (*Context) Tenant

func (receiver *Context) Tenant() string

func (*Context) TenantId

func (receiver *Context) TenantId() string

func (*Context) Token

func (receiver *Context) Token() string

func (*Context) UseAirAuth

func (receiver *Context) UseAirAuth() bool

func (*Context) UseVolcAuth

func (receiver *Context) UseVolcAuth() bool

type ContextParam

type ContextParam struct {
	Tenant               string
	TenantId             string
	Token                string
	AK                   string
	SK                   string
	Schema               string
	HostHeader           string
	Hosts                []string
	Headers              map[string]string
	Region               Region
	UseAirAuth           bool
	MetricsConfig        *metrics.Config
	HostAvailablerConfig *HostAvailablerConfig
}

type Credential

type Credential struct {
	AccessKeyID     string
	SecretAccessKey string
	Region          string
	Service         string
	SessionToken    string
}

type HTTPCaller added in v0.1.10

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

func NewHTTPCaller added in v0.1.10

func NewHTTPCaller(context *Context) *HTTPCaller

func (*HTTPCaller) DoJSONRequest added in v0.1.10

func (c *HTTPCaller) DoJSONRequest(url string, request interface{},
	response proto.Message, options *option.Options) error

func (*HTTPCaller) DoPBRequest added in v0.1.10

func (c *HTTPCaller) DoPBRequest(url string, request proto.Message,
	response proto.Message, options *option.Options) error

type HostAvailabler

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

func NewHostAvailabler

func NewHostAvailabler(urlCenter URLCenter, context *Context) *HostAvailabler

func (*HostAvailabler) GetHost added in v0.1.16

func (receiver *HostAvailabler) GetHost() string

func (*HostAvailabler) Shutdown

func (receiver *HostAvailabler) Shutdown()

type HostAvailablerConfig added in v0.1.16

type HostAvailablerConfig struct {
	// host availabler used to test the latency, example {}://%s/predict/api/ping
	// {} will be replaced by schema which set in context
	// %s will be dynamically formatted by hosts
	PingUrlFormat string
	// record the window size of each host's test status
	WindowSize int
	// timeout for requesting hosts
	PingTimeout time.Duration
	// The time interval for pingHostAvailabler to do ping
	PingInterval time.Duration
}

type Region

type Region int
const (
	RegionUnknown Region = iota
	RegionCn
	RegionSg
	RegionUs
	RegionSaasSg
)

type URLCenter

type URLCenter interface {
	Refresh(host string)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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