You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by la...@apache.org on 2021/10/30 10:04:50 UTC
[dubbo-go] branch 3.0 updated: Upgreade triple pb generate tool
(#1549)
This is an automated email from the ASF dual-hosted git repository.
laurence pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 669ab0a Upgreade triple pb generate tool (#1549)
669ab0a is described below
commit 669ab0ab3b5f386f339d7b94bb804ec7db753ed6
Author: Laurence <45...@users.noreply.github.com>
AuthorDate: Sat Oct 30 18:04:47 2021 +0800
Upgreade triple pb generate tool (#1549)
* fix: update protoc-gen-go-triple
* fix: remove unused file
* fix: metrics update
* fix: linter
---
common/logger/logger.go | 2 +-
config/application_config.go | 2 +-
config/config_api_test.go | 156 ----------
config/config_center_config.go | 2 +-
config/config_center_config_test.go | 2 +
config/consumer_config.go | 2 +-
config/graceful_shutdown.go | 2 +-
config/logger_config.go | 2 +-
config/metadata_report_config.go | 25 +-
config/method_config.go | 9 -
config/metric_config_test.go | 27 --
config_center/apollo/mockDubbogo.yaml.json | 1 -
filter/metrics/filter.go | 6 -
go.mod | 2 +-
go.sum | 4 +-
metrics/prometheus/reporter.go | 67 +++--
protocol/dubbo3/common_test.go | 43 +--
protocol/dubbo3/dubbo3_protocol.go | 10 +-
protocol/dubbo3/dubbo3_protocol_test.go | 2 +-
protocol/dubbo3/internal/helloworld.pb.go | 363 +++++++++++------------
protocol/dubbo3/internal/helloworld.proto | 1 +
protocol/dubbo3/internal/helloworld_triple.pb.go | 168 +++++++++++
protocol/dubbo3/internal/server.go | 2 +-
23 files changed, 401 insertions(+), 499 deletions(-)
diff --git a/common/logger/logger.go b/common/logger/logger.go
index bc19e46..66ecf4a 100644
--- a/common/logger/logger.go
+++ b/common/logger/logger.go
@@ -79,7 +79,7 @@ func InitLogger(conf *Config) {
EncodeCaller: zapcore.ShortCallerEncoder,
}
config.ZapConfig = &zap.Config{
- Level: zap.NewAtomicLevelAt(zap.DebugLevel),
+ Level: zap.NewAtomicLevelAt(zap.InfoLevel),
Development: false,
Encoding: "console",
EncoderConfig: zapLoggerEncoderConfig,
diff --git a/config/application_config.go b/config/application_config.go
index fb766be..1520e8e 100644
--- a/config/application_config.go
+++ b/config/application_config.go
@@ -32,7 +32,7 @@ type ApplicationConfig struct {
Organization string `default:"dubbo-go" yaml:"organization" json:"organization,omitempty" property:"organization"`
Name string `default:"dubbo.io" yaml:"name" json:"name,omitempty" property:"name"`
Module string `default:"sample" yaml:"module" json:"module,omitempty" property:"module"`
- Version string `default:"0.0.1" yaml:"version" json:"version,omitempty" property:"version"`
+ Version string `default:"3.0.0" yaml:"version" json:"version,omitempty" property:"version"`
Owner string `default:"dubbo-go" yaml:"owner" json:"owner,omitempty" property:"owner"`
Environment string `default:"dev" yaml:"environment" json:"environment,omitempty" property:"environment"`
// the metadata type. remote or local
diff --git a/config/config_api_test.go b/config/config_api_test.go
deleted file mode 100644
index ade9032..0000000
--- a/config/config_api_test.go
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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 config
-
-//
-//func TestNewDefaultServiceConfig(t *testing.T) {
-// serviceConfig := NewServiceConfigByAPI(
-// WithServiceCluster("test-cluster"),
-// WithServiceInterface("test-interface"),
-// WithServiceLoadBalance("test-loadbalance"),
-// WithServiceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithServiceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithServiceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithServiceProtocol("test-protocol"),
-// WithServiceRegistry("test-registry"),
-// WithServiceWarmUpTime("test-warmup"),
-// )
-// assert.Equal(t, serviceConfig.Cluster, "test-cluster")
-// assert.Equal(t, serviceConfig.InterfaceName, "test-interface")
-// assert.Equal(t, serviceConfig.Loadbalance, "test-loadbalance")
-// for i, v := range serviceConfig.Methods {
-// backFix := strconv.Itoa(i + 1)
-// assert.Equal(t, v.Name, "test-method"+backFix)
-// assert.Equal(t, v.Retries, "test-retries"+backFix)
-// assert.Equal(t, v.LoadBalance, "test-lb"+backFix)
-// }
-// assert.Equal(t, serviceConfig.Protocol, "test-protocol")
-// assert.Equal(t, serviceConfig.Registry, "test-registry")
-// assert.Equal(t, serviceConfig.Warmup, "test-warmup")
-//}
-//
-//func TestNewReferenceConfigByAPI(t *testing.T) {
-// refConfig := NewReferenceConfigByAPI(
-// WithReferenceCluster("test-cluster"),
-// WithReferenceInterface("test-interface"),
-// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithReferenceProtocol("test-protocol"),
-// WithReferenceRegistry("test-registry"),
-// )
-// assert.Equal(t, refConfig.Cluster, "test-cluster")
-// assert.Equal(t, refConfig.InterfaceName, "test-interface")
-// for i, v := range refConfig.Methods {
-// backFix := strconv.Itoa(i + 1)
-// assert.Equal(t, v.Name, "test-method"+backFix)
-// assert.Equal(t, v.Retries, "test-retries"+backFix)
-// assert.Equal(t, v.LoadBalance, "test-lb"+backFix)
-// }
-// assert.Equal(t, refConfig.Protocol, "test-protocol")
-// assert.Equal(t, refConfig.Registry, "test-registry")
-//}
-//
-//func TestNewRegistryConfig(t *testing.T) {
-// regConfig := NewRegistryConfig(
-// WithRegistryTimeOut("test-timeout"),
-// WithRegistryProtocol("test-protocol"),
-// WithRegistryGroup("test-group"),
-// WithRegistryAddress("test-address"),
-// WithRegistrySimplified(true),
-// WithRegistryUserName("test-username"),
-// WithRegistryPassword("test-password"),
-// )
-// assert.Equal(t, regConfig.TimeoutStr, "test-timeout")
-// assert.Equal(t, regConfig.Protocol, "test-protocol")
-// assert.Equal(t, regConfig.Group, "test-group")
-// assert.Equal(t, regConfig.Address, "test-address")
-// assert.Equal(t, regConfig.Simplified, true)
-// assert.Equal(t, regConfig.Username, "test-username")
-// assert.Equal(t, regConfig.Password, "test-password")
-//}
-//
-//func TestNewConsumerConfig(t *testing.T) {
-// referConfig := NewReferenceConfigByAPI(
-// WithReferenceCluster("test-cluster"),
-// WithReferenceInterface("test-interface"),
-// WithReferenceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithReferenceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithReferenceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithReferenceProtocol("test-protocol"),
-// WithReferenceRegistry("test-registry"),
-// )
-// defaultZKRegistry := NewRegistryConfigWithProtocolDefaultPort("zookeeper")
-// assert.Equal(t, defaultZKRegistry.Address, defaultZKAddr)
-// assert.Equal(t, defaultZKRegistry.Protocol, "zookeeper")
-// assert.Equal(t, defaultZKRegistry.TimeoutStr, defaultRegistryTimeout)
-//
-// testConsumerConfig := NewConsumerConfig(
-// WithConsumerConfigCheck(true),
-// WithConsumerConnTimeout(time.Minute),
-// WithConsumerRequestTimeout(time.Hour),
-// WithConsumerReferenceConfig("UserProvider", referConfig),
-// WithConsumerRegistryConfig("demoZK", defaultZKRegistry),
-// )
-//
-// assert.Equal(t, *testConsumerConfig.Check, true)
-// assert.Equal(t, testConsumerConfig.ConnectTimeout, time.Minute)
-// assert.Equal(t, testConsumerConfig.RequestTimeout, time.Hour)
-// assert.Equal(t, testConsumerConfig.Registries["demoZK"], defaultZKRegistry)
-// assert.Equal(t, testConsumerConfig.References["UserProvider"], referConfig)
-//}
-//
-//// TestNewProviderConfig test NewProviderConfig api
-//func TestNewProviderConfig(t *testing.T) {
-// serviceConfig := NewServiceConfigByAPI(
-// WithServiceCluster("test-cluster"),
-// WithServiceInterface("test-interface"),
-// WithServiceLoadBalance("test-loadbalance"),
-// WithServiceMethod("test-method1", "test-retries1", "test-lb1"),
-// WithServiceMethod("test-method2", "test-retries2", "test-lb2"),
-// WithServiceMethod("test-method3", "test-retries3", "test-lb3"),
-// WithServiceProtocol("test-protocol"),
-// WithServiceRegistry("test-registry"),
-// WithServiceWarmUpTime("test-warmup"),
-// )
-//
-// defaultNacosRegistry := NewRegistryConfigWithProtocolDefaultPort("nacos")
-// assert.Equal(t, defaultNacosRegistry.Address, defaultNacosAddr)
-// assert.Equal(t, defaultNacosRegistry.Protocol, "nacos")
-// assert.Equal(t, defaultNacosRegistry.TimeoutStr, defaultRegistryTimeout)
-//
-// testProviderConfig := NewProviderConfig(
-// WithProviderServices("UserProvider", serviceConfig),
-// WithProviderProtocol("dubbo", "dubbo", "20000"),
-// WithProviderRegistry("demoNacos", defaultNacosRegistry),
-// )
-//
-// assert.NotNil(t, testProviderConfig.Services)
-// for k, v := range testProviderConfig.Services {
-// assert.Equal(t, k, "UserProvider")
-// assert.Equal(t, v, serviceConfig)
-// }
-// assert.NotNil(t, testProviderConfig.Registries)
-//
-// if registry, ok := testProviderConfig.Registries["demoNacos"]; ok {
-// assert.Equal(t, registry, defaultNacosRegistry)
-// }
-// assert.NotNil(t, testProviderConfig.Protocols)
-// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Name, "dubbo")
-// assert.Equal(t, testProviderConfig.Protocols["dubbo"].Port, "20000")
-//}
diff --git a/config/config_center_config.go b/config/config_center_config.go
index e33ba35..8a64772 100644
--- a/config/config_center_config.go
+++ b/config/config_center_config.go
@@ -167,7 +167,7 @@ func (c *CenterConfig) GetDynamicConfiguration() (config_center.DynamicConfigura
}
dynamicConfig, err := c.CreateDynamicConfiguration()
if err != nil {
- logger.Errorf("Create dynamic configuration error , error message is %v", err)
+ logger.Warnf("Create dynamic configuration error , error message is %v", err)
return nil, errors.WithStack(err)
}
c.DynamicConfiguration = dynamicConfig
diff --git a/config/config_center_config_test.go b/config/config_center_config_test.go
index dca8632..e77e593 100644
--- a/config/config_center_config_test.go
+++ b/config/config_center_config_test.go
@@ -20,9 +20,11 @@ package config
import (
"testing"
)
+
import (
"github.com/stretchr/testify/assert"
)
+
import (
_ "dubbo.apache.org/dubbo-go/v3/config_center/apollo"
)
diff --git a/config/consumer_config.go b/config/consumer_config.go
index a0359dd..930b2e5 100644
--- a/config/consumer_config.go
+++ b/config/consumer_config.go
@@ -120,7 +120,7 @@ func (cc *ConsumerConfig) Load() {
checkok = false
count++
if count > maxWait {
- errMsg := fmt.Sprintf("Request timed out, please check configuration, Failed to check the status of the service %v. No provider available for the service to the consumer use dubbo version %v", refconfig.InterfaceName, constant.Version)
+ errMsg := fmt.Sprintf("No provider available of the service %v.please check configuration.", refconfig.InterfaceName)
logger.Error(errMsg)
panic(errMsg)
}
diff --git a/config/graceful_shutdown.go b/config/graceful_shutdown.go
index 6c0b755..7626413 100644
--- a/config/graceful_shutdown.go
+++ b/config/graceful_shutdown.go
@@ -53,7 +53,7 @@ import (
*/
const defaultShutDownTime = time.Second * 60
-// nolint
+// GracefulShutdownInit todo GracefulShutdownInit in 3.0 should be discusesed.
func GracefulShutdownInit() {
signals := make(chan os.Signal, 1)
diff --git a/config/logger_config.go b/config/logger_config.go
index 444bc38..d36b6d7 100644
--- a/config/logger_config.go
+++ b/config/logger_config.go
@@ -37,7 +37,7 @@ import (
)
type ZapConfig struct {
- Level string `default:"debug" json:"level,omitempty" yaml:"level" property:"level"`
+ Level string `default:"info" json:"level,omitempty" yaml:"level" property:"level"`
Development bool `default:"false" json:"development,omitempty" yaml:"development" property:"development"`
DisableCaller bool `default:"false" json:"disable-caller,omitempty" yaml:"disable-caller" property:"disable-caller"`
DisableStacktrace bool `default:"false" json:"disable-stacktrace,omitempty" yaml:"disable-stacktrace" property:"disable-stacktrace"`
diff --git a/config/metadata_report_config.go b/config/metadata_report_config.go
index f5740d1..6373871 100644
--- a/config/metadata_report_config.go
+++ b/config/metadata_report_config.go
@@ -31,13 +31,14 @@ import (
// MetadataReportConfig is app level configuration
type MetadataReportConfig struct {
- Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
- Address string `required:"true" yaml:"address" json:"address"`
- Username string `yaml:"username" json:"username,omitempty"`
- Password string `yaml:"password" json:"password,omitempty"`
- Timeout string `yaml:"timeout" json:"timeout,omitempty"`
- Group string `yaml:"group" json:"group,omitempty"`
- MetadataType string `default:"local" yaml:"metadata-type" json:"metadata-type"`
+ Protocol string `required:"true" yaml:"protocol" json:"protocol,omitempty"`
+ Address string `required:"true" yaml:"address" json:"address"`
+ Username string `yaml:"username" json:"username,omitempty"`
+ Password string `yaml:"password" json:"password,omitempty"`
+ Timeout string `yaml:"timeout" json:"timeout,omitempty"`
+ Group string `yaml:"group" json:"group,omitempty"`
+ // metadataType of this application is defined by application config, local or remote
+ metadataType string
}
// Prefix dubbo.consumer
@@ -49,7 +50,7 @@ func (mc *MetadataReportConfig) Init(rc *RootConfig) error {
if mc == nil {
return nil
}
- mc.MetadataType = rc.Application.MetadataType
+ mc.metadataType = rc.Application.MetadataType
return mc.StartMetadataReport()
}
@@ -59,7 +60,7 @@ func (mc *MetadataReportConfig) ToUrl() (*common.URL, error) {
common.WithPassword(mc.Password),
common.WithLocation(mc.Address),
common.WithProtocol(mc.Protocol),
- common.WithParamsValue(constant.METADATATYPE_KEY, mc.MetadataType),
+ common.WithParamsValue(constant.METADATATYPE_KEY, mc.metadataType),
)
if err != nil || len(res.Protocol) == 0 {
return nil, perrors.New("Invalid MetadataReport Config.")
@@ -172,12 +173,6 @@ func (mrcb *MetadataReportConfigBuilder) SetGroup(group string) *MetadataReportC
}
// nolint
-func (mrcb *MetadataReportConfigBuilder) SetMetadataType(metadataType string) *MetadataReportConfigBuilder {
- mrcb.metadataReportConfig.MetadataType = metadataType
- return mrcb
-}
-
-// nolint
func (mrcb *MetadataReportConfigBuilder) Build() *MetadataReportConfig {
// TODO Init
return mrcb.metadataReportConfig
diff --git a/config/method_config.go b/config/method_config.go
index 113f928..7c5ba9a 100644
--- a/config/method_config.go
+++ b/config/method_config.go
@@ -76,12 +76,3 @@ func (mc *MethodConfig) check() error {
}
return verify(mc)
}
-
-// UnmarshalYAML unmarshals the MethodConfig by @unmarshal function
-//func (c *MethodConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
-// if err := defaults.Set(c); err != nil {
-// return err
-// }
-// type plain MethodConfig
-// return unmarshal((*plain)(c))
-//}
diff --git a/config/metric_config_test.go b/config/metric_config_test.go
deleted file mode 100644
index 2bcdd6d..0000000
--- a/config/metric_config_test.go
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * 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 config
-
-import (
- "testing"
-)
-
-func TestGetMetricConfig(t *testing.T) {
- //empty := GetMetricConfig()
- //assert.NotNil(t, empty)
-}
diff --git a/config_center/apollo/mockDubbogo.yaml.json b/config_center/apollo/mockDubbogo.yaml.json
deleted file mode 100644
index 4131bed..0000000
--- a/config_center/apollo/mockDubbogo.yaml.json
+++ /dev/null
@@ -1 +0,0 @@
-{"appId":"testApplication_yang","cluster":"default","namespaceName":"mockDubbogo.yaml","releaseKey":"20191104105242-0f13805d89f834a4","configurations":{"registries.hangzhouzk.username":"11111"}}
diff --git a/filter/metrics/filter.go b/filter/metrics/filter.go
index 8f31c2b..19a2ead 100644
--- a/filter/metrics/filter.go
+++ b/filter/metrics/filter.go
@@ -38,12 +38,6 @@ func init() {
}
// Filter will calculate the invocation's duration and the report to the reporters
-// If you want to use this filter to collect the metrics,
-// Adding this into your configuration file, like:
-// filter: "metrics"
-// metrics:
-// reporter:
-// - "your reporter" # here you should specify the reporter, for example 'prometheus'
// more info please take a look at dubbo-samples projects
type Filter struct {
reporters []metrics.Reporter
diff --git a/go.mod b/go.mod
index 1333f17..e1f2033 100644
--- a/go.mod
+++ b/go.mod
@@ -13,7 +13,7 @@ require (
github.com/creasty/defaults v1.5.2
github.com/dubbogo/go-zookeeper v1.0.3
github.com/dubbogo/gost v1.11.19
- github.com/dubbogo/triple v1.0.8
+ github.com/dubbogo/triple v1.0.9
github.com/emicklei/go-restful/v3 v3.7.1
github.com/fsnotify/fsnotify v1.5.1
github.com/ghodss/yaml v1.0.0
diff --git a/go.sum b/go.sum
index e995df9..a753f4c 100644
--- a/go.sum
+++ b/go.sum
@@ -195,8 +195,8 @@ github.com/dubbogo/gost v1.11.19/go.mod h1:vIcP9rqz2KsXHPjsAwIUtfJIJjppQLQDcYaZT
github.com/dubbogo/jsonparser v1.0.1/go.mod h1:tYAtpctvSP/tWw4MeelsowSPgXQRVHHWbqL6ynps8jU=
github.com/dubbogo/net v0.0.4 h1:Rn9aMPZwOiRE22YhtxmDEE3H0Q3cfVRNhuEjNMelJ/8=
github.com/dubbogo/net v0.0.4/go.mod h1:1CGOnM7X3he+qgGNqjeADuE5vKZQx/eMSeUkpU3ujIc=
-github.com/dubbogo/triple v1.0.8 h1:M3p2t+Bx6z1RbVMm4GjrZKFpe8Ar0g6J0m/6fYU46tQ=
-github.com/dubbogo/triple v1.0.8/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
+github.com/dubbogo/triple v1.0.9 h1:piScEoTxmowYYFtLqPuYa0SojdSqe/+WNeGbMNkIXn4=
+github.com/dubbogo/triple v1.0.9/go.mod h1:1t9me4j4CTvNDcsMZy6/OGarbRyAUSY0tFXGXHCp7Iw=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
diff --git a/metrics/prometheus/reporter.go b/metrics/prometheus/reporter.go
index 55d1bd6..110d759 100644
--- a/metrics/prometheus/reporter.go
+++ b/metrics/prometheus/reporter.go
@@ -55,9 +55,9 @@ const (
consumerPrefix = "consumer_"
// to identify the metric's type
- histogramSuffix = "_histogram"
+ rtSuffix = "_rt"
// to identify the metric's type
- summarySuffix = "_summary"
+ tpsSuffix = "_tps"
)
var (
@@ -77,14 +77,15 @@ func init() {
// if you want to use this feature, you need to initialize your prometheus.
// https://prometheus.io/docs/guides/go-application/
type PrometheusReporter struct {
- // report the consumer-side's summary data
- consumerSummaryVec *prometheus.SummaryVec
- // report the provider-side's summary data
- providerSummaryVec *prometheus.SummaryVec
- // report the provider-side's histogram data
- providerHistogramVec *prometheus.HistogramVec
- // report the consumer-side's histogram data
- consumerHistogramVec *prometheus.HistogramVec
+ // report the consumer-side's rt gauge data
+ consumerRTGaugeVec *prometheus.GaugeVec
+ // report the provider-side's rt gauge data
+ providerRTGaugeVec *prometheus.GaugeVec
+ // todo tps support
+ // report the consumer-side's tps gauge data
+ consumerTPSGaugeVec *prometheus.GaugeVec
+ // report the provider-side's tps gauge data
+ providerTPSGaugeVec *prometheus.GaugeVec
userGauge sync.Map
userSummary sync.Map
@@ -101,14 +102,11 @@ type PrometheusReporter struct {
// or it will be ignored
func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol.Invoker, invocation protocol.Invocation, cost time.Duration, res protocol.Result) {
url := invoker.GetURL()
- var sumVec *prometheus.SummaryVec
- var hisVec *prometheus.HistogramVec
+ var rtVec *prometheus.GaugeVec
if isProvider(url) {
- sumVec = reporter.providerSummaryVec
- hisVec = reporter.providerHistogramVec
+ rtVec = reporter.providerRTGaugeVec
} else if isConsumer(url) {
- sumVec = reporter.consumerSummaryVec
- hisVec = reporter.consumerHistogramVec
+ rtVec = reporter.consumerRTGaugeVec
} else {
logger.Warnf("The url belongs neither the consumer nor the provider, "+
"so the invocation will be ignored. url: %s", url.String())
@@ -118,13 +116,12 @@ func (reporter *PrometheusReporter) Report(ctx context.Context, invoker protocol
labels := prometheus.Labels{
serviceKey: url.Service(),
groupKey: url.GetParam(groupKey, ""),
- versionKey: url.GetParam(versionKey, ""),
+ versionKey: url.GetParam(constant.APP_VERSION_KEY, ""),
methodKey: invocation.MethodName(),
timeoutKey: url.GetParam(timeoutKey, ""),
}
- costMs := float64(cost.Nanoseconds() / constant.MsToNanoRate)
- sumVec.With(labels).Observe(costMs)
- hisVec.With(labels).Observe(costMs)
+ costMs := cost.Nanoseconds()
+ rtVec.With(labels).Set(float64(costMs))
}
func newHistogramVec(name, namespace string, labels []string) *prometheus.HistogramVec {
@@ -215,16 +212,12 @@ func newPrometheusReporter(reporterConfig *metrics.ReporterConfig) metrics.Repor
if reporterInstance == nil {
reporterInitOnce.Do(func() {
reporterInstance = &PrometheusReporter{
- consumerSummaryVec: newSummaryVec(consumerPrefix+serviceKey+summarySuffix, reporterConfig.Namespace, labelNames),
- providerSummaryVec: newSummaryVec(providerPrefix+serviceKey+summarySuffix, reporterConfig.Namespace, labelNames),
- namespace: reporterConfig.Namespace,
- consumerHistogramVec: newHistogramVec(consumerPrefix+serviceKey+histogramSuffix, reporterConfig.Namespace, labelNames),
- providerHistogramVec: newHistogramVec(providerPrefix+serviceKey+histogramSuffix, reporterConfig.Namespace, labelNames),
+ namespace: reporterConfig.Namespace,
+ consumerRTGaugeVec: newGaugeVec(consumerPrefix+serviceKey+rtSuffix, reporterConfig.Namespace, labelNames),
+ providerRTGaugeVec: newGaugeVec(providerPrefix+serviceKey+rtSuffix, reporterConfig.Namespace, labelNames),
}
- prom.DefaultRegisterer.MustRegister(reporterInstance.consumerSummaryVec, reporterInstance.providerSummaryVec,
- reporterInstance.consumerHistogramVec, reporterInstance.providerHistogramVec)
-
+ prom.DefaultRegisterer.MustRegister(reporterInstance.consumerRTGaugeVec, reporterInstance.providerRTGaugeVec)
metricsExporter, err := ocprom.NewExporter(ocprom.Options{
Registry: prom.DefaultRegisterer.(*prom.Registry),
})
@@ -232,13 +225,19 @@ func newPrometheusReporter(reporterConfig *metrics.ReporterConfig) metrics.Repor
logger.Errorf("new prometheus reporter with error = %s", err)
return
}
- go func() {
- mux := http.NewServeMux()
- mux.Handle(reporterConfig.Path, metricsExporter)
- if err := http.ListenAndServe(":"+reporterConfig.Port, mux); err != nil {
- logger.Errorf("new prometheus reporter with error = %s", err)
+
+ if reporterConfig.Enable {
+ if reporterConfig.Mode == metrics.ReportModePull {
+ go func() {
+ mux := http.NewServeMux()
+ mux.Handle(reporterConfig.Path, metricsExporter)
+ if err := http.ListenAndServe(":"+reporterConfig.Port, mux); err != nil {
+ logger.Warnf("new prometheus reporter with error = %s", err)
+ }
+ }()
}
- }()
+ // todo pushgateway support
+ }
})
}
return reporterInstance
diff --git a/protocol/dubbo3/common_test.go b/protocol/dubbo3/common_test.go
index f137e84..5daac36 100644
--- a/protocol/dubbo3/common_test.go
+++ b/protocol/dubbo3/common_test.go
@@ -28,7 +28,6 @@ import (
import (
"dubbo.apache.org/dubbo-go/v3/config"
- "dubbo.apache.org/dubbo-go/v3/protocol"
"dubbo.apache.org/dubbo-go/v3/protocol/dubbo3/internal"
"dubbo.apache.org/dubbo-go/v3/protocol/invocation"
)
@@ -39,13 +38,11 @@ func addService() {
}
type greeterProvider struct {
- *greeterProviderBase
+ internal.UnimplementedGreeterServer
}
func newGreeterProvider() *greeterProvider {
- return &greeterProvider{
- greeterProviderBase: &greeterProviderBase{},
- }
+ return &greeterProvider{}
}
func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloRequest) (reply *internal.HelloReply, err error) {
@@ -53,38 +50,6 @@ func (g *greeterProvider) SayHello(ctx context.Context, req *internal.HelloReque
return &internal.HelloReply{Message: "this is message from reply"}, nil
}
-func (g *greeterProvider) Reference() string {
- return "DubboGreeterImpl"
-}
-
-// code generated by greeter.go
-type greeterProviderBase struct {
- proxyImpl protocol.Invoker
-}
-
-func (g *greeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
- g.proxyImpl = impl
-}
-
-func (g *greeterProviderBase) GetProxyImpl() protocol.Invoker {
- return g.proxyImpl
-}
-
-func (g *greeterProviderBase) ServiceDesc() *native_grpc.ServiceDesc {
- return &native_grpc.ServiceDesc{
- ServiceName: "helloworld.Greeter",
- HandlerType: (*internal.GreeterServer)(nil),
- Methods: []native_grpc.MethodDesc{
- {
- MethodName: "SayHello",
- Handler: dubboGreeterSayHelloHandler,
- },
- },
- Streams: []native_grpc.StreamDesc{},
- Metadata: "helloworld.proto",
- }
-}
-
func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context,
dec func(interface{}) error, interceptor native_grpc.UnaryServerInterceptor) (interface{}, error) {
@@ -99,7 +64,7 @@ func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context,
invo := invocation.NewRPCInvocation("SayHello", args, nil)
if interceptor == nil {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
+ result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
info := &native_grpc.UnaryServerInfo{
@@ -107,7 +72,7 @@ func dubboGreeterSayHelloHandler(srv interface{}, ctx context.Context,
FullMethod: "/helloworld.Greeter/SayHello",
}
handler := func(context.Context, interface{}) (interface{}, error) {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
+ result := base.XXX_GetProxyImpl().Invoke(context.Background(), invo)
return result.Result(), result.Error()
}
return interceptor(ctx, in, info, handler)
diff --git a/protocol/dubbo3/dubbo3_protocol.go b/protocol/dubbo3/dubbo3_protocol.go
index e53b6a4..d0854df 100644
--- a/protocol/dubbo3/dubbo3_protocol.go
+++ b/protocol/dubbo3/dubbo3_protocol.go
@@ -87,9 +87,9 @@ func (dp *DubboProtocol) Export(invoker protocol.Invoker) protocol.Exporter {
var triSerializationType tripleConstant.CodecType
if serializationType == constant.PROTOBUF_SERIALIZATION {
- m, ok := reflect.TypeOf(service).MethodByName("SetProxyImpl")
+ m, ok := reflect.TypeOf(service).MethodByName("XXX_SetProxyImpl")
if !ok {
- panic("method SetProxyImpl is necessary for triple service")
+ panic("method XXX_SetProxyImpl is necessary for triple service")
}
if invoker == nil {
panic(fmt.Sprintf("no invoker found for servicekey: %v", url.ServiceKey()))
@@ -160,11 +160,11 @@ func (dp *DubboProtocol) Destroy() {
// Dubbo3GrpcService is gRPC service
type Dubbo3GrpcService interface {
// SetProxyImpl sets proxy.
- SetProxyImpl(impl protocol.Invoker)
+ XXX_SetProxyImpl(impl protocol.Invoker)
// GetProxyImpl gets proxy.
- GetProxyImpl() protocol.Invoker
+ XXX_GetProxyImpl() protocol.Invoker
// ServiceDesc gets an RPC service's specification.
- ServiceDesc() *grpc.ServiceDesc
+ XXX_ServiceDesc() *grpc.ServiceDesc
}
type UnaryService struct {
diff --git a/protocol/dubbo3/dubbo3_protocol_test.go b/protocol/dubbo3/dubbo3_protocol_test.go
index 95e485d..b0baa35 100644
--- a/protocol/dubbo3/dubbo3_protocol_test.go
+++ b/protocol/dubbo3/dubbo3_protocol_test.go
@@ -36,7 +36,7 @@ import (
)
const (
- mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterImpl" +
+ mockDubbo3CommonUrl = "tri://127.0.0.1:20002/DubboGreeterImpl?accesslog=&anyhost=true&app.version=0.0.1&application=BDTService&async=false&bean.name=greeterProvider" +
"&category=providers&cluster=failover&dubbo=dubbo-provider-golang-2.6.0&environment=dev&execute.limit=&execute.limit.rejected.handler=&generic=false&group=&interface=org.apache.dubbo.DubboGreeterImpl" +
"&ip=192.168.1.106&loadbalance=random&methods.SayHello.loadbalance=random&methods.SayHello.retries=1&methods.SayHello.tps.limit.interval=&methods.SayHello.tps.limit.rate=&methods.SayHello.tps.limit.strategy=" +
"&methods.SayHello.weight=0&module=dubbogo+say-hello+client&name=BDTService&organization=ikurento.com&owner=ZX&pid=49427&reference.filter=cshutdown®istry.role=3&remote.timestamp=1576923717&retries=" +
diff --git a/protocol/dubbo3/internal/helloworld.pb.go b/protocol/dubbo3/internal/helloworld.pb.go
index e265b30..f846788 100644
--- a/protocol/dubbo3/internal/helloworld.pb.go
+++ b/protocol/dubbo3/internal/helloworld.pb.go
@@ -16,257 +16,228 @@
*/
// Code generated by protoc-gen-go. DO NOT EDIT.
+// versions:
+// protoc-gen-go v1.25.0
+// protoc v3.14.0
// source: helloworld.proto
package internal
import (
- context "context"
- fmt "fmt"
- math "math"
+ reflect "reflect"
+ sync "sync"
)
import (
- "github.com/dubbogo/triple/pkg/common"
- tripleConstant "github.com/dubbogo/triple/pkg/common/constant"
- dubbo3 "github.com/dubbogo/triple/pkg/triple"
-
proto "github.com/golang/protobuf/proto"
- grpc "google.golang.org/grpc"
-)
+ protoreflect "google.golang.org/protobuf/reflect/protoreflect"
-import (
- "dubbo.apache.org/dubbo-go/v3/protocol"
- dgrpc "dubbo.apache.org/dubbo-go/v3/protocol/grpc"
- "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+ protoimpl "google.golang.org/protobuf/runtime/protoimpl"
)
-// Reference imports to suppress errors if they are not otherwise used.
-var _ = proto.Marshal
-var _ = fmt.Errorf
-var _ = math.Inf
+const (
+ // Verify that this generated code is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
+ // Verify that runtime/protoimpl is sufficiently up-to-date.
+ _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
+)
-// This is a compile-time assertion to ensure that this generated file
-// is compatible with the proto package it is being compiled against.
-// A compilation error at this line likely means your copy of the
-// proto package needs to be updated.
-const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+// This is a compile-time assertion that a sufficiently up-to-date version
+// of the legacy proto package is being used.
+const _ = proto.ProtoPackageIsVersion4
// The request message containing the user's name.
type HelloRequest struct {
- Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
-}
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
-func (m *HelloRequest) Reset() { *m = HelloRequest{} }
-func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
-func (*HelloRequest) ProtoMessage() {}
-func (*HelloRequest) Descriptor() ([]byte, []int) {
- return fileDescriptor_17b8c58d586b62f2, []int{0}
+ Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
-func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_HelloRequest.Unmarshal(m, b)
-}
-func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic)
-}
-func (m *HelloRequest) XXX_Merge(src proto.Message) {
- xxx_messageInfo_HelloRequest.Merge(m, src)
-}
-func (m *HelloRequest) XXX_Size() int {
- return xxx_messageInfo_HelloRequest.Size(m)
-}
-func (m *HelloRequest) XXX_DiscardUnknown() {
- xxx_messageInfo_HelloRequest.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
-
-func (m *HelloRequest) GetName() string {
- if m != nil {
- return m.Name
+func (x *HelloRequest) Reset() {
+ *x = HelloRequest{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[0]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
}
- return ""
}
-// The response message containing the greetings
-type HelloReply struct {
- Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
- XXX_NoUnkeyedLiteral struct{} `json:"-"`
- XXX_unrecognized []byte `json:"-"`
- XXX_sizecache int32 `json:"-"`
+func (x *HelloRequest) String() string {
+ return protoimpl.X.MessageStringOf(x)
}
-func (m *HelloReply) Reset() { *m = HelloReply{} }
-func (m *HelloReply) String() string { return proto.CompactTextString(m) }
-func (*HelloReply) ProtoMessage() {}
-func (*HelloReply) Descriptor() ([]byte, []int) {
- return fileDescriptor_17b8c58d586b62f2, []int{1}
-}
+func (*HelloRequest) ProtoMessage() {}
-func (m *HelloReply) XXX_Unmarshal(b []byte) error {
- return xxx_messageInfo_HelloReply.Unmarshal(m, b)
-}
-func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
- return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic)
-}
-func (m *HelloReply) XXX_Merge(src proto.Message) {
- xxx_messageInfo_HelloReply.Merge(m, src)
-}
-func (m *HelloReply) XXX_Size() int {
- return xxx_messageInfo_HelloReply.Size(m)
-}
-func (m *HelloReply) XXX_DiscardUnknown() {
- xxx_messageInfo_HelloReply.DiscardUnknown(m)
-}
-
-var xxx_messageInfo_HelloReply proto.InternalMessageInfo
-
-func (m *HelloReply) GetMessage() string {
- if m != nil {
- return m.Message
+func (x *HelloRequest) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[0]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
}
- return ""
+ return mi.MessageOf(x)
}
-func init() {
- proto.RegisterType((*HelloRequest)(nil), "internal.HelloRequest")
- proto.RegisterType((*HelloReply)(nil), "internal.HelloReply")
-}
-
-func init() { proto.RegisterFile("helloworld.proto", fileDescriptor_17b8c58d586b62f2) }
-
-var fileDescriptor_17b8c58d586b62f2 = []byte{
- // 189 bytes of a gzipped FileDescriptorProto
- 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x48, 0xcd, 0xc9,
- 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0xc8, 0xcc,
- 0x2b, 0x49, 0x2d, 0xca, 0x4b, 0xcc, 0x51, 0x52, 0xe2, 0xe2, 0xf1, 0x00, 0xc9, 0x06, 0xa5, 0x16,
- 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30, 0x2a, 0x30,
- 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95, 0x42, 0x12,
- 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x91, 0x2b, 0x17, 0xbb,
- 0x7b, 0x51, 0x6a, 0x6a, 0x49, 0x6a, 0x91, 0x90, 0x15, 0x17, 0x47, 0x70, 0x62, 0x25, 0x58, 0x97,
- 0x90, 0x98, 0x1e, 0xcc, 0x36, 0x3d, 0x64, 0xab, 0xa4, 0x44, 0x30, 0xc4, 0x0b, 0x72, 0x2a, 0x95,
- 0x18, 0x9c, 0xcc, 0xb8, 0xa4, 0x33, 0xf3, 0xf5, 0xd2, 0x8b, 0x0a, 0x92, 0xf5, 0x52, 0x2b, 0x12,
- 0x73, 0x0b, 0x72, 0x52, 0x8b, 0xf5, 0x10, 0x3e, 0x70, 0xe2, 0x07, 0x2b, 0x0e, 0x07, 0xb1, 0x03,
- 0x40, 0x9e, 0x09, 0x60, 0x5c, 0xc4, 0xc4, 0xec, 0xe1, 0x13, 0x9e, 0xc4, 0x06, 0xf6, 0x9b, 0x31,
- 0x20, 0x00, 0x00, 0xff, 0xff, 0xc4, 0x20, 0xe8, 0xd3, 0xef, 0x00, 0x00, 0x00,
+// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead.
+func (*HelloRequest) Descriptor() ([]byte, []int) {
+ return file_helloworld_proto_rawDescGZIP(), []int{0}
}
-type greeterDubbo3Client struct {
- cc *dubbo3.TripleConn
+func (x *HelloRequest) GetName() string {
+ if x != nil {
+ return x.Name
+ }
+ return ""
}
-func NewGreeterDubbo3Client(cc *dubbo3.TripleConn) GreeterClient {
- return &greeterDubbo3Client{cc}
-}
-func (c *greeterDubbo3Client) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) {
- out := new(HelloReply)
- interfaceKey := ctx.Value(tripleConstant.InterfaceKey).(string)
- return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
-}
+// The response message containing the greetings
+type HelloReply struct {
+ state protoimpl.MessageState
+ sizeCache protoimpl.SizeCache
+ unknownFields protoimpl.UnknownFields
-// GreeterClientImpl is the client API for Greeter service.
-//
-// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
-type GreeterClient interface {
- // Sends a greeting
- SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment)
+ Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
}
-type GreeterClientImpl struct {
- // Sends a greeting
- SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error)
+func (x *HelloReply) Reset() {
+ *x = HelloReply{}
+ if protoimpl.UnsafeEnabled {
+ mi := &file_helloworld_proto_msgTypes[1]
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ ms.StoreMessageInfo(mi)
+ }
}
-type Greeter_SayHelloClient interface {
- CloseAndRecv() (*HelloReply, error)
- grpc.ClientStream
+func (x *HelloReply) String() string {
+ return protoimpl.X.MessageStringOf(x)
}
-type greeterSayHelloClient struct {
- grpc.ClientStream
-}
+func (*HelloReply) ProtoMessage() {}
-func (x *greeterSayHelloClient) CloseAndRecv() (*HelloReply, error) {
- if err := x.ClientStream.CloseSend(); err != nil {
- return nil, err
- }
- m := new(HelloReply)
- if err := x.ClientStream.RecvMsg(m); err != nil {
- return nil, err
+func (x *HelloReply) ProtoReflect() protoreflect.Message {
+ mi := &file_helloworld_proto_msgTypes[1]
+ if protoimpl.UnsafeEnabled && x != nil {
+ ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+ if ms.LoadMessageInfo() == nil {
+ ms.StoreMessageInfo(mi)
+ }
+ return ms
}
- return m, nil
+ return mi.MessageOf(x)
}
-func (c *GreeterClientImpl) Reference() string {
- return "greeterImpl"
+// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead.
+func (*HelloReply) Descriptor() ([]byte, []int) {
+ return file_helloworld_proto_rawDescGZIP(), []int{1}
}
-func (c *GreeterClientImpl) GetDubboStub(cc *dubbo3.TripleConn) GreeterClient {
- return NewGreeterDubbo3Client(cc)
+func (x *HelloReply) GetMessage() string {
+ if x != nil {
+ return x.Message
+ }
+ return ""
}
-// GreeterServer is the server API for Greeter service.
-type GreeterServer interface {
- // Sends a greeting
- SayHello(context.Context, *HelloRequest) (*HelloReply, error)
-}
+var File_helloworld_proto protoreflect.FileDescriptor
+
+var file_helloworld_proto_rawDesc = []byte{
+ 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f,
+ 0x74, 0x6f, 0x12, 0x08, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x22, 0x22, 0x0a, 0x0c,
+ 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04,
+ 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65,
+ 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18,
+ 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
+ 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65,
+ 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12,
+ 0x16, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f,
+ 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e,
+ 0x61, 0x6c, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42,
+ 0x43, 0x0a, 0x1b, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70,
+ 0x6c, 0x65, 0x73, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x42, 0x0f,
+ 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50,
+ 0x01, 0x5a, 0x0b, 0x2e, 0x2f, 0x3b, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0xa2, 0x02,
+ 0x03, 0x48, 0x4c, 0x57, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+}
+
+var (
+ file_helloworld_proto_rawDescOnce sync.Once
+ file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc
+)
-type GreeterProviderBase struct {
- proxyImpl protocol.Invoker
+func file_helloworld_proto_rawDescGZIP() []byte {
+ file_helloworld_proto_rawDescOnce.Do(func() {
+ file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData)
+ })
+ return file_helloworld_proto_rawDescData
}
-func (s *GreeterProviderBase) SetProxyImpl(impl protocol.Invoker) {
- s.proxyImpl = impl
+var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2)
+var file_helloworld_proto_goTypes = []interface{}{
+ (*HelloRequest)(nil), // 0: internal.HelloRequest
+ (*HelloReply)(nil), // 1: internal.HelloReply
}
-
-func (s *GreeterProviderBase) GetProxyImpl() protocol.Invoker {
- return s.proxyImpl
+var file_helloworld_proto_depIdxs = []int32{
+ 0, // 0: internal.Greeter.SayHello:input_type -> internal.HelloRequest
+ 1, // 1: internal.Greeter.SayHello:output_type -> internal.HelloReply
+ 1, // [1:2] is the sub-list for method output_type
+ 0, // [0:1] is the sub-list for method input_type
+ 0, // [0:0] is the sub-list for extension type_name
+ 0, // [0:0] is the sub-list for extension extendee
+ 0, // [0:0] is the sub-list for field type_name
}
-func (c *GreeterProviderBase) Reference() string {
- return "greeterImpl"
-}
-
-func _Triple_Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
- in := new(HelloRequest)
- if err := dec(in); err != nil {
- return nil, err
- }
- base := srv.(dgrpc.DubboGrpcService)
- args := []interface{}{}
- args = append(args, in)
- invo := invocation.NewRPCInvocation("SayHello", args, nil)
- if interceptor == nil {
- result := base.GetProxyImpl().Invoke(ctx, invo)
- return result, result.Error()
- }
- info := &grpc.UnaryServerInfo{
- Server: srv,
- FullMethod: "/internal.Greeter/SayHello",
+func init() { file_helloworld_proto_init() }
+func file_helloworld_proto_init() {
+ if File_helloworld_proto != nil {
+ return
}
- handler := func(ctx context.Context, req interface{}) (interface{}, error) {
- result := base.GetProxyImpl().Invoke(context.Background(), invo)
- return result.Result(), result.Error()
+ if !protoimpl.UnsafeEnabled {
+ file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*HelloRequest); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
+ file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
+ switch v := v.(*HelloReply); i {
+ case 0:
+ return &v.state
+ case 1:
+ return &v.sizeCache
+ case 2:
+ return &v.unknownFields
+ default:
+ return nil
+ }
+ }
}
- return interceptor(ctx, in, info, handler)
-}
-
-func (s *GreeterProviderBase) ServiceDesc() *grpc.ServiceDesc {
- return &grpc.ServiceDesc{
- ServiceName: "internal.Greeter",
- HandlerType: (*GreeterServer)(nil),
- Methods: []grpc.MethodDesc{
- {
- MethodName: "SayHello",
- Handler: _Triple_Greeter_SayHello_Handler,
- },
+ type x struct{}
+ out := protoimpl.TypeBuilder{
+ File: protoimpl.DescBuilder{
+ GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
+ RawDescriptor: file_helloworld_proto_rawDesc,
+ NumEnums: 0,
+ NumMessages: 2,
+ NumExtensions: 0,
+ NumServices: 1,
},
- Streams: []grpc.StreamDesc{},
- Metadata: "helloworld.proto",
- }
+ GoTypes: file_helloworld_proto_goTypes,
+ DependencyIndexes: file_helloworld_proto_depIdxs,
+ MessageInfos: file_helloworld_proto_msgTypes,
+ }.Build()
+ File_helloworld_proto = out.File
+ file_helloworld_proto_rawDesc = nil
+ file_helloworld_proto_goTypes = nil
+ file_helloworld_proto_depIdxs = nil
}
diff --git a/protocol/dubbo3/internal/helloworld.proto b/protocol/dubbo3/internal/helloworld.proto
index 7b62e20..ceb877a 100644
--- a/protocol/dubbo3/internal/helloworld.proto
+++ b/protocol/dubbo3/internal/helloworld.proto
@@ -21,6 +21,7 @@ option java_multiple_files = true;
option java_package = "io.grpc.examples.helloworld";
option java_outer_classname = "HelloWorldProto";
option objc_class_prefix = "HLW";
+option go_package = "./;internal";
package internal;
diff --git a/protocol/dubbo3/internal/helloworld_triple.pb.go b/protocol/dubbo3/internal/helloworld_triple.pb.go
new file mode 100644
index 0000000..b9c2f7f
--- /dev/null
+++ b/protocol/dubbo3/internal/helloworld_triple.pb.go
@@ -0,0 +1,168 @@
+/*
+ * 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.
+ */
+
+// Code generated by protoc-gen-go-triple. DO NOT EDIT.
+// versions:
+// - protoc-gen-go-triple v1.0.0
+// - protoc v3.14.0
+// source: helloworld.proto
+
+package internal
+
+import (
+ context "context"
+)
+
+import (
+ common "github.com/dubbogo/triple/pkg/common"
+ constant "github.com/dubbogo/triple/pkg/common/constant"
+ triple "github.com/dubbogo/triple/pkg/triple"
+
+ grpc "google.golang.org/grpc"
+ codes "google.golang.org/grpc/codes"
+ status "google.golang.org/grpc/status"
+)
+
+import (
+ protocol "dubbo.apache.org/dubbo-go/v3/protocol"
+ invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
+)
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the grpc package it is being compiled against.
+const _ = grpc.SupportPackageIsVersion7
+
+// GreeterClient is the client API for Greeter service.
+//
+// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
+type GreeterClient interface {
+ // Sends a greeting
+ SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment)
+}
+
+type greeterClient struct {
+ cc *triple.TripleConn
+}
+
+type GreeterClientImpl struct {
+ SayHello func(ctx context.Context, in *HelloRequest) (*HelloReply, error)
+}
+
+func (c *GreeterClientImpl) GetDubboStub(cc *triple.TripleConn) GreeterClient {
+ return NewGreeterClient(cc)
+}
+
+func NewGreeterClient(cc *triple.TripleConn) GreeterClient {
+ return &greeterClient{cc}
+}
+
+func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, common.ErrorWithAttachment) {
+ out := new(HelloReply)
+ interfaceKey := ctx.Value(constant.InterfaceKey).(string)
+ return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/SayHello", in, out)
+}
+
+// GreeterServer is the server API for Greeter service.
+// All implementations must embed UnimplementedGreeterServer
+// for forward compatibility
+type GreeterServer interface {
+ // Sends a greeting
+ SayHello(context.Context, *HelloRequest) (*HelloReply, error)
+ mustEmbedUnimplementedGreeterServer()
+}
+
+// UnimplementedGreeterServer must be embedded to have forward compatible implementations.
+type UnimplementedGreeterServer struct {
+ proxyImpl protocol.Invoker
+}
+
+func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) {
+ return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented")
+}
+func (s *UnimplementedGreeterServer) XXX_SetProxyImpl(impl protocol.Invoker) {
+ s.proxyImpl = impl
+}
+
+func (s *UnimplementedGreeterServer) XXX_GetProxyImpl() protocol.Invoker {
+ return s.proxyImpl
+}
+
+func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {}
+
+// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service.
+// Use of this interface is not recommended, as added methods to GreeterServer will
+// result in compilation errors.
+type UnsafeGreeterServer interface {
+ mustEmbedUnimplementedGreeterServer()
+}
+
+func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) {
+ s.RegisterService(&Greeter_ServiceDesc, srv)
+}
+
+// Dubbo3GrpcService is gRPC service
+type Dubbo3GrpcService interface {
+ // SetProxyImpl sets proxy.
+ XXX_SetProxyImpl(impl protocol.Invoker)
+ // GetProxyImpl gets proxy.
+ XXX_GetProxyImpl() protocol.Invoker
+ // ServiceDesc gets an RPC service's specification.
+ XXX_ServiceDesc() *grpc.ServiceDesc
+}
+
+func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+ in := new(HelloRequest)
+ if err := dec(in); err != nil {
+ return nil, err
+ }
+ base := srv.(Dubbo3GrpcService)
+ args := []interface{}{}
+ args = append(args, in)
+ invo := invocation.NewRPCInvocation("SayHello", args, nil)
+ if interceptor == nil {
+ result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
+ return result, result.Error()
+ }
+ info := &grpc.UnaryServerInfo{
+ Server: srv,
+ FullMethod: "/internal.Greeter/SayHello",
+ }
+ handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+ return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest))
+ }
+ return interceptor(ctx, in, info, handler)
+}
+
+// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service.
+// It's only intended for direct use with grpc.RegisterService,
+// and not to be introspected or modified (even as a copy)
+var Greeter_ServiceDesc = grpc.ServiceDesc{
+ ServiceName: "internal.Greeter",
+ HandlerType: (*GreeterServer)(nil),
+ Methods: []grpc.MethodDesc{
+ {
+ MethodName: "SayHello",
+ Handler: _Greeter_SayHello_Handler,
+ },
+ },
+ Streams: []grpc.StreamDesc{},
+ Metadata: "helloworld.proto",
+}
+
+func (s *UnimplementedGreeterServer) XXX_ServiceDesc() *grpc.ServiceDesc {
+ return &Greeter_ServiceDesc
+}
diff --git a/protocol/dubbo3/internal/server.go b/protocol/dubbo3/internal/server.go
index 97245df..51021c8 100644
--- a/protocol/dubbo3/internal/server.go
+++ b/protocol/dubbo3/internal/server.go
@@ -32,7 +32,7 @@ import (
// server is used to implement helloworld.GreeterServer.
type Server struct {
- GreeterProviderBase
+ UnimplementedGreeterServer
}
// SayHello implements helloworld.GreeterServer