api/api.go
func (api *Api) Listen(addr *net.TCPAddr) error {
	return api.StartFunc(func() error {

		tcpListener, err := net.ListenTCP("tcp", addr)
		if err != nil {
			return err
		}

		s := grpc.NewServer()
		carbonpb.RegisterCarbonServer(s, api)
		// Register reflection service on gRPC server.
		reflection.Register(s)

		api.Go(func(exit chan struct{}) {
			<-exit
			s.Stop()
		})

		api.Go(func(exit chan struct{}) {
			defer s.Stop()

			if err := s.Serve(tcpListener); err != nil {
				// may be stopped - not error
				// zapwriter.Logger("api").Fatal("failed to serve", zap.Error(err))
			}

		})

		api.listener = tcpListener

		return nil
	})
}
func (api *Api) Listen(addr *net.TCPAddr) error {
	return api.StartFunc(func() error {

		tcpListener, err := net.ListenTCP("tcp", addr)
		if err != nil {
			return err
		}

		s := grpc.NewServer()
		carbonpb.RegisterCarbonServer(s, api)
		// Register reflection service on gRPC server.
		reflection.Register(s)

		api.Go(func(exit chan struct{}) {
			<-exit
			s.Stop()
		})

		api.Go(func(exit chan struct{}) {
			defer s.Stop()

			if err := s.Serve(tcpListener); err != nil {
				// may be stopped - not error
				// zapwriter.Logger("api").Fatal("failed to serve", zap.Error(err))
			}

		})

		api.listener = tcpListener

		return nil
	})
}
// Listen bind port. Receive messages and send to out channel