Browse Source

Update grpc_server.go

pull/1780/head
Jacob Gadikian 8 years ago
committed by Adrian Brink
parent
commit
840e658ec0
1 changed files with 14 additions and 0 deletions
  1. +14
    -0
      server/grpc_server.go

+ 14
- 0
server/grpc_server.go View File

@ -1,3 +1,13 @@
/*
Package server is used to start a new ABCI server.
It defines the struct for gRPC server settings, and functions for:
* Starting a new gRPC server
* Stopping a gRPC server
*/
package server
import (
@ -12,6 +22,7 @@ import (
// var maxNumberConnections = 2
//GRPCServer is used to set the protocol and address for gRPC.
type GRPCServer struct {
cmn.BaseService
@ -23,6 +34,7 @@ type GRPCServer struct {
app types.ABCIApplicationServer
}
//NewGRPCServer allows setting up a new gRPC ABCI server.
func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (cmn.Service, error) {
parts := strings.SplitN(protoAddr, "://", 2)
proto, addr := parts[0], parts[1]
@ -37,6 +49,7 @@ func NewGRPCServer(protoAddr string, app types.ABCIApplicationServer) (cmn.Servi
return s, err
}
//Onstart registers a new gRPC service and tells that service to listen on the port that is set in NewGRPCServer.
func (s *GRPCServer) OnStart() error {
s.BaseService.OnStart()
ln, err := net.Listen(s.proto, s.addr)
@ -50,6 +63,7 @@ func (s *GRPCServer) OnStart() error {
return nil
}
//OnStop is called when a gRPC server is stopped.
func (s *GRPCServer) OnStop() {
s.BaseService.OnStop()
s.server.Stop()


Loading…
Cancel
Save