dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [dubbo-go] cvictory commented on a change in pull request #495: Imp: refactor the network transport layer
Date Mon, 01 Jun 2020 08:29:49 GMT

cvictory commented on a change in pull request #495:
URL: https://github.com/apache/dubbo-go/pull/495#discussion_r433106815



##########
File path: remoting/exchange.go
##########
@@ -0,0 +1,142 @@
+/*
+ * 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 remoting
+
+import (
+	"time"
+)
+
+import (
+	"go.uber.org/atomic"
+)
+
+import (
+	"github.com/apache/dubbo-go/common"
+)
+
+var (
+	// generate request ID for global use
+	sequence atomic.Uint64
+)
+
+func init() {
+	// init request ID
+	sequence.Store(0)
+}
+
+func SequenceId() uint64 {
+	// increse 2 for every request.
+	return sequence.Add(2)
+}
+
+// Request ...
+type Request struct {
+	ID int64
+	// protocol version
+	Version string
+	// serial ID (ignore)
+	SerialID byte
+	// Data
+	Data   interface{}
+	TwoWay bool
+	Event  bool
+	// it is used to judge the request is unbroken
+	// broken bool
+}
+
+// NewRequest
+func NewRequest(version string) *Request {
+	return &Request{
+		ID:      int64(SequenceId()),

Review comment:
       之前想用uint表示,后面想了下,还是用int64吧。 和java之类的通信,会溢出。




----------------------------------------------------------------
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


Mime
View raw message