Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge develop to 2.7.5 #500

Merged
merged 61 commits into from
May 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
42447f8
add license
zouyx Mar 20, 2020
d7b02cd
Mod: readme.md & change.md
fangyincheng Mar 22, 2020
b9a94e5
Mod: release note
fangyincheng Mar 22, 2020
39098b8
Del: delete osx in .travis.yml
fangyincheng Mar 22, 2020
2253ad0
Merge pull request #449 from fangyincheng/1.4
fangyincheng Mar 22, 2020
320e307
Merge pull request #451 from zouyx/1.4-fix-license
hxmhlt Mar 23, 2020
ed2fa0c
Add:registry directory extension
hxmhlt Apr 7, 2020
54dc74a
Mod: upper RegistryDirectory for inherit
hxmhlt Apr 7, 2020
6b58f6c
Update registry/directory/directory.go
hxmhlt Apr 8, 2020
5d630ca
Update registry/directory/directory.go
hxmhlt Apr 8, 2020
57fa801
Update registry/directory/directory.go
hxmhlt Apr 8, 2020
34c52a1
Update registry/directory/directory.go
hxmhlt Apr 8, 2020
eac6b63
Add:new func type
hxmhlt Apr 8, 2020
a4e9a02
Merge branch 'extension_directory' of https://github.com/hxmhlt/dubbo…
hxmhlt Apr 8, 2020
cf80d06
Update: hessian2 & getty version
AlexStocks Apr 10, 2020
9e06cc2
add simplified attribute in registry config
Apr 11, 2020
ef33eb1
go fmt
Apr 11, 2020
4ea624b
add license
Apr 11, 2020
01bbba5
improve code
Apr 11, 2020
b25b628
fix
Apr 11, 2020
c979fca
Merge pull request #466 from hxmhlt/extension_directory
hxmhlt Apr 11, 2020
2532b49
Mod: gofmt all go files
AlexStocks Apr 11, 2020
d6ab9d1
Add: license header
AlexStocks Apr 12, 2020
b330db7
Fix: add PATH_SEPARATOR
AlexStocks Apr 12, 2020
862bf03
Merge pull request #473 from divebomb/develop
AlexStocks Apr 12, 2020
0098b2b
fix
Apr 12, 2020
b57ba60
fix
Apr 12, 2020
71e2e17
Merge branch 'develop' into simplified
Apr 12, 2020
258a6e9
fix
Apr 12, 2020
8d92fcb
go mod
Apr 12, 2020
68602ee
add start provider with random port
zouyx Apr 12, 2020
c8f66ac
Merge pull request #474 from dubbo-x/simplified
flycash Apr 13, 2020
a2a3adc
modify test
zouyx Apr 13, 2020
3c19887
modify start provider with random port
zouyx Apr 14, 2020
cc1f480
modify start provider with random port
zouyx Apr 14, 2020
2810c63
modify test
zouyx Apr 14, 2020
ceb0292
a little refactor
cch-4321 Apr 17, 2020
b4df125
extract router init to func
cch-4321 Apr 18, 2020
f9eeb8b
modify random port implement
zouyx Apr 18, 2020
5076a4f
fix test case error
zouyx Apr 18, 2020
5bdbf08
Merge pull request #481 from cch123/develop
flycash Apr 19, 2020
86dfd94
update v1.4.0 tag link in readme
wongoo Apr 20, 2020
c50325b
add v1.4.0 link in readme
wongoo Apr 20, 2020
59d0da3
merge develop to 1.4
wongoo Apr 20, 2020
50ad24f
Merge pull request #486 from wongoo/1.4
zouyx Apr 20, 2020
58dd5bd
Add comments for ServiceMethodLimiter
Apr 23, 2020
42dbf0d
Merge pull request #490 from flycash/doc-comments
flycash Apr 23, 2020
f04c170
Mod: add comment and modify log level
fangyincheng Apr 25, 2020
74212fd
modify implement
zouyx Apr 25, 2020
5582a70
Add comments
Apr 27, 2020
b5d169c
Merge pull request #492 from fangyincheng/add-comment
flycash Apr 27, 2020
bc6cc20
Merge pull request #496 from flycash/doc-comments
flycash Apr 27, 2020
c05e5c1
modify implement
zouyx Apr 27, 2020
5d7a277
Merge branch 'develop' into feature/randomPort
zouyx Apr 27, 2020
af29f5b
travis trigger
zouyx Apr 27, 2020
e4fc89d
travis trigger
zouyx Apr 27, 2020
7711df8
change variable name
zouyx Apr 27, 2020
fcaa44a
fix review comments
zouyx Apr 28, 2020
94414e4
fix review comments
zouyx Apr 28, 2020
24e7205
Merge pull request #476 from zouyx/feature/randomPort
fangyincheng Apr 28, 2020
59365ec
Merge develop
May 2, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Apache License, Version 2.0

## Release note ##

[v1.4.0-rc1 - Mar 12, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1)
[v1.4.0 - Mar 17, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.4.0)

[v1.3.0 - Mar 1, 2020](https://github.com/apache/dubbo-go/releases/tag/v1.3.0)

Expand Down
2 changes: 1 addition & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Apache License, Version 2.0

## 发布日志 ##

[v1.4.0-rc1 - 2020年3月12日](https://github.com/apache/dubbo-go/releases/tag/v1.4.0-rc1)
[v1.4.0 - 2020年3月17日](https://github.com/apache/dubbo-go/releases/tag/v1.4.0)

[v1.3.0 - 2020年3月1日](https://github.com/apache/dubbo-go/releases/tag/v1.3.0)

Expand Down
41 changes: 41 additions & 0 deletions common/extension/registry_directory.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package extension

import (
"github.com/apache/dubbo-go/cluster"
"github.com/apache/dubbo-go/common"
"github.com/apache/dubbo-go/registry"
)

type registryDirectory func(url *common.URL, registry registry.Registry) (cluster.Directory, error)

var defaultRegistry registryDirectory

// SetDefaultRegistryDirectory ...
func SetDefaultRegistryDirectory(v registryDirectory) {
defaultRegistry = v
}

// GetDefaultRegistryDirectory ...
func GetDefaultRegistryDirectory(config *common.URL, registry registry.Registry) (cluster.Directory, error) {
if defaultRegistry == nil {
panic("registry directory is not existing, make sure you have import the package.")
}
return defaultRegistry(config, registry)
}
7 changes: 3 additions & 4 deletions common/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
typError = reflect.Zero(reflect.TypeOf((*error)(nil)).Elem()).Type()
)

// NewProxy ...
// NewProxy create service proxy.
func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[string]string) *Proxy {
return &Proxy{
invoke: invoke,
Expand All @@ -59,7 +59,6 @@ func NewProxy(invoke protocol.Invoker, callBack interface{}, attachments map[str
// type XxxProvider struct {
// Yyy func(ctx context.Context, args []interface{}, rsp *Zzz) error
// }

func (p *Proxy) Implement(v common.RPCService) {

// check parameters, incoming interface must be a elem's pointer.
Expand Down Expand Up @@ -202,12 +201,12 @@ func (p *Proxy) Implement(v common.RPCService) {

}

// Get ...
// Get get rpc service instance.
func (p *Proxy) Get() common.RPCService {
return p.rpc
}

// GetCallback ...
// GetCallback get callback.
func (p *Proxy) GetCallback() interface{} {
return p.callBack
}
2 changes: 1 addition & 1 deletion common/proxy/proxy_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/apache/dubbo-go/protocol"
)

// ProxyFactory ...
// ProxyFactory interface.
type ProxyFactory interface {
GetProxy(invoker protocol.Invoker, url *common.URL) *Proxy
GetAsyncProxy(invoker protocol.Invoker, callBack interface{}, url *common.URL) *Proxy
Expand Down
23 changes: 11 additions & 12 deletions common/rpc_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ type AsyncCallback func(response CallbackResponse)
// return map[string][string]{}
// }
const (
// METHOD_MAPPER ...
METHOD_MAPPER = "MethodMapper"
)

Expand All @@ -68,7 +67,7 @@ var (
// because Typeof takes an empty interface value. This is annoying.
typeOfError = reflect.TypeOf((*error)(nil)).Elem()

// ServiceMap ...
// ServiceMap store description of service.
// todo: lowerecas?
ServiceMap = &serviceMap{
serviceMap: make(map[string]map[string]*Service),
Expand All @@ -80,35 +79,35 @@ var (
// info of method
//////////////////////////

// MethodType ...
// MethodType is description of service method.
type MethodType struct {
method reflect.Method
ctxType reflect.Type // request context
argsType []reflect.Type // args except ctx, include replyType if existing
replyType reflect.Type // return value, otherwise it is nil
}

// Method ...
// Method get @m.method.
func (m *MethodType) Method() reflect.Method {
return m.method
}

// CtxType ...
// CtxType get @m.ctxType.
func (m *MethodType) CtxType() reflect.Type {
return m.ctxType
}

// ArgsType ...
// ArgsType get @m.argsType.
func (m *MethodType) ArgsType() []reflect.Type {
return m.argsType
}

// ReplyType ...
// ReplyType get @m.replyType.
func (m *MethodType) ReplyType() reflect.Type {
return m.replyType
}

// SuiteContext ...
// SuiteContext tranfer @ctx to reflect.Value type or get it from @m.ctxType.
func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value {
if contextv := reflect.ValueOf(ctx); contextv.IsValid() {
return contextv
Expand All @@ -120,15 +119,15 @@ func (m *MethodType) SuiteContext(ctx context.Context) reflect.Value {
// info of service interface
//////////////////////////

// Service ...
// Service is description of service
type Service struct {
name string
rcvr reflect.Value
rcvrType reflect.Type
methods map[string]*MethodType
}

// Method ...
// Method get @s.methods.
func (s *Service) Method() map[string]*MethodType {
return s.methods
}
Expand All @@ -138,12 +137,12 @@ func (s *Service) Name() string {
return s.name
}

// RcvrType ...
// RcvrType get @s.rcvrType.
func (s *Service) RcvrType() reflect.Type {
return s.rcvrType
}

// Rcvr ...
// Rcvr get @s.rcvr.
func (s *Service) Rcvr() reflect.Value {
return s.rcvr
}
Expand Down
71 changes: 42 additions & 29 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ func NewURLWithOptions(opts ...option) *URL {
// NewURL will create a new url
// the urlString should not be empty
func NewURL(urlString string, opts ...option) (URL, error) {

var (
err error
rawUrlString string
Expand Down Expand Up @@ -249,7 +248,7 @@ func NewURL(urlString string, opts ...option) (URL, error) {
return s, nil
}

// URLEqual ...
// URLEqual judge @url and @c is equal or not.
func (c URL) URLEqual(url URL) bool {
c.Ip = ""
c.Port = ""
Expand All @@ -265,17 +264,19 @@ func (c URL) URLEqual(url URL) bool {
} else if urlGroup == constant.ANY_VALUE {
urlKey = strings.Replace(urlKey, "group=*", "group="+cGroup, 1)
}

// 1. protocol, username, password, ip, port, service name, group, version should be equal
if cKey != urlKey {
return false
}

// 2. if url contains enabled key, should be true, or *
if url.GetParam(constant.ENABLED_KEY, "true") != "true" && url.GetParam(constant.ENABLED_KEY, "") != constant.ANY_VALUE {
return false
}

//TODO :may need add interface key any value condition
if !isMatchCategory(url.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), c.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY)) {
return false
}
return true
return isMatchCategory(url.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY), c.GetParam(constant.CATEGORY_KEY, constant.DEFAULT_CATEGORY))
}

func isMatchCategory(category1 string, category2 string) bool {
Expand Down Expand Up @@ -313,10 +314,9 @@ func (c URL) Key() string {
"%s://%s:%s@%s:%s/?interface=%s&group=%s&version=%s",
c.Protocol, c.Username, c.Password, c.Ip, c.Port, c.Service(), c.GetParam(constant.GROUP_KEY, ""), c.GetParam(constant.VERSION_KEY, ""))
return buildString
//return c.ServiceKey()
}

// ServiceKey ...
// ServiceKey get a unique key of a service.
func (c URL) ServiceKey() string {
intf := c.GetParam(constant.INTERFACE_KEY, strings.TrimPrefix(c.Path, "/"))
if intf == "" {
Expand Down Expand Up @@ -409,12 +409,12 @@ func (c *URL) RangeParams(f func(key, value string) bool) {

// GetParam ...
func (c URL) GetParam(s string, d string) string {
var r string
c.paramsLock.RLock()
if r = c.params.Get(s); len(r) == 0 {
defer c.paramsLock.RUnlock()
r := c.params.Get(s)
if len(r) == 0 {
r = d
}
c.paramsLock.RUnlock()
return r
}

Expand Down Expand Up @@ -454,33 +454,26 @@ func (c URL) GetRawParam(key string) string {

// GetParamBool ...
func (c URL) GetParamBool(s string, d bool) bool {

var r bool
var err error
if r, err = strconv.ParseBool(c.GetParam(s, "")); err != nil {
r, err := strconv.ParseBool(c.GetParam(s, ""))
if err != nil {
return d
}
return r
}

// GetParamInt ...
func (c URL) GetParamInt(s string, d int64) int64 {
var r int
var err error

if r, err = strconv.Atoi(c.GetParam(s, "")); r == 0 || err != nil {
r, err := strconv.Atoi(c.GetParam(s, ""))
if r == 0 || err != nil {
return d
}
return int64(r)
}

// GetMethodParamInt ...
func (c URL) GetMethodParamInt(method string, key string, d int64) int64 {
var r int
var err error
c.paramsLock.RLock()
defer c.paramsLock.RUnlock()
if r, err = strconv.Atoi(c.GetParam("methods."+method+"."+key, "")); r == 0 || err != nil {
r, err := strconv.Atoi(c.GetParam("methods."+method+"."+key, ""))
if r == 0 || err != nil {
return d
}
return int64(r)
Expand All @@ -492,14 +485,13 @@ func (c URL) GetMethodParamInt64(method string, key string, d int64) int64 {
if r == math.MinInt64 {
return c.GetParamInt(key, d)
}

return r
}

// GetMethodParam ...
func (c URL) GetMethodParam(method string, key string, d string) string {
var r string
if r = c.GetParam("methods."+method+"."+key, ""); r == "" {
r := c.GetParam("methods."+method+"."+key, "")
if r == "" {
r = d
}
return r
Expand Down Expand Up @@ -530,7 +522,6 @@ func (c *URL) SetParams(m url.Values) {

// ToMap transfer URL to Map
func (c URL) ToMap() map[string]string {

paramsMap := make(map[string]string)

c.RangeParams(func(key, value string) bool {
Expand Down Expand Up @@ -615,8 +606,30 @@ func (c *URL) Clone() *URL {
return newUrl
}

// Copy url based on the reserved parameters' keys.
func (c *URL) CloneWithParams(reserveParams []string) *URL {
params := url.Values{}
for _, reserveParam := range reserveParams {
v := c.GetParam(reserveParam, "")
if len(v) != 0 {
params.Set(reserveParam, v)
}
}

return NewURLWithOptions(
WithProtocol(c.Protocol),
WithUsername(c.Username),
WithPassword(c.Password),
WithIp(c.Ip),
WithPort(c.Port),
WithPath(c.Path),
WithMethods(c.Methods),
WithParams(params),
)
}

func mergeNormalParam(mergedUrl *URL, referenceUrl *URL, paramKeys []string) []func(method string) {
var methodConfigMergeFcn = []func(method string){}
methodConfigMergeFcn := make([]func(method string), 0, len(paramKeys))
for _, paramKey := range paramKeys {
if v := referenceUrl.GetParam(paramKey, ""); len(v) > 0 {
mergedUrl.SetParam(paramKey, v)
Expand Down
Loading