Documentation ¶
Overview ¶
Package core is motan-go base package. contains base struct, interface and default implement.
Index ¶
- Constants
- Variables
- func CanSetContext(s interface{}, context *Context)
- func FirstUpper(s string) string
- func GetLocalIP() string
- func GetLocalIPs() []string
- func GetReqInfo(request Request) string
- func GetURLFilters(url *URL, extFactory ExtentionFactory) (clusterFilter ClusterFilter, endpointFilters []Filter)
- 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 ParseExportInfo(export string) (string, int, error)
- func SliceShuffle(slice []string) []string
- type AsyncResult
- type Attachment
- type Caller
- type ClusterFilter
- type CommandNotifyListener
- type Context
- type DefaultExtentionFactory
- func (d *DefaultExtentionFactory) GetEndPoint(url *URL) EndPoint
- func (d *DefaultExtentionFactory) GetFilter(name string) Filter
- func (d *DefaultExtentionFactory) GetHa(url *URL) HaStrategy
- func (d *DefaultExtentionFactory) GetLB(url *URL) LoadBalance
- func (d *DefaultExtentionFactory) GetMessageHandler(name string) MessageHandler
- func (d *DefaultExtentionFactory) GetProvider(url *URL) Provider
- func (d *DefaultExtentionFactory) GetRegistry(url *URL) Registry
- func (d *DefaultExtentionFactory) GetSerialization(name string, id int) Serialization
- func (d *DefaultExtentionFactory) GetServer(url *URL) Server
- func (d *DefaultExtentionFactory) Initialize()
- func (d *DefaultExtentionFactory) RegistExtEndpoint(name string, newEndpoint NewEndpointFunc)
- func (d *DefaultExtentionFactory) RegistExtFilter(name string, newFilter DefaultFilterFunc)
- func (d *DefaultExtentionFactory) RegistExtHa(name string, newHa NewHaFunc)
- func (d *DefaultExtentionFactory) RegistExtLb(name string, newLb NewLbFunc)
- func (d *DefaultExtentionFactory) RegistExtProvider(name string, newProvider NewProviderFunc)
- func (d *DefaultExtentionFactory) RegistExtRegistry(name string, newRegistry NewRegistryFunc)
- func (d *DefaultExtentionFactory) RegistExtServer(name string, newServer NewServerFunc)
- func (d *DefaultExtentionFactory) RegistryExtMessageHandler(name string, newMessage NewMessageHandlerFunc)
- func (d *DefaultExtentionFactory) 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 ExtentionFactory
- type Filter
- type FilterEndPoint
- func (f *FilterEndPoint) Call(request Request) Response
- func (f *FilterEndPoint) Destroy()
- func (f *FilterEndPoint) GetName() string
- 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 HaStrategy
- type Identity
- type Initializable
- type LoadBalance
- type MessageHandler
- type MotanRequest
- func (m *MotanRequest) GetArguments() []interface{}
- func (m *MotanRequest) GetAttachment(key string) string
- func (m *MotanRequest) GetAttachments() map[string]string
- func (m *MotanRequest) GetMethod() string
- func (m *MotanRequest) GetMethodDesc() string
- func (m *MotanRequest) GetRPCContext(canCreate bool) *RPCContext
- func (m *MotanRequest) GetRequestID() uint64
- func (m *MotanRequest) GetServiceName() string
- func (m *MotanRequest) ProcessDeserializable(toTypes []interface{}) error
- func (m *MotanRequest) SetArguments(arguments []interface{})
- func (m *MotanRequest) SetAttachment(key string, value string)
- type MotanResponse
- func (m *MotanResponse) GetAttachment(key string) string
- func (m *MotanResponse) GetAttachments() map[string]string
- func (m *MotanResponse) GetException() *Exception
- func (m *MotanResponse) GetProcessTime() int64
- func (m *MotanResponse) GetRPCContext(canCreate bool) *RPCContext
- func (m *MotanResponse) GetRequestID() uint64
- func (m *MotanResponse) GetValue() interface{}
- func (m *MotanResponse) ProcessDeserializable(toType interface{}) error
- func (m *MotanResponse) SetAttachment(key string, value string)
- func (m *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 Provider
- type RPCContext
- type RegisterService
- type Registry
- type Request
- type Response
- type Serialization
- type Server
- type SetContext
- type SnapshotConf
- type SnapshotService
- type Status
- type TestEndPoint
- func (t *TestEndPoint) Call(request Request) Response
- func (t *TestEndPoint) Destroy()
- func (t *TestEndPoint) GetName() string
- func (t *TestEndPoint) GetURL() *URL
- func (t *TestEndPoint) IsAvailable() 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) 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) 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 TestRegistry
- func (t *TestRegistry) Available(serverURL *URL)
- func (t *TestRegistry) Discover(url *URL) []*URL
- func (t *TestRegistry) GetName() string
- func (t *TestRegistry) GetRegisteredServices() []*URL
- 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 URL
- func (u *URL) CanServe(other *URL) bool
- func (u *URL) ClearCachedInfo()
- func (u *URL) CompositeAddresses() []string
- func (u *URL) Copy() *URL
- func (u *URL) GetAddressStr() string
- func (u *URL) GetIdentity() string
- func (u *URL) GetInt(key string) (i int64, b 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) MergeParams(params map[string]string)
- func (u *URL) PutParam(key string, value string)
- func (u *URL) ToExtInfo() string
- 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" SessionTimeOutKey = "registrySessionTimeout" ApplicationKey = "application" VersionKey = "version" FilterKey = "filter" RegistryKey = "registry" WeightKey = "weight" SerializationKey = "serialization" RefKey = "ref" ExportKey = "export" ModuleKey = "module" GroupKey = "group" ProviderKey = "provider" AddressKey = "address" GzipSizeKey = "mingzSize" HostKey = "host" RemoteIPKey = "remoteIP" )
common url parameter key
const ( NodeTypeService = "service" NodeTypeReferer = "referer" NodeTypeAgent = "agent" )
nodeType
const (
// URLConfKey add confid to url params
URLConfKey = "conf-id"
)
Variables ¶
var ( CfgFile = "./motan.yaml" LocalIP = "" IDC = "" DynamicConfs = "" )
all env flag in motan-go
Functions ¶
func CanSetContext ¶
func CanSetContext(s interface{}, context *Context)
CanSetContext :CanSetContext
func FirstUpper ¶
func GetReqInfo ¶
func GetURLFilters ¶
func GetURLFilters(url *URL, extFactory ExtentionFactory) (clusterFilter ClusterFilter, endpointFilters []Filter)
func InterfaceToString ¶
func InterfaceToString(in interface{}) string
func SliceShuffle ¶
Types ¶
type AsyncResult ¶
type AsyncResult struct { StartTime int64 Done chan *AsyncResult Reply interface{} Error error }
AsyncResult : async call result
type Attachment ¶
type Attachment interface { GetAttachments() map[string]string GetAttachment(key string) string SetAttachment(key string, value string) }
Attachment : can get, set attachments.
type Caller ¶
type Caller interface { 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 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 BasicRefers map[string]*URL ServiceURLs map[string]*URL BasicServiceURLs map[string]*URL AgentURL *URL ClientURL *URL ServerURL *URL }
Context for agent, client, server. context is created depends on config file
func (*Context) Initialize ¶
func (c *Context) Initialize()
type DefaultExtentionFactory ¶
type DefaultExtentionFactory struct {
// contains filtered or unexported fields
}
func (*DefaultExtentionFactory) GetEndPoint ¶
func (d *DefaultExtentionFactory) GetEndPoint(url *URL) EndPoint
func (*DefaultExtentionFactory) GetFilter ¶
func (d *DefaultExtentionFactory) GetFilter(name string) Filter
func (*DefaultExtentionFactory) GetHa ¶
func (d *DefaultExtentionFactory) GetHa(url *URL) HaStrategy
func (*DefaultExtentionFactory) GetLB ¶
func (d *DefaultExtentionFactory) GetLB(url *URL) LoadBalance
func (*DefaultExtentionFactory) GetMessageHandler ¶
func (d *DefaultExtentionFactory) GetMessageHandler(name string) MessageHandler
func (*DefaultExtentionFactory) GetProvider ¶
func (d *DefaultExtentionFactory) GetProvider(url *URL) Provider
func (*DefaultExtentionFactory) GetRegistry ¶
func (d *DefaultExtentionFactory) GetRegistry(url *URL) Registry
func (*DefaultExtentionFactory) GetSerialization ¶
func (d *DefaultExtentionFactory) GetSerialization(name string, id int) Serialization
func (*DefaultExtentionFactory) GetServer ¶
func (d *DefaultExtentionFactory) GetServer(url *URL) Server
func (*DefaultExtentionFactory) Initialize ¶
func (d *DefaultExtentionFactory) Initialize()
func (*DefaultExtentionFactory) RegistExtEndpoint ¶
func (d *DefaultExtentionFactory) RegistExtEndpoint(name string, newEndpoint NewEndpointFunc)
func (*DefaultExtentionFactory) RegistExtFilter ¶
func (d *DefaultExtentionFactory) RegistExtFilter(name string, newFilter DefaultFilterFunc)
func (*DefaultExtentionFactory) RegistExtHa ¶
func (d *DefaultExtentionFactory) RegistExtHa(name string, newHa NewHaFunc)
func (*DefaultExtentionFactory) RegistExtLb ¶
func (d *DefaultExtentionFactory) RegistExtLb(name string, newLb NewLbFunc)
func (*DefaultExtentionFactory) RegistExtProvider ¶
func (d *DefaultExtentionFactory) RegistExtProvider(name string, newProvider NewProviderFunc)
func (*DefaultExtentionFactory) RegistExtRegistry ¶
func (d *DefaultExtentionFactory) RegistExtRegistry(name string, newRegistry NewRegistryFunc)
func (*DefaultExtentionFactory) RegistExtServer ¶
func (d *DefaultExtentionFactory) RegistExtServer(name string, newServer NewServerFunc)
func (*DefaultExtentionFactory) RegistryExtMessageHandler ¶
func (d *DefaultExtentionFactory) RegistryExtMessageHandler(name string, newMessage NewMessageHandlerFunc)
func (*DefaultExtentionFactory) RegistryExtSerialization ¶
func (d *DefaultExtentionFactory) 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
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 { Export(server Server) error Unexport() error SetProvider(provider Provider) GetProvider() Provider WithURL }
Exporter : export and manage a service. one exporter bind with a service
type ExtentionFactory ¶
type ExtentionFactory interface { 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) }
ExtentionFactory : can regiser and get all kinds of extension implements.
type Filter ¶
type Filter interface { 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) 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 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 { 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 map[string]string RPCContext *RPCContext }
MotanRequest : Request default implement
func (*MotanRequest) GetArguments ¶
func (m *MotanRequest) GetArguments() []interface{}
func (*MotanRequest) GetAttachment ¶
func (m *MotanRequest) GetAttachment(key string) string
GetAttachment GetAttachment
func (*MotanRequest) GetAttachments ¶
func (m *MotanRequest) GetAttachments() map[string]string
func (*MotanRequest) GetMethodDesc ¶
func (m *MotanRequest) GetMethodDesc() string
GetMethodDesc GetMethodDesc
func (*MotanRequest) GetRPCContext ¶
func (m *MotanRequest) GetRPCContext(canCreate bool) *RPCContext
func (*MotanRequest) GetRequestID ¶
func (m *MotanRequest) GetRequestID() uint64
func (*MotanRequest) GetServiceName ¶
func (m *MotanRequest) GetServiceName() string
GetServiceName GetServiceName
func (*MotanRequest) ProcessDeserializable ¶
func (m *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) SetArguments ¶
func (m *MotanRequest) SetArguments(arguments []interface{})
func (*MotanRequest) SetAttachment ¶
func (m *MotanRequest) SetAttachment(key string, value string)
SetAttachment : SetAttachment
type MotanResponse ¶
type MotanResponse struct { RequestID uint64 Value interface{} Exception *Exception ProcessTime int64 Attachment map[string]string RPCContext *RPCContext }
func BuildExceptionResponse ¶
func BuildExceptionResponse(requestid uint64, e *Exception) *MotanResponse
func (*MotanResponse) GetAttachment ¶
func (m *MotanResponse) GetAttachment(key string) string
func (*MotanResponse) GetAttachments ¶
func (m *MotanResponse) GetAttachments() map[string]string
func (*MotanResponse) GetException ¶
func (m *MotanResponse) GetException() *Exception
func (*MotanResponse) GetProcessTime ¶
func (m *MotanResponse) GetProcessTime() int64
func (*MotanResponse) GetRPCContext ¶
func (m *MotanResponse) GetRPCContext(canCreate bool) *RPCContext
func (*MotanResponse) GetRequestID ¶
func (m *MotanResponse) GetRequestID() uint64
func (*MotanResponse) GetValue ¶
func (m *MotanResponse) GetValue() interface{}
func (*MotanResponse) ProcessDeserializable ¶
func (m *MotanResponse) ProcessDeserializable(toType interface{}) error
ProcessDeserializable : same with MotanRequest
func (*MotanResponse) SetAttachment ¶
func (m *MotanResponse) SetAttachment(key string, value string)
func (*MotanResponse) SetProcessTime ¶
func (m *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 RPCContext ¶
type RPCContext struct { ExtFactory ExtentionFactory OriginalMessage interface{} Oneway bool Proxy bool GzipSize int SerializeNum int Serialized bool // for call AsyncCall bool Result *AsyncResult Reply interface{} }
RPCContext : Context for RPC call
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 { Name WithURL DiscoverService RegisterService SnapshotService }
Registry : can subscribe or register service
type Request ¶
type Request interface { Attachment 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 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 ExtentionFactory) Serialization
type Server ¶
type Server interface { WithURL Name Destroyable SetMessageHandler(mh MessageHandler) GetMessageHandler() MessageHandler Open(block bool, proxy bool, handler MessageHandler, extFactory ExtentionFactory) error }
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 TestEndPoint ¶
type TestEndPoint struct {
URL *URL
}
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) GetURL ¶
func (t *TestEndPoint) GetURL() *URL
func (*TestEndPoint) IsAvailable ¶
func (t *TestEndPoint) IsAvailable() 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) 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) 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) 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 TestRegistry ¶
type TestRegistry struct {
URL *URL
}
func (*TestRegistry) Available ¶
func (t *TestRegistry) Available(serverURL *URL)
func (*TestRegistry) Discover ¶
func (t *TestRegistry) Discover(url *URL) []*URL
func (*TestRegistry) GetName ¶
func (t *TestRegistry) GetName() string
func (*TestRegistry) GetRegisteredServices ¶
func (t *TestRegistry) GetRegisteredServices() []*URL
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 URL ¶
type URL struct { Protocol string Host string Port int Path string //e.g. service name Group string Parameters map[string]string // contains filtered or unexported fields }
func FromExtInfo ¶
func (*URL) ClearCachedInfo ¶
func (u *URL) ClearCachedInfo()
func (*URL) CompositeAddresses ¶
func (*URL) GetAddressStr ¶
func (*URL) GetIdentity ¶
GetIdentity return the identity of url. identity info includes protocol, host, port, path, group the identity will cached, so must clear cached info after update above info by calling ClearCachedInfo()
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.