Skip to content

Commit

Permalink
migrate to 'google.golang.org/protobuf'
Browse files Browse the repository at this point in the history
  • Loading branch information
xiemalin committed Aug 26, 2021
1 parent ba9ae3e commit 7010925
Show file tree
Hide file tree
Showing 28 changed files with 1,320 additions and 518 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ baidurpc是一种基于TCP协议的二进制高性能RPC通信协议实现。它
</p>

[![Go Report Card](https://goreportcard.com/badge/github.com/baidu-golang/pbrpc?style=flat-square)](https://goreportcard.com/report/github.com/baidu-golang/pbrpc)
[![Go](https://github.com/baidu-golang/pbrpc/actions/workflows/main.yml/badge.svg?branch=v1.3.x)](https://github.com/baidu-golang/pbrpc/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/baidu-golang/pbrpc/branch/v1.3.x/graph/badge.svg?token=EY9Z88E82P)](https://codecov.io/gh/baidu-golang/pbrpc)
[![Go](https://github.com/baidu-golang/pbrpc/actions/workflows/main.yml/badge.svg)](https://github.com/baidu-golang/pbrpc/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/baidu-golang/pbrpc/branch/master/graph/badge.svg?token=EY9Z88E82P)](https://codecov.io/gh/baidu-golang/pbrpc)
[![Releases](https://img.shields.io/github/release/baidu-golang/pbrpc/all.svg?style=flat-square)](https://github.com/baidu-golang/pbrpc/releases)
[![Go Reference](https://golang.com.cn/badge/github.com/baidu-golang/pbrpc.svg)](https://golang.com.cn/github.com/baidu-golang/pbrpc)
[![LICENSE](https://img.shields.io/github/license/baidu-golang/pbrpc.svg?style=flat-square)](https://github.com/baidu-golang/pbrpc/blob/master/LICENSE)
Expand Down
6 changes: 3 additions & 3 deletions benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"time"

baidurpc "github.com/baidu-golang/pbrpc"
"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
)

// BenchmarkTestLocalConnectionPerformance bench mark test
Expand Down Expand Up @@ -60,12 +60,12 @@ func doSimpleRPCInvokeWithSignature(rpcClient *baidurpc.RpcClient, serviceName,
rpcInvocation := baidurpc.NewRpcInvocation(&serviceName, &methodName)

name := "马林"
dm := EchoMessage{name}
dm := DataMessage{Name: name}

rpcInvocation.SetParameterIn(&dm)
rpcInvocation.LogId = proto.Int64(1)

parameterOut := EchoMessage{}
parameterOut := DataMessage{}

rpcClient.SendRpcRequest(rpcInvocation, &parameterOut)
}
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
"sync/atomic"
"time"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"
"github.com/jhunters/timewheel"
)

Expand Down
22 changes: 11 additions & 11 deletions client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"time"

baidurpc "github.com/baidu-golang/pbrpc"
"github.com/golang/protobuf/proto"
. "github.com/smartystreets/goconvey/convey"
"google.golang.org/protobuf/proto"
)

const (
Expand All @@ -45,9 +45,9 @@ type AddOneTraceService struct {

// Trace
func (as *AddOneTraceService) Trace(service, name string, traceInfo *baidurpc.TraceInfo) *baidurpc.TraceInfo {
*traceInfo.SpanId++
*traceInfo.TraceId++
*traceInfo.ParentSpanId++
traceInfo.SpanId++
traceInfo.TraceId++
traceInfo.ParentSpanId++
return traceInfo
}

Expand Down Expand Up @@ -144,15 +144,15 @@ func TestSingleTcpConnectionClientWithBadChunkCase(t *testing.T) {
rpcInvocation := baidurpc.NewRpcInvocation(&serviceName, &methodName)

name := "(马林)(matthew)(XML)(jhunters)"
dm := EchoMessage{name}
dm := DataMessage{Name: name}

rpcInvocation.SetParameterIn(&dm)
rpcInvocation.LogId = proto.Int64(1)

dataPackage, err := rpcInvocation.GetRequestRpcDataPackage()
So(err, ShouldBeNil)

dataPackage.ChunkInfo(10, 1) // bad chunk data package
dataPackage.ChuckInfo(10, 1) // bad chunk data package
go func() {
client.Session.SendReceive(dataPackage) // send bad chunk data package server will block unitl timeout
}()
Expand Down Expand Up @@ -305,7 +305,7 @@ func doSimpleRPCInvokeWithSignatureWithConvey(rpcClient *baidurpc.RpcClient, ser
rpcInvocation := baidurpc.NewRpcInvocation(&serviceName, &methodName)

name := "(马林)(matthew)(XML)(jhunters)"
dm := EchoMessage{name}
dm := DataMessage{Name: name}

rpcInvocation.SetParameterIn(&dm)
rpcInvocation.LogId = proto.Int64(1)
Expand All @@ -323,7 +323,7 @@ func doSimpleRPCInvokeWithSignatureWithConvey(rpcClient *baidurpc.RpcClient, ser
rpcInvocation.AuthenticateData = []byte(AUTH_TOKEN)
}

parameterOut := EchoMessage{}
parameterOut := DataMessage{}
var response *baidurpc.RpcDataPackage
var err error
if timeout {
Expand Down Expand Up @@ -356,9 +356,9 @@ func doSimpleRPCInvokeWithSignatureWithConvey(rpcClient *baidurpc.RpcClient, ser
So(string(response.Attachment), ShouldEqual, "I am a attachementThis is attachment data")
}

So(*response.GetTraceId(), ShouldEqual, rpcInvocation.TraceId+1)
So(*response.GetParentSpanId(), ShouldEqual, rpcInvocation.ParentSpanId+1)
So(*response.GetParentSpanId(), ShouldEqual, rpcInvocation.ParentSpanId+1)
So(response.GetTraceId(), ShouldEqual, rpcInvocation.TraceId+1)
So(response.GetParentSpanId(), ShouldEqual, rpcInvocation.ParentSpanId+1)
So(response.GetParentSpanId(), ShouldEqual, rpcInvocation.ParentSpanId+1)
So(response.GetRpcRequestMetaExt()["key1"], ShouldEqual, "value1")
})

Expand Down
261 changes: 0 additions & 261 deletions data.pb.go

This file was deleted.

Loading

0 comments on commit 7010925

Please sign in to comment.