Skip to content
This repository was archived by the owner on May 11, 2019. It is now read-only.

Commit 47bc036

Browse files
committedApr 7, 2019
rebuild .proto and pass test
1 parent 9a7175c commit 47bc036

17 files changed

+5778
-385
lines changed
 

‎README.md

+15
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,21 @@ goim 是 非常成功的 IM 原型( 即时消息平台), 依赖项为 kafka (
9393

9494

9595

96+
**proto 生成go**
97+
```
98+
cd ./api/comet/grpc
99+
100+
protoc -I=/Users/qinshen/go/src -I=/usr/local/include -I=./ --gofast_out=plugins=grpc:. ./*.proto
101+
102+
cd ./api/logic/grpc
103+
104+
protoc -I=/Users/qinshen/go/src -I=/usr/local/include -I=./ --gofast_out=plugins=grpc:. ./*.proto
105+
106+
107+
```
108+
109+
110+
96111
请查看 [/Makefile](/Makefile) , 运行 make
97112

98113
**编译**

‎api/comet/grpc/api.pb.go

+206-116
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/comet/grpc/api.proto

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ syntax = "proto3";
22

33
package goim.comet;
44
option go_package = "grpc";
5+
option (gogoproto.testgen_all) = true;
6+
option (gogoproto.benchgen_all) = true;
57

68
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
79

‎api/comet/grpc/apipb_test.go

+1,803
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/comet/grpc/build.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
protoc -I=/Users/qinshen/go/src -I=/usr/local/include -I=./ --gofast_out=plugins=grpc:. ./*.proto
3+

‎api/logic/grpc/api.pb.go

+468-266
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎api/logic/grpc/api.proto

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ syntax = "proto3";
33
package goim.logic;
44

55
option go_package = "grpc";
6+
option (gogoproto.testgen_all) = true;
7+
option (gogoproto.benchgen_all) = true;
68

79
import "github.com/tsingson/ex-goim/api/comet/grpc/api.proto";
810
import "github.com/gogo/protobuf/gogoproto/gogo.proto";

‎api/logic/grpc/apipb_test.go

+3,228
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dump.rdb

-108 Bytes
Binary file not shown.

‎go.mod

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ require (
3030
github.com/nsip/gommap v0.0.0-20181229045655-f7881c3a959f // indirect
3131
github.com/pascaldekloe/goe v0.1.0 // indirect
3232
github.com/pkg/errors v0.8.1
33-
github.com/sanity-io/litter v1.1.0
3433
github.com/sirupsen/logrus v1.4.1 // indirect
3534
github.com/spf13/afero v1.2.2
3635
github.com/stretchr/testify v1.3.0

‎goim-nats/comet/client.go

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package comet
2+
3+
import (
4+
"context"
5+
"time"
6+
7+
"google.golang.org/grpc"
8+
"google.golang.org/grpc/balancer/roundrobin"
9+
"google.golang.org/grpc/keepalive"
10+
11+
logic "github.com/tsingson/ex-goim/api/logic/grpc"
12+
"github.com/tsingson/ex-goim/goim-nats/comet/conf"
13+
)
14+
15+
const (
16+
// grpc options
17+
grpcInitialWindowSize = 1 << 24
18+
grpcInitialConnWindowSize = 1 << 24
19+
grpcMaxSendMsgSize = 1 << 24
20+
grpcMaxCallMsgSize = 1 << 24
21+
grpcKeepAliveTime = time.Second * 10
22+
grpcKeepAliveTimeout = time.Second * 3
23+
grpcBackoffMaxDelay = time.Second * 3
24+
)
25+
26+
// NewLogicClient grpc client for logic
27+
func NewLogicClient(c *conf.RPCClient) logic.LogicClient {
28+
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(c.Dial))
29+
defer cancel()
30+
conn, err := grpc.DialContext(ctx, "discovery://default/goim.logic",
31+
[]grpc.DialOption{
32+
grpc.WithInsecure(),
33+
grpc.WithInitialWindowSize(grpcInitialWindowSize),
34+
grpc.WithInitialConnWindowSize(grpcInitialConnWindowSize),
35+
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(grpcMaxCallMsgSize)),
36+
grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(grpcMaxSendMsgSize)),
37+
grpc.WithBackoffMaxDelay(grpcBackoffMaxDelay),
38+
grpc.WithKeepaliveParams(keepalive.ClientParameters{
39+
Time: grpcKeepAliveTime,
40+
Timeout: grpcKeepAliveTimeout,
41+
PermitWithoutStream: true,
42+
}),
43+
grpc.WithBalancerName(roundrobin.Name),
44+
}...)
45+
if err != nil {
46+
panic(err)
47+
}
48+
return logic.NewLogicClient(conn)
49+
}

‎goim-nats/comet/server.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"github.com/zhenjl/cityhash"
1010

1111
logic "github.com/tsingson/ex-goim/api/logic/grpc"
12-
"github.com/tsingson/ex-goim/goim-nats/comet/client"
12+
1313
"github.com/tsingson/ex-goim/goim-nats/comet/conf"
1414
)
1515

@@ -34,7 +34,7 @@ func NewServer(cfg *conf.CometConfig) *Server {
3434
s := &Server{
3535
c: cfg,
3636
round: NewRound(cfg),
37-
rpcClient: client.NewLogicClient(cfg.RPCClient),
37+
rpcClient: NewLogicClient(cfg.RPCClient),
3838
}
3939
// init bucket
4040
s.buckets = make([]*Bucket, cfg.Bucket.Size)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)
This repository has been archived.