-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
63 lines (49 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
ser "./grpc/mrpc"
protos "./grpc/protos"
"fmt"
"github.com/golang/protobuf/proto"
"time"
)
//mrpc测试
func main() {
ser.InitRedis()
server := ser.NewServer()
helloServer := ser.NewHelloServer()
protos.RegisterHelloServiceServer(server, helloServer)
//
ser.InitSubManager(server)
ser.Subscribe("c1") //nolint:errcheck
message := &protos.String{
Value: "rpc test",
}
marshal, err := proto.Marshal(message)
if err != nil {
panic(err)
}
//after := time.After(1 * time.Second)
//sendSum := 0
//go func() {
// duration := time.NewTicker(200* time.Millisecond)
//
//
// for {
// select{
// case <-duration.C:
// ser.Publish("c1","proto.HelloService/HelloTest", marshal) //nolint:errcheck
// fmt.Println("send c1")
// sendSum++
// case <-after:
// fmt.Println("send sum :",sendSum)
// return
// }
// }
//}()
time.Sleep(1 * time.Second)
ser.Publish("c1", "proto.HelloService/HelloTest", marshal) //nolint:errcheck
fmt.Println("send c1")
ser.Publish("c1", "proto.HelloService/HelloTest", marshal)
fmt.Println("send c1")
time.Sleep(10 * time.Minute)
}