core

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 26 Imported by: 28

Documentation

Overview

Package core is motan-go base package. contains base struct, interface and default implement.

Index

Constants

View Source
const (
	FrameworkException = iota
	// ServiceException : exception by service call
	ServiceException
	// BizException : exception by service implements
	BizException
)

--------------all global public constants-------------- exception type

View Source
const (
	// EndPointFilterType filter for endpoint
	EndPointFilterType = iota
	// ClusterFilterType filter for cluster
	ClusterFilterType
)

filter type

View Source
const (
	NodeTypeKey             = "nodeType"
	Hakey                   = "haStrategy"
	Lbkey                   = "loadbalance"
	TimeOutKey              = "requestTimeout"
	MinTimeOutKey           = "minRequestTimeout"
	MaxTimeOutKey           = "maxRequestTimeout"
	SessionTimeOutKey       = "registrySessionTimeout"
	RetriesKey              = "retries"
	ApplicationKey          = "application"
	VersionKey              = "version"
	FilterKey               = "filter"
	GlobalFilter            = "globalFilter"
	DisableGlobalFilter     = "disableGlobalFilter"
	DefaultFilter           = "defaultFilter"
	DisableDefaultFilter    = "disableDefaultFilter"
	MotanEpAsyncInit        = "motanEpAsyncInit"
	RegistryKey             = "registry"
	WeightKey               = "weight"
	SerializationKey        = "serialization"
	RefKey                  = "ref"
	ExportKey               = "export"
	ModuleKey               = "module"
	GroupKey                = "group"
	ProviderKey             = "provider"
	ProxyKey                = "proxy"
	AddressKey              = "address"
	GzipSizeKey             = "mingzSize"
	HostKey                 = "host"
	RemoteIPKey             = "remoteIP"
	ProxyRegistryKey        = "proxyRegistry"
	ProxyRegistryUrlString  = "proxyRegistryUrlString"
	InitClusterTimeoutKey   = "initClusterTimeout"
	ConnectTimeoutKey       = "connectTimeout"
	ConnectRetryIntervalKey = "connectRetryInterval"
	ClientConnectionKey     = "clientConnection"
	LazyInit                = "lazyInit"
	AsyncInitConnection     = "asyncInitConnection"
	ErrorCountThresholdKey  = "errorCountThreshold"
	KeepaliveIntervalKey    = "keepaliveInterval"
	UnixSockKey             = "unixSock"
	ManagementUnixSockKey   = "managementUnixSock"
	ManagementPortRangeKey  = "managementPortRange"
	HTTPProxyUnixSockKey    = "httpProxyUnixSock"
	MixGroups               = "mixGroups"
	MaxContentLength        = "maxContentLength"
	UnixSockProtocolFlag    = "unix://"
)

common url parameter key

View Source
const (
	XForwardedForLower = "x-forwarded-for" // used as motan default proxy key
	XForwardedFor      = "X-Forwarded-For"
	ConsistentHashKey  = "consistentHashKey" //string used to calculate consistent hash
)

attachment keys

View Source
const (
	RegisterSuccess   = "register-success"
	RegisterFailed    = "register-failed"
	UnregisterSuccess = "unregister-success"
	UnregisterFailed  = "unregister-failed"
	NotRegister       = "not-register"
)

registryStatus

View Source
const (
	NodeTypeService = "service"
	NodeTypeReferer = "referer"
	NodeTypeAgent   = "agent"
)

nodeType

View Source
const (
	Receive       = "receive"
	Decode        = "decode"
	Convert       = "convert"
	ClFilter      = "clusterFilter"
	EpFilterStart = "selectEndpoint"
	EpFilterEnd   = "endpointFilter"
	Encode        = "encode"
	Send          = "send"
)

trace span name

View Source
const (
	DefaultWriteTimeout     = 5 * time.Second
	DefaultMaxContentLength = 10 * 1024 * 1024
	GroupNameSeparator      = ","
)
View Source
const (
	GroupEnvironmentName     = "MESH_SERVICE_ADDITIONAL_GROUP"
	DirectRPCEnvironmentName = "MESH_DIRECT_RPC"
	FilterEnvironmentName    = "MESH_FILTERS"
	HandlerEnvironmentName   = "MESH_ADMIN_EXT_HANDLERS"
	RegGroupSuffix           = "RPC_REG_GROUP_SUFFIX"
	SubGroupSuffix           = "MESH_MULTI_SUB_GROUP_SUFFIX"
)

env variables

View Source
const (
	ENoEndpoints      = 1001
	ENoChannel        = 1002
	EUnkonwnMsg       = 1003
	EConvertMsg       = 1004
	EProviderNotExist = 404
)

errorCodes

View Source
const (
	DefaultMetaPrefix            = "META_"
	EnvMetaPrefixKey             = "envMetaPrefix"
	URLRegisterMeta              = "registerMeta"
	DefaultRegisterMeta          = false
	MetaCacheExpireSecondKey     = "metaCacheExpireSecond"
	DynamicMetaKey               = "dynamicMeta"
	DefaultDynamicMeta           = true
	WeightRefreshPeriodSecondKey = "weightRefreshPeriodSecond"
	WeightMetaSuffixKey          = "WEIGHT"
	ServiceNotSupport            = "service not support"
)

meta info

View Source
const (
	RuntimeInstanceTypeKey     = "instanceType"
	RuntimeExportersKey        = "exporters"
	RuntimeClustersKey         = "clusters"
	RuntimeHttpClustersKey     = "httpClusters"
	RuntimeExtensionFactoryKey = "extensionFactory"
	RuntimeServersKey          = "servers"
	RuntimeBasicKey            = "basic"

	RuntimeUrlKey            = "url"
	RuntimeIsAvailableKey    = "isAvailable"
	RuntimeProxyKey          = "proxy"
	RuntimeAvailableKey      = "available"
	RuntimeEndpointKey       = "endpoint"
	RuntimeFiltersKey        = "filters"
	RuntimeClusterFiltersKey = "clusterFilters"
	RuntimeNameKey           = "name"
	RuntimeIndexKey          = "index"
	RuntimeTypeKey           = "type"

	RuntimeProviderKey = "provider"

	RuntimeAgentServerKey        = "agentServer"
	RuntimeAgentPortServerKey    = "agentPortServer"
	RuntimeMaxContentLengthKey   = "maxContentLength"
	RuntimeHeartbeatEnabledKey   = "heartbeatEnabled"
	RuntimeMessageHandlerKey     = "messageHandler"
	RuntimeProvidersKey          = "providers"
	RuntimeMessageHandlerTypeKey = "messageHandlerType"

	RuntimeHttpProxyServerKey = "httpProxyServer"
	RuntimeDenyKey            = "deny"
	RuntimeKeepaliveKey       = "keepalive"
	RuntimeDefaultDomainKey   = "defaultDomain"

	RuntimeReferersKey    = "referers"
	RuntimeRefererSizeKey = "refererSize"
	RuntimeUnavailableKey = "unavailable"

	RuntimeErrorCountKey       = "errorCount"
	RuntimeKeepaliveRunningKey = "keepaliveRunning"
	RuntimeKeepaliveTypeKey    = "keepaliveType"

	RuntimeRegistriesKey = "registries"

	RuntimeRegisteredServiceUrlsKey = "registeredServiceUrls"
	RuntimeSubscribedServiceUrlsKey = "subscribedServiceUrls"
	RuntimeFailedRegisterUrls       = "failedRegisterUrls"
	RuntimeFailedUnregisterUrls     = "failedUnregisterUrls"
	RuntimeFailedSubscribeUrls      = "failedSubscribeUrls"
	RuntimeFailedUnsubScribeUrls    = "failedUnsubscribeUrls"
	RuntimeSubscribeInfoKey         = "subscribeInfo"
	RuntimeAgentCommandKey          = "agentCommand"
	RuntimeServiceCommandKey        = "serviceCommand"
	RuntimeStaticCommandKey         = "staticCommand"
	RuntimeWeightKey                = "weight"
	RuntimeCommandHistoryKey        = "commandHistory"
	RuntimeNotifyHistoryKey         = "notifyHistory"

	RuntimeCpuPercentKey = "cpuPercent"
	RuntimeRssMemoryKey  = "rssMemory"
)
View Source
const (
	SwitcherSection = "switcher"

	// URLConfKey is config id
	// config Keys
	URLConfKey = "conf-id"
)
View Source
const (
	DefaultAttachmentSize = 16
	ProtocolLocal         = "local"
)
View Source
const (
	DefaultReferVersion = "1.0"
)
View Source
const (
	MetaUpstreamCode = "upstreamCode"
)

meta keys

View Source
const (
	MetricsReqApplication = "metricsReqApp"
)

metrics request application

View Source
const (
	ProviderNotExistPrefix = "provider not exist serviceKey="
)

ProviderNotExistPrefix errorMessage

Variables

View Source
var (
	// TracePolicy is trace policy for mesh request, this func is called by each request, trace will enable if this func return a TraceContext
	TracePolicy TracePolicyFunc = NoTrace

	// RandomTraceBase is random base for RandomTrace
	RandomTraceBase        = 10
	MaxTraceSize    uint64 = 10000
)
View Source
var (
	Port        = flag.Int("port", 0, "agent listen port")
	Eport       = flag.Int("eport", 0, "agent export service port when as a reverse proxy server")
	Hport       = flag.Int("hport", 0, "http forward proxy server port")
	Mport       = flag.Int("mport", 0, "agent manage port")
	Pidfile     = flag.String("pidfile", "", "agent manage port")
	CfgFile     = flag.String("c", "", "motan run conf")
	LocalIP     = flag.String("localIP", "", "local ip for motan register")
	IDC         = flag.String("idc", "", "the idc info for agent or client.")
	Pool        = flag.String("pool", "", "application pool config. like 'application-idc-level'")
	Application = flag.String("application", "", "assist for application pool config.")
	Recover     = flag.Bool("recover", false, "recover from accidental exit")
)

all env flag in motan-go

View Source
var ErrNotEnough = errors.New("BytesBuffer: not enough bytes")
View Source
var ErrOverflow = errors.New("BytesBuffer: integer overflow")
View Source
var (
	PanicStatFunc func()
)

Functions

func AddRelevantFilter added in v1.1.0

func AddRelevantFilter(filterStr string)

func ByteSliceShuffle added in v1.2.0

func ByteSliceShuffle(slice []byte) []byte

func CanSetContext

func CanSetContext(s interface{}, context *Context)

CanSetContext :CanSetContext

func ClearDirectEnvRegistry added in v1.1.0

func ClearDirectEnvRegistry()

ClearDirectEnvRegistry is only for unit test

func FirstUpper

func FirstUpper(s string) string

func GetAllGroups

func GetAllGroups(gr GroupDiscoverableRegistry) []string

func GetApplication added in v1.2.0

func GetApplication() string

func GetEPFilterInfo added in v1.1.0

func GetEPFilterInfo(filter EndPointFilter) string

func GetLocalIP

func GetLocalIP() string

GetLocalIP flag of localIP > ip net

func GetLocalIPs

func GetLocalIPs() []string

GetLocalIPs ip from ip net

func GetMport added in v1.2.0

func GetMport() int

func GetNonNegative added in v1.2.0

func GetNonNegative(originValue int64) int64

func GetRelevantFilters added in v1.1.0

func GetRelevantFilters() map[string]bool

func GetReqInfo

func GetReqInfo(request Request) string

func GetResInfo added in v1.1.0

func GetResInfo(response Response) string

func GetRuntimeInfo added in v1.2.0

func GetRuntimeInfo(s interface{}) map[string]interface{}

GetRuntimeInfo : call s.GetRuntimeInfo

func GetURLFilters

func GetURLFilters(url *URL, extFactory ExtensionFactory) (clusterFilter ClusterFilter, endpointFilters []Filter)

func HandlePanic

func HandlePanic(f func())

func Initialize

func Initialize(s interface{})

Initialize : Initialize if implement Initializable

func InterfaceToString

func InterfaceToString(in interface{}) string

func IsSame

func IsSame(m1 map[string]string, m2 map[string]string, key string, defaultValue string) bool

func ListenUnixSock

func ListenUnixSock(unixSockAddr string) (net.Listener, error)

ListenUnixSock try to listen a unix socket address this method using by create motan agent server, management server and http proxy server

func ParseExportInfo

func ParseExportInfo(export string) (string, int, error)

func RegistLocalProvider

func RegistLocalProvider(service string, provider Provider)

func ReleaseBytesBuffer added in v1.1.0

func ReleaseBytesBuffer(b *BytesBuffer)

ReleaseBytesBuffer put the BytesBuffer to bytesBufferPool

func ReleaseMotanRequest added in v1.1.0

func ReleaseMotanRequest(req *MotanRequest)

func ReleaseMotanResponse added in v1.1.0

func ReleaseMotanResponse(m *MotanResponse)

func ServiceInGroup

func ServiceInGroup(sr ServiceDiscoverableRegistry, group string, service string) bool

func SetApplication added in v1.2.0

func SetApplication(v string)

func SetMport added in v1.2.0

func SetMport(v int)

func SliceShuffle

func SliceShuffle(slice []string) []string

func SlicesUnique added in v1.1.0

func SlicesUnique(src []string) []string

SlicesUnique deduplicate the values of the slice

func TrimSplit

func TrimSplit(s string, sep string) []string

TrimSplit slices s into all substrings separated by sep and returns a slice of the substrings between those separators, specially trim all substrings.

func TrimSplitSet added in v1.1.0

func TrimSplitSet(s string, sep string) map[string]bool

TrimSplitSet slices string and convert to map set

Types

type AsyncResult

type AsyncResult struct {
	Done  chan *AsyncResult
	Error error
}

AsyncResult : async call result

type AtomicString

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

func NewAtomicString

func NewAtomicString(str string) *AtomicString

func (*AtomicString) Load

func (s *AtomicString) Load() string

func (*AtomicString) Store

func (s *AtomicString) Store(str string)

type Attachment

type Attachment interface {
	GetAttachments() *StringMap
	GetAttachment(key string) string
	SetAttachment(key string, value string)
}

Attachment : can get, set attachments.

type BytesBuffer

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

BytesBuffer is a variable-sized buffer of bytes with Read and Write methods. BytesBuffer is not thread safe for multi goroutine operation.

func AcquireBytesBuffer added in v1.1.0

func AcquireBytesBuffer(initSize int) *BytesBuffer

AcquireBytesBuffer create an empty BytesBuffer with initial size and byte order from bytesBufferPool

func CreateBytesBuffer

func CreateBytesBuffer(data []byte) *BytesBuffer

CreateBytesBuffer create a BytesBuffer from data bytes

func CreateBytesBufferWithOrder

func CreateBytesBufferWithOrder(data []byte, order binary.ByteOrder) *BytesBuffer

CreateBytesBufferWithOrder create a BytesBuffer from data bytes with bytes order

func NewBytesBuffer

func NewBytesBuffer(initsize int) *BytesBuffer

NewBytesBuffer create an empty BytesBuffer with initial size

func NewBytesBufferWithOrder

func NewBytesBufferWithOrder(initsize int, order binary.ByteOrder) *BytesBuffer

NewBytesBufferWithOrder create an empty BytesBuffer with initial size and byte order

func (*BytesBuffer) Bytes

func (b *BytesBuffer) Bytes() []byte

func (*BytesBuffer) Cap

func (b *BytesBuffer) Cap() int

func (*BytesBuffer) GetRPos

func (b *BytesBuffer) GetRPos() int

GetRPos get the read position of BytesBuffer

func (*BytesBuffer) GetWPos

func (b *BytesBuffer) GetWPos() int

GetWPos get the write position of BytesBuffer

func (*BytesBuffer) Len

func (b *BytesBuffer) Len() int

func (*BytesBuffer) Next

func (b *BytesBuffer) Next(n int) ([]byte, error)

func (*BytesBuffer) Read

func (b *BytesBuffer) Read(p []byte) (n int, err error)

func (*BytesBuffer) ReadByte

func (b *BytesBuffer) ReadByte() (byte, error)

func (*BytesBuffer) ReadFull

func (b *BytesBuffer) ReadFull(p []byte) error

func (*BytesBuffer) ReadInt

func (b *BytesBuffer) ReadInt() (int, error)

ReadInt read next int32

func (*BytesBuffer) ReadUint16

func (b *BytesBuffer) ReadUint16() (n uint16, err error)

func (*BytesBuffer) ReadUint32

func (b *BytesBuffer) ReadUint32() (n uint32, err error)

func (*BytesBuffer) ReadUint64

func (b *BytesBuffer) ReadUint64() (n uint64, err error)

func (*BytesBuffer) ReadVarint

func (b *BytesBuffer) ReadVarint() (x uint64, err error)

func (*BytesBuffer) ReadZigzag32

func (b *BytesBuffer) ReadZigzag32() (x uint64, err error)

func (*BytesBuffer) ReadZigzag64

func (b *BytesBuffer) ReadZigzag64() (x uint64, err error)

func (*BytesBuffer) Remain

func (b *BytesBuffer) Remain() int

func (*BytesBuffer) Reset

func (b *BytesBuffer) Reset()

func (*BytesBuffer) SetRPos

func (b *BytesBuffer) SetRPos(pos int)

SetRPos get the read position of BytesBuffer

func (*BytesBuffer) SetWPos

func (b *BytesBuffer) SetWPos(pos int)

SetWPos set the write position of BytesBuffer

func (*BytesBuffer) Write

func (b *BytesBuffer) Write(bytes []byte)

Write write a byte array append the BytesBuffer, and the wpos will increase len(bytes)

func (*BytesBuffer) WriteByte

func (b *BytesBuffer) WriteByte(c byte)

WriteByte write a byte append the BytesBuffer, the wpos will increase one

func (*BytesBuffer) WriteString added in v1.1.0

func (b *BytesBuffer) WriteString(str string)

WriteString write a str string append the BytesBuffer, and the wpos will increase len(str)

func (*BytesBuffer) WriteUint16

func (b *BytesBuffer) WriteUint16(u uint16)

WriteUint16 write a uint16 append the BytesBuffer acording to buffer's order

func (*BytesBuffer) WriteUint32

func (b *BytesBuffer) WriteUint32(u uint32)

func (*BytesBuffer) WriteUint64

func (b *BytesBuffer) WriteUint64(u uint64)

func (*BytesBuffer) WriteVarint

func (b *BytesBuffer) WriteVarint(u uint64) int

func (*BytesBuffer) WriteZigzag32

func (b *BytesBuffer) WriteZigzag32(u uint32) int

func (*BytesBuffer) WriteZigzag64

func (b *BytesBuffer) WriteZigzag64(u uint64) int

type Caller

type Caller interface {
	RuntimeInfo
	WithURL
	Status
	Call(request Request) Response
	Destroyable
}

Caller : can process a motan request. the call maybe process from remote by endpoint, maybe process by some kinds of provider

type CircularRecorder added in v1.2.0

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

func NewCircularRecorder added in v1.2.0

func NewCircularRecorder(size int) *CircularRecorder

func (*CircularRecorder) AddRecord added in v1.2.0

func (c *CircularRecorder) AddRecord(item interface{})

func (*CircularRecorder) GetRecords added in v1.2.0

func (c *CircularRecorder) GetRecords() map[string]interface{}

type Cloneable

type Cloneable interface {
	Clone() interface{}
}

Cloneable : can clone itself, the return type interface{} must be the type which implement this interface

type ClusterFilter

type ClusterFilter interface {
	Filter
	SetNext(nextFilter ClusterFilter)
	GetNext() ClusterFilter
	//Filter for Cluster
	Filter(haStrategy HaStrategy, loadBalance LoadBalance, request Request) Response
}

ClusterFilter : filter for cluster

func GetLastClusterFilter

func GetLastClusterFilter() ClusterFilter

type CommandNotifyListener

type CommandNotifyListener interface {
	Identity
	NotifyCommand(registryURL *URL, commandType int, commandInfo string)
}

CommandNotifyListener : support command notify

type Context

type Context struct {
	ConfigFile       string
	Config           *cfg.Config
	RegistryURLs     map[string]*URL
	RefersURLs       map[string]*URL
	HTTPClientURLs   map[string]*URL
	BasicReferURLs   map[string]*URL
	ServiceURLs      map[string]*URL
	BasicServiceURLs map[string]*URL
	AgentURL         *URL
	ClientURL        *URL
	ServerURL        *URL
	// contains filtered or unexported fields
}

Context for agent, client, server. context is created depends on config file

func NewContext

func NewContext(configFile string, application string, pool string) *Context

func NewContextFromConfig

func NewContextFromConfig(conf *cfg.Config, application string, pool string) *Context

func (*Context) FilterSetToStr added in v1.1.0

func (c *Context) FilterSetToStr(f map[string]bool) string

func (*Context) GetDefaultFilterSet added in v1.1.0

func (c *Context) GetDefaultFilterSet(newURL *URL) map[string]bool

func (*Context) GetEnvGlobalFilterSet added in v1.1.0

func (c *Context) GetEnvGlobalFilterSet() map[string]bool

func (*Context) GetFilterSet added in v1.1.0

func (c *Context) GetFilterSet(filterStr, disableFilterStr string) (dst map[string]bool)

func (*Context) GetGlobalFilterSet added in v1.1.0

func (c *Context) GetGlobalFilterSet(newURL *URL) map[string]bool

func (*Context) Initialize

func (c *Context) Initialize()

func (*Context) MergeFilterSet added in v1.1.0

func (c *Context) MergeFilterSet(sets ...map[string]bool) (dst map[string]bool)

type CopyOnWriteMap

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

func NewCopyOnWriteMap

func NewCopyOnWriteMap() *CopyOnWriteMap

func (*CopyOnWriteMap) Delete

func (m *CopyOnWriteMap) Delete(key interface{}) (pv interface{})

func (*CopyOnWriteMap) Len

func (m *CopyOnWriteMap) Len() int

func (*CopyOnWriteMap) Load

func (m *CopyOnWriteMap) Load(key interface{}) (interface{}, bool)

func (*CopyOnWriteMap) LoadOrNil

func (m *CopyOnWriteMap) LoadOrNil(key interface{}) interface{}

func (*CopyOnWriteMap) Range

func (m *CopyOnWriteMap) Range(f func(k, v interface{}) bool)

func (*CopyOnWriteMap) SafeDoFunc added in v1.1.0

func (m *CopyOnWriteMap) SafeDoFunc(f func())

func (*CopyOnWriteMap) Store

func (m *CopyOnWriteMap) Store(key, value interface{})

func (*CopyOnWriteMap) Swap

func (m *CopyOnWriteMap) Swap(newMap map[interface{}]interface{}) map[interface{}]interface{}

func (*CopyOnWriteMap) UnsafeStore added in v1.1.0

func (m *CopyOnWriteMap) UnsafeStore(key, value interface{})

type DefaultExtensionFactory

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

func (*DefaultExtensionFactory) GetEndPoint

func (d *DefaultExtensionFactory) GetEndPoint(url *URL) EndPoint

func (*DefaultExtensionFactory) GetFilter

func (d *DefaultExtensionFactory) GetFilter(name string) Filter

func (*DefaultExtensionFactory) GetHa

func (d *DefaultExtensionFactory) GetHa(url *URL) HaStrategy

func (*DefaultExtensionFactory) GetLB

func (d *DefaultExtensionFactory) GetLB(url *URL) LoadBalance

func (*DefaultExtensionFactory) GetMessageHandler

func (d *DefaultExtensionFactory) GetMessageHandler(name string) MessageHandler

func (*DefaultExtensionFactory) GetProvider

func (d *DefaultExtensionFactory) GetProvider(url *URL) Provider

func (*DefaultExtensionFactory) GetRegistry

func (d *DefaultExtensionFactory) GetRegistry(url *URL) Registry

func (*DefaultExtensionFactory) GetRuntimeInfo added in v1.2.0

func (d *DefaultExtensionFactory) GetRuntimeInfo() map[string]interface{}

func (*DefaultExtensionFactory) GetSerialization

func (d *DefaultExtensionFactory) GetSerialization(name string, id int) Serialization

func (*DefaultExtensionFactory) GetServer

func (d *DefaultExtensionFactory) GetServer(url *URL) Server

func (*DefaultExtensionFactory) Initialize

func (d *DefaultExtensionFactory) Initialize()

func (*DefaultExtensionFactory) RegistExtEndpoint

func (d *DefaultExtensionFactory) RegistExtEndpoint(name string, newEndpoint NewEndpointFunc)

func (*DefaultExtensionFactory) RegistExtFilter

func (d *DefaultExtensionFactory) RegistExtFilter(name string, newFilter DefaultFilterFunc)

func (*DefaultExtensionFactory) RegistExtHa

func (d *DefaultExtensionFactory) RegistExtHa(name string, newHa NewHaFunc)

func (*DefaultExtensionFactory) RegistExtLb

func (d *DefaultExtensionFactory) RegistExtLb(name string, newLb NewLbFunc)

func (*DefaultExtensionFactory) RegistExtProvider

func (d *DefaultExtensionFactory) RegistExtProvider(name string, newProvider NewProviderFunc)

func (*DefaultExtensionFactory) RegistExtRegistry

func (d *DefaultExtensionFactory) RegistExtRegistry(name string, newRegistry NewRegistryFunc)

func (*DefaultExtensionFactory) RegistExtServer

func (d *DefaultExtensionFactory) RegistExtServer(name string, newServer NewServerFunc)

func (*DefaultExtensionFactory) RegistryExtMessageHandler

func (d *DefaultExtensionFactory) RegistryExtMessageHandler(name string, newMessage NewMessageHandlerFunc)

func (*DefaultExtensionFactory) RegistryExtSerialization

func (d *DefaultExtensionFactory) RegistryExtSerialization(name string, id int, newSerialization NewSerializationFunc)

type DefaultFilterFunc

type DefaultFilterFunc func() Filter

type DeserializableValue

type DeserializableValue struct {
	Serialization Serialization
	Body          []byte
}

DeserializableValue : for lazy deserialize

func (*DeserializableValue) Deserialize

func (d *DeserializableValue) Deserialize(v interface{}) (interface{}, error)

Deserialize : Deserialize

func (*DeserializableValue) DeserializeMulti

func (d *DeserializableValue) DeserializeMulti(v []interface{}) ([]interface{}, error)

DeserializeMulti : DeserializeMulti

type Destroyable

type Destroyable interface {
	Destroy()
}

Destroyable : can destroy ....

type DiscoverCommand

type DiscoverCommand interface {
	SubscribeCommand(url *URL, listener CommandNotifyListener)
	UnSubscribeCommand(url *URL, listener CommandNotifyListener)
	DiscoverCommand(url *URL) string
}

DiscoverCommand : discover command for client or agent

type DiscoverService

type DiscoverService interface {
	Subscribe(url *URL, listener NotifyListener)

	Unsubscribe(url *URL, listener NotifyListener)

	Discover(url *URL) []*URL
}

DiscoverService : discover service for cluster

type EndPoint

type EndPoint interface {
	Name
	Caller
	SetSerialization(s Serialization)
	SetProxy(proxy bool)
}

EndPoint : can process a remote rpc call

func EndpointShuffle added in v1.2.0

func EndpointShuffle(slice []EndPoint) []EndPoint

type EndPointFilter

type EndPointFilter interface {
	Filter
	SetNext(nextFilter EndPointFilter)
	GetNext() EndPointFilter
	//Filter for endpoint
	Filter(caller Caller, request Request) Response
}

EndPointFilter : filter for endpoint

func GetLastEndPointFilter

func GetLastEndPointFilter() EndPointFilter

type Exception

type Exception struct {
	ErrCode int    `json:"errcode"`
	ErrMsg  string `json:"errmsg"`
	ErrType int    `json:"errtype"`
}

Exception :Exception

type Exporter

type Exporter interface {
	RuntimeInfo
	Export(server Server, extFactory ExtensionFactory, context *Context) error
	Unexport() error
	SetProvider(provider Provider)
	GetProvider() Provider
	Available()
	Unavailable()
	IsAvailable() bool
	WithURL
}

Exporter : export and manage a service. one exporter bind with a service

type ExtensionFactory

type ExtensionFactory interface {
	RuntimeInfo
	GetHa(url *URL) HaStrategy
	GetLB(url *URL) LoadBalance
	GetFilter(name string) Filter
	GetRegistry(url *URL) Registry
	GetEndPoint(url *URL) EndPoint
	GetProvider(url *URL) Provider
	GetServer(url *URL) Server
	GetMessageHandler(name string) MessageHandler
	GetSerialization(name string, id int) Serialization
	RegistExtFilter(name string, newFilter DefaultFilterFunc)
	RegistExtHa(name string, newHa NewHaFunc)
	RegistExtLb(name string, newLb NewLbFunc)
	RegistExtEndpoint(name string, newEndpoint NewEndpointFunc)
	RegistExtProvider(name string, newProvider NewProviderFunc)
	RegistExtRegistry(name string, newRegistry NewRegistryFunc)
	RegistExtServer(name string, newServer NewServerFunc)
	RegistryExtMessageHandler(name string, newMessage NewMessageHandlerFunc)
	RegistryExtSerialization(name string, id int, newSerialization NewSerializationFunc)
}

ExtensionFactory : can regiser and get all kinds of extension implements.

type Filter

type Filter interface {
	RuntimeInfo
	Name
	// filter must be prototype
	NewFilter(url *URL) Filter
	HasNext() bool
	GetIndex() int
	GetType() int32
}

Filter : filter request or response in a call processing

type FilterEndPoint

type FilterEndPoint struct {
	URL           *URL
	Filter        EndPointFilter
	StatusFilters []Status
	Caller        Caller
}

func (*FilterEndPoint) Call

func (f *FilterEndPoint) Call(request Request) Response

func (*FilterEndPoint) Destroy

func (f *FilterEndPoint) Destroy()

func (*FilterEndPoint) GetName

func (f *FilterEndPoint) GetName() string

func (*FilterEndPoint) GetRuntimeInfo added in v1.2.0

func (f *FilterEndPoint) GetRuntimeInfo() map[string]interface{}

func (*FilterEndPoint) GetURL

func (f *FilterEndPoint) GetURL() *URL

func (*FilterEndPoint) IsAvailable

func (f *FilterEndPoint) IsAvailable() bool

func (*FilterEndPoint) SetProxy

func (f *FilterEndPoint) SetProxy(proxy bool)

func (*FilterEndPoint) SetSerialization

func (f *FilterEndPoint) SetSerialization(s Serialization)

func (*FilterEndPoint) SetURL

func (f *FilterEndPoint) SetURL(url *URL)

type FinishHandleFunc

type FinishHandleFunc func()

func (FinishHandleFunc) Handle

func (f FinishHandleFunc) Handle()

type FinishHandler

type FinishHandler interface {
	Handle()
}

type GroupDiscoverableRegistry

type GroupDiscoverableRegistry interface {
	Registry
	DiscoverAllGroups() ([]string, error)
}

type HaStrategy

type HaStrategy interface {
	Name
	WithURL
	Call(request Request, loadBalance LoadBalance) Response
}

HaStrategy : high availability strategy

type Identity

type Identity interface {
	GetIdentity() string
}

Identity : get id

type Initializable

type Initializable interface {
	Initialize()
}

Initializable :Initializable

type LoadBalance

type LoadBalance interface {
	OnRefresh(endpoints []EndPoint)

	Select(request Request) EndPoint

	SelectArray(request Request) []EndPoint

	SetWeight(weight string)
}

LoadBalance : loadBalance for cluster

type MessageHandler

type MessageHandler interface {
	Name
	RuntimeInfo
	Call(request Request) (res Response)
	AddProvider(p Provider) error
	RmProvider(p Provider)
	GetProvider(serviceName string) Provider
}

MessageHandler : handler message(request) for Server

type MotanRequest

type MotanRequest struct {
	RequestID   uint64
	ServiceName string
	Method      string
	MethodDesc  string
	Arguments   []interface{}
	Attachment  *StringMap
	RPCContext  *RPCContext
	// contains filtered or unexported fields
}

MotanRequest : Request default implement

func AcquireMotanRequest added in v1.1.0

func AcquireMotanRequest() *MotanRequest

func (*MotanRequest) Clone

func (req *MotanRequest) Clone() interface{}

func (*MotanRequest) GetArguments

func (req *MotanRequest) GetArguments() []interface{}

func (*MotanRequest) GetAttachment

func (req *MotanRequest) GetAttachment(key string) string

GetAttachment GetAttachment

func (*MotanRequest) GetAttachments

func (req *MotanRequest) GetAttachments() *StringMap

func (*MotanRequest) GetMethod

func (req *MotanRequest) GetMethod() string

GetMethod GetMethod

func (*MotanRequest) GetMethodDesc

func (req *MotanRequest) GetMethodDesc() string

GetMethodDesc GetMethodDesc

func (*MotanRequest) GetRPCContext

func (req *MotanRequest) GetRPCContext(canCreate bool) *RPCContext

func (*MotanRequest) GetRequestID

func (req *MotanRequest) GetRequestID() uint64

func (*MotanRequest) GetServiceName

func (req *MotanRequest) GetServiceName() string

GetServiceName GetServiceName

func (*MotanRequest) ProcessDeserializable

func (req *MotanRequest) ProcessDeserializable(toTypes []interface{}) error

ProcessDeserializable : DeserializableValue to real params according toType some serialization can deserialize without toType, so nil toType can be accepted in these serializations

func (*MotanRequest) Reset added in v1.1.0

func (req *MotanRequest) Reset()

Reset reset motan request

func (*MotanRequest) SetArguments

func (req *MotanRequest) SetArguments(arguments []interface{})

func (*MotanRequest) SetAttachment

func (req *MotanRequest) SetAttachment(key string, value string)

SetAttachment : SetAttachment

type MotanResponse

type MotanResponse struct {
	RequestID   uint64
	Value       interface{}
	Exception   *Exception
	ProcessTime int64
	Attachment  *StringMap
	RPCContext  *RPCContext
	// contains filtered or unexported fields
}

func AcquireMotanResponse added in v1.1.0

func AcquireMotanResponse() *MotanResponse

func BuildExceptionResponse

func BuildExceptionResponse(requestid uint64, e *Exception) *MotanResponse

func (*MotanResponse) GetAttachment

func (res *MotanResponse) GetAttachment(key string) string

func (*MotanResponse) GetAttachments

func (res *MotanResponse) GetAttachments() *StringMap

func (*MotanResponse) GetException

func (res *MotanResponse) GetException() *Exception

func (*MotanResponse) GetProcessTime

func (res *MotanResponse) GetProcessTime() int64

func (*MotanResponse) GetRPCContext

func (res *MotanResponse) GetRPCContext(canCreate bool) *RPCContext

func (*MotanResponse) GetRequestID

func (res *MotanResponse) GetRequestID() uint64

func (*MotanResponse) GetValue

func (res *MotanResponse) GetValue() interface{}

func (*MotanResponse) ProcessDeserializable

func (res *MotanResponse) ProcessDeserializable(toType interface{}) error

ProcessDeserializable : same with MotanRequest

func (*MotanResponse) Reset added in v1.1.0

func (res *MotanResponse) Reset()

func (*MotanResponse) SetAttachment

func (res *MotanResponse) SetAttachment(key string, value string)

func (*MotanResponse) SetProcessTime

func (res *MotanResponse) SetProcessTime(time int64)

type Name

type Name interface {
	GetName() string
}

Name is a interface can get and set name. especially for extension implements

type NewEndpointFunc

type NewEndpointFunc func(url *URL) EndPoint

type NewHaFunc

type NewHaFunc func(url *URL) HaStrategy

type NewLbFunc

type NewLbFunc func(url *URL) LoadBalance

type NewMessageHandlerFunc

type NewMessageHandlerFunc func() MessageHandler

type NewProviderFunc

type NewProviderFunc func(url *URL) Provider

type NewRegistryFunc

type NewRegistryFunc func(url *URL) Registry

type NewSerializationFunc

type NewSerializationFunc func() Serialization

type NewServerFunc

type NewServerFunc func(url *URL) Server

type NotifyListener

type NotifyListener interface {
	Identity
	Notify(registryURL *URL, urls []*URL)
}

NotifyListener : NotifyListener

type Pinger

type Pinger struct {
	Interval    time.Duration
	Timeout     time.Duration
	Count       int
	PacketsSent int
	PacketsRecv int
	Rtts        []time.Duration
	Size        int
	// contains filtered or unexported fields
}

func NewPinger

func NewPinger(addr string, count int, timeout time.Duration, size int, privileged bool) (*Pinger, error)

func (*Pinger) Addr

func (p *Pinger) Addr() string

func (*Pinger) IPAddr

func (p *Pinger) IPAddr() *net.IPAddr

func (*Pinger) Ping

func (p *Pinger) Ping() error

type Provider

type Provider interface {
	SetService(s interface{})
	Caller
	GetPath() string
}

Provider : service provider

func GetLocalProvider

func GetLocalProvider(service string) Provider

type RPCContext

type RPCContext struct {
	ExtFactory      ExtensionFactory
	OriginalMessage interface{}
	Oneway          bool
	Proxy           bool
	GzipSize        int
	BodySize        int
	SerializeNum    int
	Serialized      bool

	// for call
	AsyncCall bool
	Result    *AsyncResult
	Reply     interface{}
	// various time, it's owned by motan request context
	RequestSendTime     time.Time
	RequestReceiveTime  time.Time
	ResponseSendTime    time.Time
	ResponseReceiveTime time.Time

	FinishHandlers []FinishHandler

	// trace context
	Tc *TraceContext

	// ----  internal vars ----
	IsMotanV1  bool
	RemoteAddr string // remote address
}

RPCContext : Context for RPC call

func (*RPCContext) AddFinishHandler

func (c *RPCContext) AddFinishHandler(handler FinishHandler)

func (*RPCContext) OnFinish

func (c *RPCContext) OnFinish()

func (*RPCContext) Reset added in v1.1.0

func (c *RPCContext) Reset()

type RegisterService

type RegisterService interface {
	Register(serverURL *URL)
	UnRegister(serverURL *URL)
	Available(serverURL *URL)
	Unavailable(serverURL *URL)
	GetRegisteredServices() []*URL
}

RegisterService : register service for rpc server

type Registry

Registry : can subscribe or register service

type RegistryStatus added in v1.1.0

type RegistryStatus struct {
	Status   string
	Service  *URL
	Registry RegisterService
	ErrMsg   string
	IsCheck  bool
}

type RegistryStatusManager added in v1.1.0

type RegistryStatusManager interface {
	GetRegistryStatus() map[string]*RegistryStatus
}

type Request

type Request interface {
	Attachment
	Cloneable
	GetServiceName() string // service name  e.g. request path.or interface name
	GetMethod() string
	GetMethodDesc() string
	GetArguments() []interface{}
	GetRequestID() uint64
	GetRPCContext(canCreate bool) *RPCContext
	ProcessDeserializable(toTypes []interface{}) error
}

Request : motan request

type Response

type Response interface {
	Attachment
	GetValue() interface{}
	GetException() *Exception
	GetRequestID() uint64
	GetProcessTime() int64
	SetProcessTime(time int64)
	GetRPCContext(canCreate bool) *RPCContext
	ProcessDeserializable(toType interface{}) error
}

Response : motan response

type RuntimeInfo added in v1.2.0

type RuntimeInfo interface {
	GetRuntimeInfo() map[string]interface{}
}

RuntimeInfo : output runtime information

type Serialization

type Serialization interface {
	GetSerialNum() int
	Serialize(v interface{}) ([]byte, error)
	DeSerialize(b []byte, v interface{}) (interface{}, error)
	SerializeMulti(v []interface{}) ([]byte, error)
	DeSerializeMulti(b []byte, v []interface{}) ([]interface{}, error)
}

Serialization : Serialization

func GetSerialization

func GetSerialization(url *URL, extFactory ExtensionFactory) Serialization

type Server

type Server interface {
	WithURL
	Name
	Destroyable
	RuntimeInfo
	SetMessageHandler(mh MessageHandler)
	GetMessageHandler() MessageHandler
	Open(block bool, proxy bool, handler MessageHandler, extFactory ExtensionFactory) error
	SetHeartbeat(b bool)
}

Server : rpc server which listen port and process request

type ServiceDiscoverableRegistry

type ServiceDiscoverableRegistry interface {
	Registry
	DiscoverAllServices(group string) ([]string, error)
}

type SetContext

type SetContext interface {
	SetContext(context *Context)
}

SetContext :SetContext

type SnapshotConf

type SnapshotConf struct {
	// SnapshotInterval is the interval of creating snapshot
	SnapshotInterval time.Duration
	SnapshotDir      string
}

SnapshotConf is model for registry snapshot config.

type SnapshotService

type SnapshotService interface {
	StartSnapshot(conf *SnapshotConf)
}

SnapshotService : start registry snapshot

type Span

type Span struct {
	Name     string    `json:"name"`
	Addr     string    `json:"address"`
	Time     time.Time `json:"time"`
	Duration int64     `json:"duration"`
}

type Status

type Status interface {
	IsAvailable() bool
}

Status : for cluster or endpoint to check is available

type StringMap

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

StringMap goroutine safe string map, this will just be used in few goroutines so just use a simple implementation

func NewStringMap

func NewStringMap(cap int) *StringMap

func (*StringMap) Copy

func (m *StringMap) Copy() *StringMap

func (*StringMap) Delete

func (m *StringMap) Delete(key string)

func (*StringMap) Len

func (m *StringMap) Len() int

func (*StringMap) Load

func (m *StringMap) Load(key string) (value string, ok bool)

func (*StringMap) LoadOrEmpty

func (m *StringMap) LoadOrEmpty(key string) string

func (*StringMap) Range

func (m *StringMap) Range(f func(k, v string) bool)

Range calls f sequentially for each key and value present in the map If f returns false, range stops the iteration.

Notice: do not delete elements in range function,because of Range loop the inner map directly.

func (*StringMap) RawMap

func (m *StringMap) RawMap() map[string]string

func (*StringMap) Reset added in v1.1.0

func (m *StringMap) Reset()

func (*StringMap) Store

func (m *StringMap) Store(key, value string)

type Switcher

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

func (*Switcher) GetName

func (s *Switcher) GetName() string

func (*Switcher) IsOpen

func (s *Switcher) IsOpen() bool

func (*Switcher) SetValue

func (s *Switcher) SetValue(value bool)

func (*Switcher) Watch

func (s *Switcher) Watch(listeners ...SwitcherListener)

type SwitcherListener

type SwitcherListener interface {
	Notify(value bool)
}

type SwitcherManager

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

func GetSwitcherManager

func GetSwitcherManager() *SwitcherManager

func (*SwitcherManager) GetAllSwitchers

func (s *SwitcherManager) GetAllSwitchers() map[string]bool

func (*SwitcherManager) GetOrRegister added in v1.1.0

func (s *SwitcherManager) GetOrRegister(name string, value bool, listeners ...SwitcherListener) *Switcher

GetOrRegister returns the switcher with the given name if it's already registered, otherwise registers and returns the new switcher.

func (*SwitcherManager) GetSwitcher

func (s *SwitcherManager) GetSwitcher(name string) *Switcher

GetSwitcher returns the switcher with the given name, or nil if not found.

func (*SwitcherManager) IsOpen added in v1.1.0

func (s *SwitcherManager) IsOpen(sn string) bool

IsOpen returns true if the switcher is present and on, otherwise false.

func (*SwitcherManager) Register

func (s *SwitcherManager) Register(name string, value bool, listeners ...SwitcherListener)

func (*SwitcherManager) SetValue added in v1.1.0

func (s *SwitcherManager) SetValue(name string, value bool)

SetValue sets the value of the switcher with the given name.

type TCPKeepAliveListener

type TCPKeepAliveListener struct {
	*net.TCPListener
}

func (TCPKeepAliveListener) Accept

func (ln TCPKeepAliveListener) Accept() (net.Conn, error)

type TestEndPoint

type TestEndPoint struct {
	URL         *URL
	ProcessTime int64
	// contains filtered or unexported fields
}

func (*TestEndPoint) Call

func (t *TestEndPoint) Call(request Request) Response

func (*TestEndPoint) Destroy

func (t *TestEndPoint) Destroy()

func (*TestEndPoint) GetName

func (t *TestEndPoint) GetName() string

func (*TestEndPoint) GetRuntimeInfo added in v1.2.0

func (t *TestEndPoint) GetRuntimeInfo() map[string]interface{}

func (*TestEndPoint) GetURL

func (t *TestEndPoint) GetURL() *URL

func (*TestEndPoint) Initialize added in v1.1.0

func (t *TestEndPoint) Initialize()

func (*TestEndPoint) IsAvailable

func (t *TestEndPoint) IsAvailable() bool

func (*TestEndPoint) SetAvailable added in v1.1.0

func (t *TestEndPoint) SetAvailable(a bool)

func (*TestEndPoint) SetProxy

func (t *TestEndPoint) SetProxy(proxy bool)

func (*TestEndPoint) SetSerialization

func (t *TestEndPoint) SetSerialization(s Serialization)

func (*TestEndPoint) SetURL

func (t *TestEndPoint) SetURL(url *URL)

type TestEndPointFilter

type TestEndPointFilter struct {
	Index int
	URL   *URL
	// contains filtered or unexported fields
}

func (*TestEndPointFilter) Filter

func (t *TestEndPointFilter) Filter(caller Caller, request Request) Response

func (*TestEndPointFilter) GetIndex

func (t *TestEndPointFilter) GetIndex() int

func (*TestEndPointFilter) GetName

func (t *TestEndPointFilter) GetName() string

func (*TestEndPointFilter) GetNext

func (t *TestEndPointFilter) GetNext() EndPointFilter

func (*TestEndPointFilter) GetRuntimeInfo added in v1.2.0

func (t *TestEndPointFilter) GetRuntimeInfo() map[string]interface{}

func (*TestEndPointFilter) GetType

func (t *TestEndPointFilter) GetType() int32

func (*TestEndPointFilter) HasNext

func (t *TestEndPointFilter) HasNext() bool

func (*TestEndPointFilter) NewFilter

func (t *TestEndPointFilter) NewFilter(url *URL) Filter

func (*TestEndPointFilter) SetNext

func (t *TestEndPointFilter) SetNext(nextFilter EndPointFilter)

type TestFilter

type TestFilter struct {
	Index int
	URL   *URL
	// contains filtered or unexported fields
}

func (*TestFilter) Filter

func (t *TestFilter) Filter(haStrategy HaStrategy, loadBalance LoadBalance, request Request) Response

func (*TestFilter) GetIndex

func (t *TestFilter) GetIndex() int

func (*TestFilter) GetName

func (t *TestFilter) GetName() string

func (*TestFilter) GetNext

func (t *TestFilter) GetNext() ClusterFilter

func (*TestFilter) GetRuntimeInfo added in v1.2.0

func (t *TestFilter) GetRuntimeInfo() map[string]interface{}

func (*TestFilter) GetType

func (t *TestFilter) GetType() int32

func (*TestFilter) HasNext

func (t *TestFilter) HasNext() bool

func (*TestFilter) NewFilter

func (t *TestFilter) NewFilter(url *URL) Filter

func (*TestFilter) SetNext

func (t *TestFilter) SetNext(nextFilter ClusterFilter)

type TestHaStrategy

type TestHaStrategy struct {
	URL *URL
}

func (*TestHaStrategy) Call

func (t *TestHaStrategy) Call(request Request, loadBalance LoadBalance) Response

func (*TestHaStrategy) GetName

func (t *TestHaStrategy) GetName() string

func (*TestHaStrategy) GetURL

func (t *TestHaStrategy) GetURL() *URL

func (*TestHaStrategy) SetURL

func (t *TestHaStrategy) SetURL(url *URL)

type TestLoadBalance

type TestLoadBalance struct {
	Endpoints []EndPoint
}

func (*TestLoadBalance) OnRefresh

func (t *TestLoadBalance) OnRefresh(endpoints []EndPoint)

func (*TestLoadBalance) Select

func (t *TestLoadBalance) Select(request Request) EndPoint

func (*TestLoadBalance) SelectArray

func (t *TestLoadBalance) SelectArray(request Request) []EndPoint

func (*TestLoadBalance) SetWeight

func (t *TestLoadBalance) SetWeight(weight string)

type TestObject

type TestObject struct {
	Str string
}

type TestProvider

type TestProvider struct {
	URL *URL
}

func (*TestProvider) Call

func (t *TestProvider) Call(request Request) Response

func (*TestProvider) Destroy

func (t *TestProvider) Destroy()

func (*TestProvider) GetPath

func (t *TestProvider) GetPath() string

func (*TestProvider) GetRuntimeInfo added in v1.2.0

func (t *TestProvider) GetRuntimeInfo() map[string]interface{}

func (*TestProvider) GetURL

func (t *TestProvider) GetURL() *URL

func (*TestProvider) IsAvailable

func (t *TestProvider) IsAvailable() bool

func (*TestProvider) SetService

func (t *TestProvider) SetService(s interface{})

func (*TestProvider) SetURL

func (t *TestProvider) SetURL(url *URL)

type TestRegistry

type TestRegistry struct {
	URL           *URL
	GroupService  map[string][]string
	DiscoverError bool
}

func (*TestRegistry) Available

func (t *TestRegistry) Available(serverURL *URL)

func (*TestRegistry) Discover

func (t *TestRegistry) Discover(url *URL) []*URL

func (*TestRegistry) DiscoverAllGroups

func (t *TestRegistry) DiscoverAllGroups() ([]string, error)

func (*TestRegistry) DiscoverAllServices

func (t *TestRegistry) DiscoverAllServices(group string) ([]string, error)

func (*TestRegistry) GetName

func (t *TestRegistry) GetName() string

func (*TestRegistry) GetRegisteredServices

func (t *TestRegistry) GetRegisteredServices() []*URL

func (*TestRegistry) GetRuntimeInfo added in v1.2.0

func (t *TestRegistry) GetRuntimeInfo() map[string]interface{}

func (*TestRegistry) GetURL

func (t *TestRegistry) GetURL() *URL

func (*TestRegistry) InitRegistry

func (t *TestRegistry) InitRegistry()

func (*TestRegistry) Register

func (t *TestRegistry) Register(serverURL *URL)

func (*TestRegistry) SetURL

func (t *TestRegistry) SetURL(url *URL)

func (*TestRegistry) StartSnapshot

func (t *TestRegistry) StartSnapshot(conf *SnapshotConf)

func (*TestRegistry) Subscribe

func (t *TestRegistry) Subscribe(url *URL, listener NotifyListener)

func (*TestRegistry) UnRegister

func (t *TestRegistry) UnRegister(serverURL *URL)

func (*TestRegistry) Unavailable

func (t *TestRegistry) Unavailable(serverURL *URL)

func (*TestRegistry) Unsubscribe

func (t *TestRegistry) Unsubscribe(url *URL, listener NotifyListener)

type TraceContext

type TraceContext struct {
	Rid      uint64                 `json:"requestid"`
	Addr     string                 `json:"address"`
	Values   map[string]interface{} `json:"values"`
	ReqSpans []*Span                `json:"request_spans"`
	ResSpans []*Span                `json:"response_spans"`
	// contains filtered or unexported fields
}

func AlwaysTrace

func AlwaysTrace(rid uint64, ext *StringMap) *TraceContext

AlwaysTrace : trace every request unless the tracecontext size over MaxTraceSize.

func GetTraceContexts

func GetTraceContexts() []*TraceContext

GetTraceContexts get && remove all TraceContext in holder, and create a new TraceContext holder.

func NewTraceContext

func NewTraceContext(rid uint64) *TraceContext

NewTraceContext : create a new TraceContext and hold to holder. it will return nil, if TraceContext size of holder is over MaxTraceSize.

func NoTrace

func NoTrace(rid uint64, ext *StringMap) *TraceContext

NoTrace : not trace. default trace policy.

func RandomTrace

func RandomTrace(rid uint64, ext *StringMap) *TraceContext

RandomTrace : trace ratio is 1/RandomTraceBase

func (*TraceContext) PutReqSpan

func (t *TraceContext) PutReqSpan(span *Span)

PutReqSpan : put a trace Span at request phase

func (*TraceContext) PutResSpan

func (t *TraceContext) PutResSpan(span *Span)

PutResSpan : put a trace Span at response phase

type TracePolicyFunc

type TracePolicyFunc func(rid uint64, ext *StringMap) *TraceContext

type URL

type URL struct {
	Protocol   string            `json:"protocol"`
	Host       string            `json:"host"`
	Port       int               `json:"port"`
	Path       string            `json:"path"` //e.g. service name
	Group      string            `json:"group"`
	Parameters map[string]string `json:"parameters"`
	// contains filtered or unexported fields
}

func FromExtInfo

func FromExtInfo(extInfo string) *URL

func GetDirectEnvRegistry added in v1.1.0

func GetDirectEnvRegistry(url *URL) *URL

GetDirectEnvRegistry get the direct registry from the environment variable. return registry urls if url match, or return nil

func (*URL) CanServe

func (u *URL) CanServe(other *URL) bool

func (*URL) CanServeProtocol added in v1.2.0

func (u *URL) CanServeProtocol(other *URL) bool

func (*URL) ClearCachedInfo

func (u *URL) ClearCachedInfo()

func (*URL) Copy

func (u *URL) Copy() *URL

func (*URL) GetAddressStr

func (u *URL) GetAddressStr() string

func (*URL) GetBoolValue added in v1.1.0

func (u *URL) GetBoolValue(key string, defaultValue bool) bool

func (*URL) GetIdentity

func (u *URL) GetIdentity() string

GetIdentity return the identity of url. identity info includes protocol, host, port, path, group the identity will be cached, so must clear cached info after update above info by calling ClearCachedInfo()

func (*URL) GetIdentityWithRegistry added in v1.1.0

func (u *URL) GetIdentityWithRegistry() string

func (*URL) GetInt

func (u *URL) GetInt(key string) (int64, bool)

func (*URL) GetIntValue

func (u *URL) GetIntValue(key string, defaultValue int64) int64

func (*URL) GetMethodIntValue

func (u *URL) GetMethodIntValue(method string, methodDesc string, key string, defaultValue int64) int64

func (*URL) GetMethodPositiveIntValue

func (u *URL) GetMethodPositiveIntValue(method string, methodDesc string, key string, defaultValue int64) int64

func (*URL) GetParam

func (u *URL) GetParam(key string, defaultValue string) string

func (*URL) GetPortStr

func (u *URL) GetPortStr() string

func (*URL) GetPositiveIntValue

func (u *URL) GetPositiveIntValue(key string, defaultValue int64) int64

func (*URL) GetStringParamsWithDefault

func (u *URL) GetStringParamsWithDefault(key string, defaultValue string) string

func (*URL) GetTimeDuration

func (u *URL) GetTimeDuration(key string, unit time.Duration, defaultDuration time.Duration) time.Duration

GetTimeDuration get time duration from params.

func (*URL) IsMatch added in v1.1.0

func (u *URL) IsMatch(service, group, protocol, version string) bool

IsMatch is a tool function for comparing parameters: service, group, protocol and version with URL. When 'protocol' or 'version' is empty, it will be ignored

func (*URL) MergeParams

func (u *URL) MergeParams(params map[string]string)

func (*URL) PutParam

func (u *URL) PutParam(key string, value string)

func (*URL) ToExtInfo

func (u *URL) ToExtInfo() string

type WeightLoadBalance added in v1.2.0

type WeightLoadBalance interface {
	LoadBalance
	NotifyWeightChange()
}

WeightLoadBalance : weight loadBalance for cluster

type WithURL

type WithURL interface {
	GetURL() *URL
	SetURL(url *URL)
}

WithURL : can set and get URL

Jump to

Keyboard shortcuts

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