Documentation ¶
Index ¶
- Constants
- Variables
- func GetLocalIp() string
- func GetReference(service RPCService) string
- func IsEquals(left *URL, right *URL, excludes ...string) bool
- func MatchKey(serviceKey string, protocol string) string
- func ServiceKey(intf string, group string, version string) string
- func SetCompareURLEqualFunc(f CompareURLEqualFunc)
- type AsyncCallback
- type AsyncCallbackService
- type CallbackResponse
- type CompareURLEqualFunc
- type MetadataInfo
- type MethodType
- type Node
- type Option
- func WithIp(ip string) Option
- func WithLocation(location string) Option
- func WithMethods(methods []string) Option
- func WithParams(params url.Values) Option
- func WithParamsValue(key, val string) Option
- func WithPassword(pwd string) Option
- func WithPath(path string) Option
- func WithPort(port string) Option
- func WithProtocol(proto string) Option
- func WithToken(token string) Option
- func WithUsername(username string) Option
- type RPCService
- type ReferencedRPCService
- type RoleType
- type Service
- type ServiceInfo
- type URL
- func (c *URL) AddParam(key string, value string)
- func (c *URL) AddParamAvoidNil(key string, value string)
- func (c *URL) Clone() *URL
- func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL
- func (c *URL) CloneWithParams(reserveParams []string) *URL
- func (c *URL) ColonSeparatedKey() string
- func (c *URL) Compare(comp cm.Comparator) int
- func (c *URL) DelParam(key string)
- func (c *URL) EncodedServiceKey() string
- func (c *URL) GetCacheInvokerMapKey() string
- func (c *URL) GetMethodParam(method string, key string, d string) string
- func (c *URL) GetMethodParamBool(method string, key string, d bool) bool
- func (c *URL) GetMethodParamInt(method string, key string, d int64) int64
- func (c *URL) GetMethodParamInt64(method string, key string, d int64) int64
- func (c *URL) GetMethodParamIntValue(method string, key string, d int) int
- func (c *URL) GetParam(s string, d string) string
- func (c *URL) GetParamAndDecoded(key string) (string, error)
- func (c *URL) GetParamBool(key string, d bool) bool
- func (c *URL) GetParamByIntValue(key string, d int) int
- func (c *URL) GetParamDuration(s string, d string) time.Duration
- func (c *URL) GetParamInt(key string, d int64) int64
- func (c *URL) GetParamInt32(key string, d int32) int32
- func (c *URL) GetParams() url.Values
- func (c *URL) GetRawParam(key string) string
- func (c *URL) Group() string
- func (c *URL) JavaClassName() string
- func (c *URL) Key() string
- func (c *URL) RangeParams(f func(key, value string) bool)
- func (c *URL) ReplaceParams(param url.Values)
- func (c *URL) Service() string
- func (c *URL) ServiceKey() string
- func (c *URL) SetParam(key string, value string)
- func (c *URL) SetParams(m url.Values)
- func (c *URL) String() string
- func (c *URL) ToMap() map[string]string
- func (c *URL) URLEqual(url *URL) bool
- func (c *URL) Version() string
- type URLSlice
Constants ¶
const ( // CONSUMER is consumer role CONSUMER = iota // CONFIGURATOR is configurator role CONFIGURATOR // ROUTER is router role ROUTER // PROVIDER is provider role PROVIDER PROTOCOL = "protocol" )
dubbo role type constant
const (
METHOD_MAPPER = "MethodMapper"
)
for lowercase func
func MethodMapper() map[string][string] { return map[string][string]{} }
Variables ¶
var ( // DubboNodes Dubbo service node DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"} // DubboRole Dubbo service role DubboRole = [...]string{"consumer", "", "routers", "provider"} )
var IncludeKeys = gxset.NewSet( constant.APPLICATION_KEY, constant.GROUP_KEY, constant.TIMESTAMP_KEY, constant.SERIALIZATION_KEY, constant.CLUSTER_KEY, constant.LOADBALANCE_KEY, constant.PATH_KEY, constant.TIMEOUT_KEY, constant.TOKEN_KEY, constant.VERSION_KEY, constant.WARMUP_KEY, constant.WEIGHT_KEY, constant.RELEASE_KEY)
Functions ¶
func GetLocalIp ¶
func GetLocalIp() string
func GetReference ¶
func GetReference(service RPCService) string
GetReference return the reference id of the service. If the service implemented the ReferencedRPCService interface, it will call the Reference method. If not, it will return the struct name as the reference id.
func IsEquals ¶
IsEquals compares if two URLs equals with each other. Excludes are all parameter keys which should ignored.
func SetCompareURLEqualFunc ¶
func SetCompareURLEqualFunc(f CompareURLEqualFunc)
Types ¶
type AsyncCallback ¶
type AsyncCallback func(response CallbackResponse)
AsyncCallback async callback method
type AsyncCallbackService ¶
type AsyncCallbackService interface { // Callback: callback CallBack(response CallbackResponse) }
AsyncCallbackService callback interface for async
type CompareURLEqualFunc ¶
func GetCompareURLEqualFunc ¶
func GetCompareURLEqualFunc() CompareURLEqualFunc
type MetadataInfo ¶
type MetadataInfo struct { Reported bool `json:"-"` App string `json:"app,omitempty"` Revision string `json:"revision,omitempty"` Services map[string]*ServiceInfo `json:"services,omitempty"` }
MetadataInfo the metadata information of instance
func NewMetadataInfo ¶
func NewMetadataInfo(app string, revision string, services map[string]*ServiceInfo) *MetadataInfo
nolint
func (*MetadataInfo) CalAndGetRevision ¶
func (mi *MetadataInfo) CalAndGetRevision() string
CalAndGetRevision is different from Dubbo because golang doesn't support overload so that we should use interface + method name as identifier and ignore the method params in my opinion, it's enough because Dubbo actually ignore the URL params. please refer org.apache.dubbo.common.URL#toParameterString(java.lang.String...)
func (*MetadataInfo) RemoveService ¶
func (mi *MetadataInfo) RemoveService(service *ServiceInfo)
nolint
type MethodType ¶
type MethodType struct {
// contains filtered or unexported fields
}
MethodType is description of service method.
func (*MethodType) ArgsType ¶
func (m *MethodType) ArgsType() []reflect.Type
ArgsType gets @m.argsType.
func (*MethodType) ReplyType ¶
func (m *MethodType) ReplyType() reflect.Type
ReplyType gets @m.replyType.
func (*MethodType) SuiteContext ¶
func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value
SuiteContext transfers @ctx to reflect.Value type or get it from @m.ctxType.
type Option ¶
type Option func(*URL)
Option accepts URL Option will define a function of handling URL
func WithParamsValue ¶
WithParamsValue sets params field for URL
type ReferencedRPCService ¶
type ReferencedRPCService interface { // Reference: // rpc service id or reference id Reference() string }
ReferencedRPCService rpc service interface
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is description of service
type ServiceInfo ¶
type ServiceInfo struct { Name string `json:"name,omitempty"` Group string `json:"group,omitempty"` Version string `json:"version,omitempty"` Protocol string `json:"protocol,omitempty"` Path string `json:"path,omitempty"` Params map[string]string `json:"params,omitempty"` ServiceKey string `json:"-"` MatchKey string `json:"-"` URL *URL `json:"-"` }
ServiceInfo the information of service
func NewServiceInfo ¶
func NewServiceInfo(name, group, version, protocol, path string, params map[string]string) *ServiceInfo
nolint
type URL ¶
type URL struct { Path string // like /com.ikurento.dubbo.UserProvider Username string Password string Methods []string // special for registry SubURL *URL // contains filtered or unexported fields }
URL thread-safe. but this URL should not be copied. we fail to define this struct to be immutable object. but, those method which will update the URL, including SetParam, SetParams are only allowed to be invoked in creating URL instance Please keep in mind that this struct is immutable after it has been created and initialized.
func MergeURL ¶
MergeURL will merge those two URL the result is based on serviceURL, and the key which si only contained in referenceURL will be added into result. for example, if serviceURL contains params (a1->v1, b1->v2) and referenceURL contains params(a2->v3, b1 -> v4) the params of result will be (a1->v1, b1->v2, a2->v3). You should notice that the value of b1 is v2, not v4. due to URL is not thread-safe, so this method is not thread-safe
func NewURLWithOptions ¶
NewURLWithOptions will create a new URL with options
func (*URL) AddParamAvoidNil ¶
AddParamAvoidNil will add key-value pair
func (*URL) CloneWithParams ¶
Copy URL based on the reserved parameter's keys.
func (*URL) ColonSeparatedKey ¶
ColonSeparatedKey The format is "{interface}:[version]:[group]"
func (*URL) EncodedServiceKey ¶
EncodedServiceKey encode the service key
func (*URL) GetCacheInvokerMapKey ¶
GetCacheInvokerMapKey get directory cacheInvokerMap key
func (*URL) GetMethodParam ¶
GetMethodParam gets method param
func (*URL) GetMethodParamBool ¶
GetMethodParamBool judge whether @method param exists or not
func (*URL) GetMethodParamInt ¶
GetMethodParamInt gets int method param
func (*URL) GetMethodParamInt64 ¶
GetMethodParamInt64 gets int64 method param
func (*URL) GetMethodParamIntValue ¶
GetMethodParamIntValue gets int method param
func (*URL) GetParamAndDecoded ¶
GetParamAndDecoded gets values and decode
func (*URL) GetParamBool ¶
GetParamBool judge whether @key exists or not
func (*URL) GetParamByIntValue ¶
GetParamByIntValue gets int value by @key
func (*URL) GetParamDuration ¶
GetParamDuration get duration if param is invalid or missing will return 3s
func (*URL) GetParamInt ¶
GetParamInt gets int64 value by @key
func (*URL) GetParamInt32 ¶
GetParamInt32 gets int32 value by @key
func (*URL) RangeParams ¶
RangeParams will iterate the params
func (*URL) ReplaceParams ¶
ReplaceParams will replace the URL.params usually it should only be invoked when you want to modify an URL, such as MergeURL
func (*URL) ServiceKey ¶
ServiceKey gets a unique key of a service.
func (*URL) SetParam ¶
SetParam will put the key-value pair into URL usually it should only be invoked when you want to initialized an URL
func (*URL) SetParams ¶
SetParams will put all key-value pair into URL. 1. if there already has same key, the value will be override 2. it's not thread safe 3. think twice when you want to invoke this method