feat(grpc): initial grpc server. (#253)

* feat(grpc): initial grpc server.

* refactor(vendor): add missing vendor.

* fix testing

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2017-07-24 15:06:23 +08:00
committed by GitHub
parent 478e39ec65
commit 9a52f8f2b5
102 changed files with 21796 additions and 441 deletions

35
rpc/example/client.go Normal file
View File

@@ -0,0 +1,35 @@
package main
import (
"log"
pb "github.com/appleboy/gorush/rpc/proto"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
const (
address = "localhost:50051"
defaultName = "world"
)
func main() {
// Set up a connection to the server.
conn, err := grpc.Dial(address, grpc.WithInsecure())
if err != nil {
log.Fatalf("did not connect: %v", err)
}
defer conn.Close()
c := pb.NewGorushClient(conn)
r, err := c.Send(context.Background(), &pb.NotificationRequest{
Platform: 2,
Tokens: []string{"1234567890"},
Message: "test message",
})
if err != nil {
log.Fatalf("could not greet: %v", err)
}
log.Printf("Success: %t\n", r.Success)
log.Printf("Count: %d\n", r.Counts)
}