Exemplo n.º 1
0
func (s *baseTestServer) listen() (port int, err error) {
	if s.service, err = newRpc(); err != nil {
		return
	}
	if port, err = fixtures.GetOpenPort(); err != nil {
		return
	}
	s.Listener, err = net.Listen("tcp", fmt.Sprintf(":%d", port))
	return
}
Exemplo n.º 2
0
func (s *GRPCServer) Start() {
	if s.Port, s.err = fixtures.GetOpenPort(); s.err != nil {
		return
	}

	if s.l, s.err = net.Listen("tcp", fmt.Sprintf(":%d", s.Port)); s.err != nil {
		return
	}

	s.srv = grpc.NewServer()
	pb3.RegisterBarServer(s.srv, &server{})
	go s.srv.Serve(s.l)
	time.Sleep(time.Millisecond * 100)
}
Exemplo n.º 3
0
func (s *TServer) Start(transportFactory thrift.TTransportFactory) (err error) {
	if s.Port, err = fixtures.GetOpenPort(); err != nil {
		return
	}

	protoFactory := thrift.NewTBinaryProtocolFactoryDefault()
	processor := srv.NewTSrvProcessor(&service{})

	var transport thrift.TServerTransport
	if transport, err = thrift.NewTServerSocket(fmt.Sprintf(":%d", s.Port)); err != nil {
		return
	}
	s.Server = thrift.NewTSimpleServer4(processor, transport,
		transportFactory, protoFactory)
	go s.Server.Serve()
	time.Sleep(time.Millisecond * 100)
	return
}