common

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2020 License: Apache-2.0 Imports: 19 Imported by: 37

Documentation

Index

Constants

View Source
const (
	// CONSUMER is consumer role
	CONSUMER = iota
	// CONFIGURATOR is configurator role
	CONFIGURATOR
	// ROUTER is router role
	ROUTER
	// PROVIDER is provider role
	PROVIDER
	PROTOCOL = "protocol"
)

role constant

View Source
const (
	METHOD_MAPPER = "MethodMapper"
)

for lowercase func

func MethodMapper() map[string][string] {
    return map[string][string]{}
}

Variables

View Source
var (
	// DubboNodes Dubbo service node
	DubboNodes = [...]string{"consumers", "configurators", "routers", "providers"}
	// DubboRole Dubbo service role
	DubboRole = [...]string{"consumer", "", "routers", "provider"}
)
View Source
var (

	// ServiceMap store description of service.
	ServiceMap = &serviceMap{
		serviceMap:   make(map[string]map[string]*Service),
		interfaceMap: make(map[string][]*Service),
	}
)

Functions

func IsEquals added in v1.5.3

func IsEquals(left URL, right URL, excludes ...string) bool

IsEquals compares if two URLs equals with each other. Excludes are all parameter keys which should ignored.

func ServiceKey added in v1.5.3

func ServiceKey(intf string, group string, version string) string

func WithIp

func WithIp(ip string) option

WithIp sets ip for url

func WithLocation added in v1.2.0

func WithLocation(location string) option

WithLocation sets location for url

func WithMethods

func WithMethods(methods []string) option

WithMethods sets methods for url

func WithParams

func WithParams(params url.Values) option

WithParams sets params for url

func WithParamsValue

func WithParamsValue(key, val string) option

WithParamsValue sets params field for url

func WithPassword

func WithPassword(pwd string) option

WithPassword sets password for url

func WithPath

func WithPath(path string) option

WithPath sets path for url

func WithPort

func WithPort(port string) option

WithPort sets port for url

func WithProtocol

func WithProtocol(proto string) option

WithProtocol sets protocol for url

func WithToken added in v1.2.0

func WithToken(token string) option

WithToken sets token for url

func WithUsername

func WithUsername(username string) option

WithUsername sets username for url

Types

type AsyncCallback added in v1.3.0

type AsyncCallback func(response CallbackResponse)

AsyncCallback async callback method

type AsyncCallbackService added in v1.3.0

type AsyncCallbackService interface {
	// Callback: callback
	CallBack(response CallbackResponse)
}

AsyncCallbackService callback interface for async

type CallbackResponse added in v1.3.0

type CallbackResponse interface{}

CallbackResponse for different protocol

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) CtxType

func (m *MethodType) CtxType() reflect.Type

CtxType gets @m.ctxType.

func (*MethodType) Method

func (m *MethodType) Method() reflect.Method

Method gets @m.method.

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 tranfers @ctx to reflect.Value type or get it from @m.ctxType.

type Node

type Node interface {
	GetUrl() URL
	IsAvailable() bool
	Destroy()
}

Node use for process dubbo node

type RPCService

type RPCService interface {
	// Reference:
	// rpc service id or reference id
	Reference() string
}

RPCService rpc service interface

type RoleType

type RoleType int

nolint

func (RoleType) Role

func (t RoleType) Role() string

Role returns role by @RoleType

func (RoleType) String

func (t RoleType) String() string

type Service

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

Service is description of service

func (*Service) Method

func (s *Service) Method() map[string]*MethodType

Method gets @s.methods.

func (*Service) Name added in v1.5.0

func (s *Service) Name() string

Name will return service name

func (*Service) Rcvr

func (s *Service) Rcvr() reflect.Value

Rcvr gets @s.rcvr.

func (*Service) RcvrType

func (s *Service) RcvrType() reflect.Type

RcvrType gets @s.rcvrType.

type URL

type URL struct {
	Path     string // like  /com.ikurento.dubbo.UserProvider3
	Username string
	Password string
	Methods  []string
	// special for registry
	SubURL *URL
	// contains filtered or unexported fields
}

URL is not thread-safe. 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

func MergeUrl(serviceUrl *URL, referenceUrl *URL) *URL

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 NewURL

func NewURL(urlString string, opts ...option) (URL, error)

NewURL will create a new url the urlString should not be empty

func NewURLWithOptions

func NewURLWithOptions(opts ...option) *URL

NewURLWithOptions will create a new url with options

func (*URL) AddParam

func (c *URL) AddParam(key string, value string)

AddParam will add the key-value pair Not thread-safe think twice before using it.

func (*URL) AddParamAvoidNil added in v1.5.3

func (c *URL) AddParamAvoidNil(key string, value string)

AddParamAvoidNil will add key-value pair Not thread-safe think twice before using it.

func (*URL) Clone added in v1.2.0

func (c *URL) Clone() *URL

Clone will copy the url

func (*URL) CloneExceptParams added in v1.5.0

func (c *URL) CloneExceptParams(excludeParams *gxset.HashSet) *URL

func (*URL) CloneWithParams added in v1.5.0

func (c *URL) CloneWithParams(reserveParams []string) *URL

Copy url based on the reserved parameter's keys.

func (*URL) ColonSeparatedKey added in v1.4.0

func (c *URL) ColonSeparatedKey() string

ColonSeparatedKey The format is "{interface}:[version]:[group]"

func (*URL) EncodedServiceKey added in v1.2.0

func (c *URL) EncodedServiceKey() string

EncodedServiceKey encode the service key

func (URL) GetMethodParam

func (c URL) GetMethodParam(method string, key string, d string) string

GetMethodParam gets method param

func (URL) GetMethodParamBool added in v1.3.0

func (c URL) GetMethodParamBool(method string, key string, d bool) bool

GetMethodParamBool judge whether @method param exists or not

func (URL) GetMethodParamInt

func (c URL) GetMethodParamInt(method string, key string, d int64) int64

GetMethodParamInt gets int method param

func (URL) GetMethodParamInt64

func (c URL) GetMethodParamInt64(method string, key string, d int64) int64

GetMethodParamInt64 gets int64 method param

func (URL) GetParam

func (c URL) GetParam(s string, d string) string

GetParam gets value by key

func (URL) GetParamAndDecoded

func (c URL) GetParamAndDecoded(key string) (string, error)

GetParamAndDecoded gets values and decode

func (URL) GetParamBool

func (c URL) GetParamBool(key string, d bool) bool

GetParamBool judge whether @key exists or not

func (URL) GetParamInt

func (c URL) GetParamInt(key string, d int64) int64

GetParamInt gets int value by @key

func (URL) GetParams added in v1.2.0

func (c URL) GetParams() url.Values

GetParams gets values

func (URL) GetRawParam

func (c URL) GetRawParam(key string) string

GetRawParam gets raw param

func (URL) Key

func (c URL) Key() string

Key gets key

func (*URL) RangeParams added in v1.2.0

func (c *URL) RangeParams(f func(key, value string) bool)

RangeParams will iterate the params it's not thread-safe

func (URL) Service

func (c URL) Service() string

Service gets service

func (URL) ServiceKey

func (c URL) ServiceKey() string

ServiceKey gets a unique key of a service.

func (*URL) SetParam added in v1.2.0

func (c *URL) SetParam(key string, value string)

SetParam will put the key-value pair into url it's not thread safe. think twice before you want to use this method usually it should only be invoked when you want to initialized an url

func (*URL) SetParams added in v1.2.0

func (c *URL) SetParams(m url.Values)

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

func (URL) String

func (c URL) String() string

func (URL) ToMap

func (c URL) ToMap() map[string]string

ToMap transfer URL to Map

func (URL) URLEqual

func (c URL) URLEqual(url URL) bool

URLEqual judge @url and @c is equal or not.

type URLSlice added in v1.5.0

type URLSlice []URL

URLSlice will be used to sort URL instance Instances will be order by URL.String()

func (URLSlice) Len added in v1.5.0

func (s URLSlice) Len() int

nolint

func (URLSlice) Less added in v1.5.0

func (s URLSlice) Less(i, j int) bool

nolint

func (URLSlice) Swap added in v1.5.0

func (s URLSlice) Swap(i, j int)

nolint

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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