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
(WIP) ServiceDiscoveryRegistry implementation #491
Conversation
merge v1.4.0 into develop
Feature/dubbo 2.7.5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Split imports into three blocks. You can take other files as reference.
- Add comments for each public method, structure, interface.
- Please rebase or merge the 2.7.5 branch.
@@ -18,11 +18,11 @@ | |||
package extension | |||
|
|||
import ( | |||
"github.com/apache/dubbo-go/registry" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
) | ||
|
||
func SetServiceNameMapping(name string, creator func() mapping.ServiceNameMapping) { | ||
// TODO(@邓大明) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use english pls
} | ||
|
||
func GetServiceNameMapping(name string) mapping.ServiceNameMapping { | ||
// TODO(@邓大明) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as above
"github.com/apache/dubbo-go/common" | ||
"github.com/apache/dubbo-go/common/extension" | ||
"github.com/apache/dubbo-go/registry" | ||
"github.com/apache/dubbo-go/registry/service/instance" | ||
"math/rand" | ||
"time" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split those package
"github.com/apache/dubbo-go/common" | ||
"github.com/apache/dubbo-go/registry" | ||
"github.com/stretchr/testify/assert" | ||
"testing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format those package
s.lock.Lock() | ||
// 1. expunge stale | ||
s.expungeStaleRevisionExportedURLs(serviceInstances) | ||
// 2. Initialize | ||
s.initRevisionExportedURLs(serviceInstances) | ||
s.lock.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think this lock is too large, can shorten it?
currentRevision := gxset.NewSet() | ||
for _, s := range serviceInstances { | ||
rv := getExportedServicesRevision(s) | ||
if len(rv) != 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(rv) != 0 { | |
if len(rv) > 0 { |
) | ||
|
||
func TestServiceDiscoveryRegistry_Register(t *testing.T) { | ||
//registryURL,_:=common.NewURL("in-memory://localhost:12345", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete it if useless
"github.com/apache/dubbo-go/common" | ||
"github.com/apache/dubbo-go/common/constant" | ||
"github.com/apache/dubbo-go/registry" | ||
"github.com/apache/dubbo-go/registry/service/synthesizer" | ||
"net/url" | ||
"strings" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
"github.com/apache/dubbo-go/common" | ||
"github.com/apache/dubbo-go/common/constant" | ||
"github.com/apache/dubbo-go/registry" | ||
"github.com/stretchr/testify/assert" | ||
"net/url" | ||
"testing" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format
Fix Some Bug and merger origin/develop
2、format imports
Codecov Report
@@ Coverage Diff @@
## feature/dubbo-2.7.5 #491 +/- ##
=======================================================
- Coverage 66.81% 64.53% -2.29%
=======================================================
Files 196 202 +6
Lines 10125 10596 +471
=======================================================
+ Hits 6765 6838 +73
- Misses 2708 3103 +395
- Partials 652 655 +3
Continue to review full report at Codecov.
|
…nto feature/dubbo-2.7.5 # Conflicts: # config/service_config.go # config/service_config_test.go # go.sum
config/config_loader.go
Outdated
svs.id = key | ||
svs.Implement(rpcService) | ||
if err := svs.Export(); err != nil { | ||
panic(fmt.Sprintf("service %s export failed! err: %#v", key, err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hi, new guy, pls use %+v for error to handle nil-error or self-defined error.
config/service_config.go
Outdated
@@ -113,6 +113,24 @@ func NewServiceConfig(id string, context context.Context) *ServiceConfig { | |||
} | |||
} | |||
|
|||
// Get Random Port | |||
func getRandomPort(protocolConfigs []*ProtocolConfig) *list.List { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this work has been done by Mr Zouyx. why u do it again?
config/config_loader.go
Outdated
extension.SetAndInitGlobalDispatcher(providerConfig.eventDispatcherType) | ||
|
||
extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same to line 184?
config/config_loader.go
Outdated
extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType) | ||
|
||
extension.SetAndInitGlobalDispatcher(consumerConfig.eventDispatcherType) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the same to line 105?
registry/event_listener.go
Outdated
return e.ServiceName == sicl.ServiceName | ||
} | ||
|
||
type ChangedNotify interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it move to parent package?
func SetMetadataServiceProxy(name string, creator func() BaseMetadataServiceProxy) { | ||
//TODO | ||
} | ||
|
||
func GetMetadataServiceProxy(name string) BaseMetadataServiceProxy { | ||
//TODO | ||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should implement?
|
||
//IsAvailable for make sure is't available | ||
func (s *serviceDiscoveryRegistry) IsAvailable() bool { | ||
return true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
always true?
Merge nacos metadata report implementation
Codecov Report
@@ Coverage Diff @@
## feature/dubbo-2.7.5 #491 +/- ##
=======================================================
- Coverage 66.06% 63.63% -2.43%
=======================================================
Files 203 210 +7
Lines 10558 11163 +605
=======================================================
+ Hits 6975 7104 +129
- Misses 2909 3371 +462
- Partials 674 688 +14
Continue to review full report at Codecov.
|
}) | ||
} | ||
|
||
// StoreConsumerMetadata will store the metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
store the consumer metadata.
client config_client.IConfigClient | ||
} | ||
|
||
// StoreProviderMetadata will store the metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
store the provider metadata
}) | ||
} | ||
|
||
// SaveServiceMetadata will store the metadata |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
save the service metadata.
} | ||
|
||
bytes, err := json.Marshal(urlStrList) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this blank line.
|
||
package nacos | ||
|
||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
split.
remoting/nacos/builder.go
Outdated
if err != nil { | ||
return nil, err | ||
} | ||
clientConfig.TimeoutMs = uint64(timeout.Seconds() * 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls init the config in a struct.
clientConfig := nacosConstant.ClientConfig {
xxx: xxx,
}
It can be found by consumer
Invoke dubbo server success
#420