Skip to content

Commit

Permalink
Merge c869b5e into d204c4e
Browse files Browse the repository at this point in the history
  • Loading branch information
FinalT authored Dec 27, 2023
2 parents d204c4e + c869b5e commit e5a7f69
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
5 changes: 3 additions & 2 deletions config/application_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ type ApplicationConfig struct {
Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"`
Environment string `yaml:"environment" json:"environment,omitempty" property:"environment"`
// the metadata type. remote or local
MetadataType string `default:"local" yaml:"metadata-type" json:"metadataType,omitempty" property:"metadataType"`
Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"`
MetadataType string `default:"local" yaml:"metadata-type" json:"metadataType,omitempty" property:"metadataType"`
Tag string `yaml:"tag" json:"tag,omitempty" property:"tag"`
MetadataServicePort string `yaml:"metadata-service-port" json:"metadata-service-port,omitempty" property:"metadata-service-port"`
}

// Prefix dubbo.application
Expand Down
19 changes: 18 additions & 1 deletion metadata/service/exporter/configurable/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
)

import (
"dubbo.apache.org/dubbo-go/v3"
"dubbo.apache.org/dubbo-go/v3/common"
"dubbo.apache.org/dubbo-go/v3/common/constant"
"dubbo.apache.org/dubbo-go/v3/common/extension"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error {
SetServiceID(constant.SimpleMetadataServiceName).
SetProtocolIDs(constant.DefaultProtocol).
AddRCProtocol(constant.DefaultProtocol, config.NewProtocolConfigBuilder().
SetName(constant.DefaultProtocol).
SetName(constant.DefaultProtocol).SetPort(getMetadataPort()).
Build()).
SetRegistryIDs("N/A").
SetInterface(constant.MetadataServiceName).
Expand All @@ -84,6 +85,22 @@ func (exporter *MetadataServiceExporter) Export(url *common.URL) error {
return nil
}

func getMetadataPort() string {
rootConfig := config.GetRootConfig()
port := rootConfig.Application.MetadataServicePort
if port == "" {
protocolConfig, ok := rootConfig.Protocols[constant.DefaultProtocol]
if ok {
port = protocolConfig.Port
} else {
logger.Warnf("[Metadata Service] Dubbo-go %s version's MetadataService only support dubbo protocol,"+
"MetadataService will use random port",
dubbo.Version)
}
}
return port
}

// Unexport will unexport the metadataService
func (exporter *MetadataServiceExporter) Unexport() {
if exporter.IsExported() {
Expand Down
21 changes: 21 additions & 0 deletions version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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 dubbo

// dubbo-go version
const Version = "3.1.1"

0 comments on commit e5a7f69

Please sign in to comment.