-
Notifications
You must be signed in to change notification settings - Fork 0
GRPC
Vojtech Mašek edited this page Aug 19, 2019
·
2 revisions
https://github.com/grpc/grpc-go
https://developers.google.com/protocol-buffers/docs/proto3
Run GRPC Server
svc := NewDummyService()
lis, err := net.Listen("tcp", viper.GetString("server.binds.grpc"))
if err != nil {
panic(err)
}
s := grpc.NewServer()
proto.RegisterDummyServer(s, svc)
// Register reflection service on gRPC server.
reflection.Register(s)
if err := s.Serve(lis); err != nil {
log.Fatalf("grpc: failed to serve: %v", err)
}
Run GRPC HTTP Gateway
ctx := context.Background()
ctx, cancel := context.WithCancel(ctx)
defer cancel()
mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
if err := proto.RegisterDummyHandlerFromEndpoint(ctx, mux, viper.GetString("server.binds.grpc"), opts); err != nil {
log.Fatalf("gw: failed to register: %v", err)
}
log.Fatalf("gw: failed to server: %v", http.ListenAndServe(viper.GetString("server.binds.gw"), mux))
-
FE / Angular
-
Golang
-
DevOps
-
Agile process and SCRUM
-
Internship
-
Bootcamp