Documentation ¶
Overview ¶
Package core is motan-go base package. contains base struct, interface and default implement.
Index ¶
- Constants
- Variables
- func AddRelevantFilter(filterStr string)
- func ByteSliceShuffle(slice []byte) []byte
- func CanSetContext(s interface{}, context *Context)
- func ClearDirectEnvRegistry()
- func FirstUpper(s string) string
- func GetAllGroups(gr GroupDiscoverableRegistry) []string
- func GetApplication() string
- func GetEPFilterInfo(filter EndPointFilter) string
- func GetLocalIP() string
- func GetLocalIPs() []string
- func GetMport() int
- func GetNonNegative(originValue int64) int64
- func GetRelevantFilters() map[string]bool
- func GetReqInfo(request Request) string
- func GetResInfo(response Response) string
- func GetRuntimeInfo(s interface{}) map[string]interface{}
- func GetURLFilters(url *URL, extFactory ExtensionFactory) (clusterFilter ClusterFilter, endpointFilters []Filter)
- func HandlePanic(f func())
- func Initialize(s interface{})
- func InterfaceToString(in interface{}) string
- func IsSame(m1 map[string]string, m2 map[string]string, key string, defaultValue string) bool
- func ListenUnixSock(unixSockAddr string) (net.Listener, error)
- func ParseExportInfo(export string) (string, int, error)
- func RegistLocalProvider(service string, provider Provider)
- func ReleaseBytesBuffer(b *BytesBuffer)
- func ReleaseMotanRequest(req *MotanRequest)
- func ReleaseMotanResponse(m *MotanResponse)
- func ServiceInGroup(sr ServiceDiscoverableRegistry, group string, service string) bool
- func SetApplication(v string)
- func SetMport(v int)
- func SliceShuffle(slice []string) []string
- func SlicesUnique(src []string) []string
- func TrimSplit(s string, sep string) []string
- func TrimSplitSet(s string, sep string) map[string]bool
- type AsyncResult
- type AtomicString
- type Attachment
- type BytesBuffer
- func AcquireBytesBuffer(initSize int) *BytesBuffer
- func CreateBytesBuffer(data []byte) *BytesBuffer
- func CreateBytesBufferWithOrder(data []byte, order binary.ByteOrder) *BytesBuffer
- func NewBytesBuffer(initsize int) *BytesBuffer
- func NewBytesBufferWithOrder(initsize int, order binary.ByteOrder) *BytesBuffer
- func (b *BytesBuffer) Bytes() []byte
- func (b *BytesBuffer) Cap() int
- func (b *BytesBuffer) GetRPos() int
- func (b *BytesBuffer) GetWPos() int
- func (b *BytesBuffer) Len() int
- func (b *BytesBuffer) Next(n int) ([]byte, error)
- func (b *BytesBuffer) Read(p []byte) (n int, err error)
- func (b *BytesBuffer) ReadByte() (byte, error)
- func (b *BytesBuffer) ReadFull(p []byte) error
- func (b *BytesBuffer) ReadInt() (int, error)
- func (b *BytesBuffer) ReadUint16() (n uint16, err error)
- func (b *BytesBuffer) ReadUint32() (n uint32, err error)
- func (b *BytesBuffer) ReadUint64() (n uint64, err error)
- func (b *BytesBuffer) ReadVarint() (x uint64, err error)
- func (b *BytesBuffer) ReadZigzag32() (x uint64, err error)
- func (b *BytesBuffer) ReadZigzag64() (x uint64, err error)
- func (b *BytesBuffer) Remain() int
- func (b *BytesBuffer) Reset()
- func (b *BytesBuffer) SetRPos(pos int)
- func (b *BytesBuffer) SetWPos(pos int)
- func (b *BytesBuffer) Write(bytes []byte)
- func (b *BytesBuffer) WriteByte(c byte)
- func (b *BytesBuffer) WriteString(str string)
- func (b *BytesBuffer) WriteUint16(u uint16)
- func (b *BytesBuffer) WriteUint32(u uint32)
- func (b *BytesBuffer) WriteUint64(u uint64)
- func (b *BytesBuffer) WriteVarint(u uint64) int
- func (b *BytesBuffer) WriteZigzag32(u uint32) int
- func (b *BytesBuffer) WriteZigzag64(u uint64) int
- type Caller
- type CircularRecorder
- type Cloneable
- type ClusterFilter
- type CommandNotifyListener
- type Context
- func (c *Context) FilterSetToStr(f map[string]bool) string
- func (c *Context) GetDefaultFilterSet(newURL *URL) map[string]bool
- func (c *Context) GetEnvGlobalFilterSet() map[string]bool
- func (c *Context) GetFilterSet(filterStr, disableFilterStr string) (dst map[string]bool)
- func (c *Context) GetGlobalFilterSet(newURL *URL) map[string]bool
- func (c *Context) Initialize()
- func (c *Context) MergeFilterSet(sets ...map[string]bool) (dst map[string]bool)
- type CopyOnWriteMap
- func (m *CopyOnWriteMap) Delete(key interface{}) (pv interface{})
- func (m *CopyOnWriteMap) Len() int
- func (m *CopyOnWriteMap) Load(key interface{}) (interface{}, bool)
- func (m *CopyOnWriteMap) LoadOrNil(key interface{}) interface{}
- func (m *CopyOnWriteMap) Range(f func(k, v interface{}) bool)
- func (m *CopyOnWriteMap) SafeDoFunc(f func())
- func (m *CopyOnWriteMap) Store(key, value interface{})
- func (m *CopyOnWriteMap) Swap(newMap map[interface{}]interface{}) map[interface{}]interface{}
- func (m *CopyOnWriteMap) UnsafeStore(key, value interface{})
- type DefaultExtensionFactory
- func (d *DefaultExtensionFactory) GetEndPoint(url *URL) EndPoint
- func (d *DefaultExtensionFactory) GetFilter(name string) Filter
- func (d *DefaultExtensionFactory) GetHa(url *URL) HaStrategy
- func (d *DefaultExtensionFactory) GetLB(url *URL) LoadBalance
- func (d *DefaultExtensionFactory) GetMessageHandler(name string) MessageHandler
- func (d *DefaultExtensionFactory) GetProvider(url *URL) Provider
- func (d *DefaultExtensionFactory) GetRegistry(url *URL) Registry
- func (d *DefaultExtensionFactory) GetRuntimeInfo() map[string]interface{}
- func (d *DefaultExtensionFactory) GetSerialization(name string, id int) Serialization
- func (d *DefaultExtensionFactory) GetServer(url *URL) Server
- func (d *DefaultExtensionFactory) Initialize()
- func (d *DefaultExtensionFactory) RegistExtEndpoint(name string, newEndpoint NewEndpointFunc)
- func (d *DefaultExtensionFactory) RegistExtFilter(name string, newFilter DefaultFilterFunc)
- func (d *DefaultExtensionFactory) RegistExtHa(name string, newHa NewHaFunc)
- func (d *DefaultExtensionFactory) RegistExtLb(name string, newLb NewLbFunc)
- func (d *DefaultExtensionFactory) RegistExtProvider(name string, newProvider NewProviderFunc)
- func (d *DefaultExtensionFactory) RegistExtRegistry(name string, newRegistry NewRegistryFunc)
- func (d *DefaultExtensionFactory) RegistExtServer(name string, newServer NewServerFunc)
- func (d *DefaultExtensionFactory) RegistryExtMessageHandler(name string, newMessage NewMessageHandlerFunc)
- func (d *DefaultExtensionFactory) RegistryExtSerialization(name string, id int, newSerialization NewSerializationFunc)
- type DefaultFilterFunc
- type DeserializableValue
- type Destroyable
- type DiscoverCommand
- type DiscoverService
- type EndPoint
- type EndPointFilter
- type Exception
- type Exporter
- type ExtensionFactory
- type Filter
- type FilterEndPoint
- func (f *FilterEndPoint) Call(request Request) Response
- func (f *FilterEndPoint) Destroy()
- func (f *FilterEndPoint) GetName() string
- func (f *FilterEndPoint) GetRuntimeInfo() map[string]interface{}
- func (f *FilterEndPoint) GetURL() *URL
- func (f *FilterEndPoint) IsAvailable() bool
- func (f *FilterEndPoint) SetProxy(proxy bool)
- func (f *FilterEndPoint) SetSerialization(s Serialization)
- func (f *FilterEndPoint) SetURL(url *URL)
- type FinishHandleFunc
- type FinishHandler
- type GroupDiscoverableRegistry
- type HaStrategy
- type Identity
- type Initializable
- type LoadBalance
- type MessageHandler
- type MotanRequest
- func (req *MotanRequest) Clone() interface{}
- func (req *MotanRequest) GetArguments() []interface{}
- func (req *MotanRequest) GetAttachment(key string) string
- func (req *MotanRequest) GetAttachments() *StringMap
- func (req *MotanRequest) GetMethod() string
- func (req *MotanRequest) GetMethodDesc() string
- func (req *MotanRequest) GetRPCContext(canCreate bool) *RPCContext
- func (req *MotanRequest) GetRequestID() uint64
- func (req *MotanRequest) GetServiceName() string
- func (req *MotanRequest) ProcessDeserializable(toTypes []interface{}) error
- func (req *MotanRequest) Reset()
- func (req *MotanRequest) SetArguments(arguments []interface{})
- func (req *MotanRequest) SetAttachment(key string, value string)
- type MotanResponse
- func (res *MotanResponse) GetAttachment(key string) string
- func (res *MotanResponse) GetAttachments() *StringMap
- func (res *MotanResponse) GetException() *Exception
- func (res *MotanResponse) GetProcessTime() int64
- func (res *MotanResponse) GetRPCContext(canCreate bool) *RPCContext
- func (res *MotanResponse) GetRequestID() uint64
- func (res *MotanResponse) GetValue() interface{}
- func (res *MotanResponse) ProcessDeserializable(toType interface{}) error
- func (res *MotanResponse) Reset()
- func (res *MotanResponse) SetAttachment(key string, value string)
- func (res *MotanResponse) SetProcessTime(time int64)
- type Name
- type NewEndpointFunc
- type NewHaFunc
- type NewLbFunc
- type NewMessageHandlerFunc
- type NewProviderFunc
- type NewRegistryFunc
- type NewSerializationFunc
- type NewServerFunc
- type NotifyListener
- type Pinger
- type Provider
- type RPCContext
- type RegisterService
- type Registry
- type RegistryStatus
- type RegistryStatusManager
- type Request
- type Response
- type RuntimeInfo
- type Serialization
- type Server
- type ServiceDiscoverableRegistry
- type SetContext
- type SnapshotConf
- type SnapshotService
- type Span
- type Status
- type StringMap
- func (m *StringMap) Copy() *StringMap
- func (m *StringMap) Delete(key string)
- func (m *StringMap) Len() int
- func (m *StringMap) Load(key string) (value string, ok bool)
- func (m *StringMap) LoadOrEmpty(key string) string
- func (m *StringMap) Range(f func(k, v string) bool)
- func (m *StringMap) RawMap() map[string]string
- func (m *StringMap) Reset()
- func (m *StringMap) Store(key, value string)
- type Switcher
- type SwitcherListener
- type SwitcherManager
- func (s *SwitcherManager) GetAllSwitchers() map[string]bool
- func (s *SwitcherManager) GetOrRegister(name string, value bool, listeners ...SwitcherListener) *Switcher
- func (s *SwitcherManager) GetSwitcher(name string) *Switcher
- func (s *SwitcherManager) IsOpen(sn string) bool
- func (s *SwitcherManager) Register(name string, value bool, listeners ...SwitcherListener)
- func (s *SwitcherManager) SetValue(name string, value bool)
- type TCPKeepAliveListener
- type TestEndPoint
- func (t *TestEndPoint) Call(request Request) Response
- func (t *TestEndPoint) Destroy()
- func (t *TestEndPoint) GetName() string
- func (t *TestEndPoint) GetRuntimeInfo() map[string]interface{}
- func (t *TestEndPoint) GetURL() *URL
- func (t *TestEndPoint) Initialize()
- func (t *TestEndPoint) IsAvailable() bool
- func (t *TestEndPoint) SetAvailable(a bool)
- func (t *TestEndPoint) SetProxy(proxy bool)
- func (t *TestEndPoint) SetSerialization(s Serialization)
- func (t *TestEndPoint) SetURL(url *URL)
- type TestEndPointFilter
- func (t *TestEndPointFilter) Filter(caller Caller, request Request) Response
- func (t *TestEndPointFilter) GetIndex() int
- func (t *TestEndPointFilter) GetName() string
- func (t *TestEndPointFilter) GetNext() EndPointFilter
- func (t *TestEndPointFilter) GetRuntimeInfo() map[string]interface{}
- func (t *TestEndPointFilter) GetType() int32
- func (t *TestEndPointFilter) HasNext() bool
- func (t *TestEndPointFilter) NewFilter(url *URL) Filter
- func (t *TestEndPointFilter) SetNext(nextFilter EndPointFilter)
- type TestFilter
- func (t *TestFilter) Filter(haStrategy HaStrategy, loadBalance LoadBalance, request Request) Response
- func (t *TestFilter) GetIndex() int
- func (t *TestFilter) GetName() string
- func (t *TestFilter) GetNext() ClusterFilter
- func (t *TestFilter) GetRuntimeInfo() map[string]interface{}
- func (t *TestFilter) GetType() int32
- func (t *TestFilter) HasNext() bool
- func (t *TestFilter) NewFilter(url *URL) Filter
- func (t *TestFilter) SetNext(nextFilter ClusterFilter)
- type TestHaStrategy
- type TestLoadBalance
- type TestObject
- type TestProvider
- func (t *TestProvider) Call(request Request) Response
- func (t *TestProvider) Destroy()
- func (t *TestProvider) GetPath() string
- func (t *TestProvider) GetRuntimeInfo() map[string]interface{}
- func (t *TestProvider) GetURL() *URL
- func (t *TestProvider) IsAvailable() bool
- func (t *TestProvider) SetService(s interface{})
- func (t *TestProvider) SetURL(url *URL)
- type TestRegistry
- func (t *TestRegistry) Available(serverURL *URL)
- func (t *TestRegistry) Discover(url *URL) []*URL
- func (t *TestRegistry) DiscoverAllGroups() ([]string, error)
- func (t *TestRegistry) DiscoverAllServices(group string) ([]string, error)
- func (t *TestRegistry) GetName() string
- func (t *TestRegistry) GetRegisteredServices() []*URL
- func (t *TestRegistry) GetRuntimeInfo() map[string]interface{}
- func (t *TestRegistry) GetURL() *URL
- func (t *TestRegistry) InitRegistry()
- func (t *TestRegistry) Register(serverURL *URL)
- func (t *TestRegistry) SetURL(url *URL)
- func (t *TestRegistry) StartSnapshot(conf *SnapshotConf)
- func (t *TestRegistry) Subscribe(url *URL, listener NotifyListener)
- func (t *TestRegistry) UnRegister(serverURL *URL)
- func (t *TestRegistry) Unavailable(serverURL *URL)
- func (t *TestRegistry) Unsubscribe(url *URL, listener NotifyListener)
- type TraceContext
- type TracePolicyFunc
- type URL
- func (u *URL) CanServe(other *URL) bool
- func (u *URL) CanServeProtocol(other *URL) bool
- func (u *URL) ClearCachedInfo()
- func (u *URL) Copy() *URL
- func (u *URL) GetAddressStr() string
- func (u *URL) GetBoolValue(key string, defaultValue bool) bool
- func (u *URL) GetIdentity() string
- func (u *URL) GetIdentityWithRegistry() string
- func (u *URL) GetInt(key string) (int64, bool)
- func (u *URL) GetIntValue(key string, defaultValue int64) int64
- func (u *URL) GetMethodIntValue(method string, methodDesc string, key string, defaultValue int64) int64
- func (u *URL) GetMethodPositiveIntValue(method string, methodDesc string, key string, defaultValue int64) int64
- func (u *URL) GetParam(key string, defaultValue string) string
- func (u *URL) GetPortStr() string
- func (u *URL) GetPositiveIntValue(key string, defaultValue int64) int64
- func (u *URL) GetStringParamsWithDefault(key string, defaultValue string) string
- func (u *URL) GetTimeDuration(key string, unit time.Duration, defaultDuration time.Duration) time.Duration
- func (u *URL) IsMatch(service, group, protocol, version string) bool
- func (u *URL) MergeParams(params map[string]string)
- func (u *URL) PutParam(key string, value string)
- func (u *URL) ToExtInfo() string
- type WeightLoadBalance
- type WithURL
Constants ¶
const ( FrameworkException = iota // ServiceException : exception by service call ServiceException // BizException : exception by service implements BizException )
--------------all global public constants-------------- exception type
const ( // EndPointFilterType filter for endpoint EndPointFilterType = iota // ClusterFilterType filter for cluster ClusterFilterType )
filter type
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
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
const ( RegisterSuccess = "register-success" RegisterFailed = "register-failed" UnregisterSuccess = "unregister-success" UnregisterFailed = "unregister-failed" NotRegister = "not-register" )
registryStatus
const ( NodeTypeService = "service" NodeTypeReferer = "referer" NodeTypeAgent = "agent" )
nodeType
const ( Receive = "receive" Decode = "decode" Convert = "convert" ClFilter = "clusterFilter" EpFilterStart = "selectEndpoint" EpFilterEnd = "endpointFilter" Encode = "encode" Send = "send" )
trace span name
const ( DefaultWriteTimeout = 5 * time.Second DefaultMaxContentLength = 10 * 1024 * 1024 GroupNameSeparator = "," )
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
const ( ENoEndpoints = 1001 ENoChannel = 1002 EUnkonwnMsg = 1003 EConvertMsg = 1004 EProviderNotExist = 404 )
errorCodes
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
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" 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" )
const ( SwitcherSection = "switcher" // URLConfKey is config id // config Keys URLConfKey = "conf-id" )
const ( DefaultAttachmentSize = 16 ProtocolLocal = "local" )
const (
DefaultReferVersion = "1.0"
)
const (
MetaUpstreamCode = "upstreamCode"
)
meta keys
const (
MetricsReqApplication = "metricsReqApp"
)
metrics request application
const (
ProviderNotExistPrefix = "provider not exist serviceKey="
)
ProviderNotExistPrefix errorMessage
Variables ¶
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 )
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
var ErrNotEnough = errors.New("BytesBuffer: not enough bytes")
var ErrOverflow = errors.New("BytesBuffer: integer overflow")
var (
PanicStatFunc func()
)
Functions ¶
func AddRelevantFilter ¶ added in v1.1.0
func AddRelevantFilter(filterStr string)
func ByteSliceShuffle ¶ added in v1.2.0
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 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 GetNonNegative ¶ added in v1.2.0
func GetRelevantFilters ¶ added in v1.1.0
func GetReqInfo ¶
func GetResInfo ¶ added in v1.1.0
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 InterfaceToString ¶
func InterfaceToString(in interface{}) string
func ListenUnixSock ¶
ListenUnixSock try to listen a unix socket address this method using by create motan agent server, management server and http proxy server
func RegistLocalProvider ¶
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 SliceShuffle ¶
func SlicesUnique ¶ added in v1.1.0
SlicesUnique deduplicate the values of the slice
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) ReadByte ¶
func (b *BytesBuffer) ReadByte() (byte, error)
func (*BytesBuffer) ReadFull ¶
func (b *BytesBuffer) ReadFull(p []byte) error
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 NewContextFromConfig ¶
func (*Context) FilterSetToStr ¶ added in v1.1.0
func (*Context) GetDefaultFilterSet ¶ added in v1.1.0
func (*Context) GetEnvGlobalFilterSet ¶ added in v1.1.0
func (*Context) GetFilterSet ¶ added in v1.1.0
func (*Context) GetGlobalFilterSet ¶ added in v1.1.0
func (*Context) Initialize ¶
func (c *Context) Initialize()
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 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
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() 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 HaStrategy ¶
type HaStrategy interface { Name WithURL Call(request Request, loadBalance LoadBalance) Response }
HaStrategy : high availability strategy
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) 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 NewHaFunc ¶
type NewHaFunc func(url *URL) HaStrategy
type NewLbFunc ¶
type NewLbFunc func(url *URL) LoadBalance
type NewMessageHandlerFunc ¶
type NewMessageHandlerFunc func() MessageHandler
type NewProviderFunc ¶
type NewRegistryFunc ¶
type NewSerializationFunc ¶
type NewSerializationFunc func() Serialization
type NewServerFunc ¶
type NotifyListener ¶
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 }
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) GetRegisteredServices() []*URL }
RegisterService : register service for rpc server
type Registry ¶
type Registry interface { RuntimeInfo Name WithURL DiscoverService RegisterService SnapshotService }
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 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 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 (*StringMap) LoadOrEmpty ¶
type Switcher ¶
type Switcher struct {
// contains filtered or unexported fields
}
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
}
type TestEndPoint ¶
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 ¶
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 ¶
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 ¶
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 GetDirectEnvRegistry ¶ added in v1.1.0
GetDirectEnvRegistry get the direct registry from the environment variable. return registry urls if url match, or return nil
func (*URL) CanServeProtocol ¶ added in v1.2.0
func (*URL) ClearCachedInfo ¶
func (u *URL) ClearCachedInfo()
func (*URL) GetAddressStr ¶
func (*URL) GetBoolValue ¶ added in v1.1.0
func (*URL) GetIdentity ¶
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 (*URL) GetMethodIntValue ¶
func (*URL) GetMethodPositiveIntValue ¶
func (*URL) GetPortStr ¶
func (*URL) GetPositiveIntValue ¶
func (*URL) GetStringParamsWithDefault ¶
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
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 ¶
type WeightLoadBalance ¶ added in v1.2.0
type WeightLoadBalance interface { LoadBalance NotifyWeightChange() }
WeightLoadBalance : weight loadBalance for cluster