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

fix branch conflict between main and dev3.3 #2751

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go_version }}
go-version: ${{ matrix.golang }}
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v3.4.0
with:
version: v1.54
args: --timeout=10m
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ metadata/report/zookeeper/zookeeper-4unittest/

# macOS
.DS_Store
.history
17 changes: 0 additions & 17 deletions client/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ func (refOpts *ReferenceOptions) refer(srv common.RPCService, info *ClientInfo)
refOpts.urls = urls
refOpts.invoker = invoker

// publish consumer's metadata
publishServiceDefinition(cfgURL)
// create proxy
if info == nil && srv != nil {
if ref.Async {
Expand Down Expand Up @@ -279,21 +277,6 @@ func buildInvoker(urls []*common.URL, ref *global.ReferenceConfig) (protocol.Inv
return resInvoker, nil
}

func publishServiceDefinition(url *common.URL) {
localService, err := extension.GetLocalMetadataService(constant.DefaultKey)
if err != nil {
logger.Warnf("get local metadata service failed, please check if you have imported _ \"dubbo.apache.org/dubbo-go/v3/metadata/service/local\"")
return
}
localService.PublishServiceDefinition(url)
if url.GetParam(constant.MetadataTypeKey, "") != constant.RemoteMetadataStorageType {
return
}
if remoteMetadataService, err := extension.GetRemoteMetadataService(); err == nil && remoteMetadataService != nil {
remoteMetadataService.PublishServiceDefinition(url)
}
}

func (refOpts *ReferenceOptions) CheckAvailable() bool {
ref := refOpts.Reference
if refOpts.invoker == nil {
Expand Down
44 changes: 44 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ package client

import (
"context"
"time"
)

import (
"dubbo.apache.org/dubbo-go/v3/common"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/global"
"dubbo.apache.org/dubbo-go/v3/metadata"
"dubbo.apache.org/dubbo-go/v3/protocol"
invocation_impl "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
)
Expand Down Expand Up @@ -118,6 +121,9 @@ func (cli *Client) DialWithDefinition(interfaceName string, definition *ClientDe
}

func (cli *Client) dial(interfaceName string, info *ClientInfo, opts ...ReferenceOption) (*Connection, error) {
if err := cli.initRegistryMetadataReport(); err != nil {
return nil, err
}
newRefOpts := defaultReferenceOptions()
finalOpts := []ReferenceOption{
setReference(cli.cliOpts.overallReference),
Expand All @@ -138,6 +144,44 @@ func (cli *Client) dial(interfaceName string, info *ClientInfo, opts ...Referenc
return &Connection{refOpts: newRefOpts}, nil
}

func (cli *Client) initRegistryMetadataReport() error {
if len(cli.cliOpts.Registries) > 0 {
for id, reg := range cli.cliOpts.Registries {
if reg.UseAsMetaReport == "true" {
opts, err := registryToReportOptions(id, reg)
if err != nil {
return err
}
if err := opts.Init(); err != nil {
return err
}
}
}
}
return nil
}

func registryToReportOptions(id string, rc *global.RegistryConfig) (*metadata.ReportOptions, error) {
opts := metadata.NewReportOptions(
metadata.WithRegistryId(id),
metadata.WithProtocol(rc.Protocol),
metadata.WithAddress(rc.Address),
metadata.WithUsername(rc.Username),
metadata.WithPassword(rc.Password),
metadata.WithGroup(rc.Group),
metadata.WithNamespace(rc.Namespace),
metadata.WithParams(rc.Params),
)
if rc.Timeout != "" {
timeout, err := time.ParseDuration(rc.Timeout)
if err != nil {
return nil, err
}
metadata.WithTimeout(timeout)(opts)
}
return opts, nil
}

func generateInvocation(methodName string, reqs []interface{}, resp interface{}, callType string, opts *CallOptions) (protocol.Invocation, error) {
var paramsRawVals []interface{}
for _, req := range reqs {
Expand Down
2 changes: 2 additions & 0 deletions common/constant/key.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ const (
// registry keys
const (
RegistryKey = "registry"
RegistryIdKey = "registry.id"
RegistryProtocol = "registry"
ServiceRegistryProtocol = "service-discovery-registry"
RegistryRoleKey = "registry.role"
Expand All @@ -186,6 +187,7 @@ const (

const (
ApplicationKey = "application"
ApplicationTagKey = "application.tag"
OrganizationKey = "organization"
NameKey = "name"
ModuleKey = "module"
Expand Down
51 changes: 0 additions & 51 deletions common/extension/metadata_remote.go

This file was deleted.

8 changes: 4 additions & 4 deletions common/extension/metadata_report_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@
package extension

import (
"dubbo.apache.org/dubbo-go/v3/metadata/report/factory"
"dubbo.apache.org/dubbo-go/v3/metadata/report"
)

var metaDataReportFactories = make(map[string]func() factory.MetadataReportFactory, 8)
var metaDataReportFactories = make(map[string]func() report.MetadataReportFactory, 8)

// SetMetadataReportFactory sets the MetadataReportFactory with @name
func SetMetadataReportFactory(name string, v func() factory.MetadataReportFactory) {
func SetMetadataReportFactory(name string, v func() report.MetadataReportFactory) {
metaDataReportFactories[name] = v
}

// GetMetadataReportFactory finds the MetadataReportFactory with @name
func GetMetadataReportFactory(name string) factory.MetadataReportFactory {
func GetMetadataReportFactory(name string) report.MetadataReportFactory {
if metaDataReportFactories[name] == nil {
return nil
}
Expand Down
55 changes: 0 additions & 55 deletions common/extension/metadata_service.go

This file was deleted.

46 changes: 0 additions & 46 deletions common/extension/metadata_service_exporter.go

This file was deleted.

50 changes: 0 additions & 50 deletions common/extension/metadata_service_proxy_factory.go

This file was deleted.

Loading
Loading