You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2020/05/17 14:40:18 UTC

[GitHub] [dubbo-go] micln commented on a change in pull request #505: Add: DelegateMetadataReport & RemoteMetadataService

micln commented on a change in pull request #505:
URL: https://github.com/apache/dubbo-go/pull/505#discussion_r426267401



##########
File path: metadata/definition/definition.go
##########
@@ -19,13 +19,21 @@ package definition
 
 import (
 	"bytes"
+	"encoding/json"
+	"fmt"
+	"strings"
 )
 
 import (
 	"github.com/apache/dubbo-go/common"
 	"github.com/apache/dubbo-go/common/constant"
 )
 
+// ServiceDefinition is a interface of service's definition

Review comment:
       ServiceDefiner ?

##########
File path: metadata/definition/definition.go
##########
@@ -34,6 +42,36 @@ type ServiceDefinition struct {
 	Types         []TypeDefinition
 }
 
+func (def ServiceDefinition) ToBytes() ([]byte, error) {

Review comment:
       Does (def *ServiceDefinition) better?

##########
File path: metadata/definition/definition.go
##########
@@ -34,6 +42,36 @@ type ServiceDefinition struct {
 	Types         []TypeDefinition
 }
 
+func (def ServiceDefinition) ToBytes() ([]byte, error) {
+	return json.Marshal(def)
+}
+
+func (def ServiceDefinition) String() string {
+	var methodStr strings.Builder
+	for _, m := range def.Methods {
+		var paramType strings.Builder
+		for _, p := range m.ParameterTypes {
+			paramType.WriteString(fmt.Sprintf("{type:%v}", p))

Review comment:
       fmt.Fprintf(paramType, "{type:%v}", p) ?

##########
File path: metadata/report/delegate/delegate_report.go
##########
@@ -0,0 +1,275 @@
+/*
+ * 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 delegate
+
+import (
+	"encoding/json"
+	"sync"
+	"time"
+)
+
+import (
+	"github.com/go-co-op/gocron"
+	"go.uber.org/atomic"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+	"github.com/apache/dubbo-go/common/constant"
+	"github.com/apache/dubbo-go/common/logger"
+	"github.com/apache/dubbo-go/config/instance"
+	"github.com/apache/dubbo-go/metadata/definition"
+	"github.com/apache/dubbo-go/metadata/identifier"
+)
+
+const (
+	// defaultMetadataReportRetryTimes is defined for max  times to retry
+	defaultMetadataReportRetryTimes int64 = 100
+	// defaultMetadataReportRetryPeriod is defined for cycle interval to retry, the unit is second
+	defaultMetadataReportRetryPeriod int64 = 3
+	// defaultMetadataReportRetryPeriod is defined for cycle report or not
+	defaultMetadataReportCycleReport bool = true
+)
+
+// metadataReportRetry is a scheduler for retrying task
+type metadataReportRetry struct {
+	retryPeriod  int64
+	retryLimit   int64
+	scheduler    *gocron.Scheduler
+	job          *gocron.Job
+	retryCounter *atomic.Int64
+	// if no failed report, wait how many times to run retry task.
+	retryTimesIfNonFail int64
+}
+
+// newMetadataReportRetry will create a scheduler for retry task
+func newMetadataReportRetry(retryPeriod int64, retryLimit int64, retryFunc func() bool) (*metadataReportRetry, error) {
+	s1 := gocron.NewScheduler(time.UTC)

Review comment:
       dost `UTC` need be set by users




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org