Пример #1
0
func setupBenchServer() ([]string, error) {
	ch, err := testutils.NewServerChannel(testutils.NewOpts().
		SetServiceName(benchServerName).
		SetFramePool(tchannel.NewSyncFramePool()))
	if err != nil {
		return nil, err
	}
	fmt.Println(benchServerName, "started on", ch.PeerInfo().HostPort)

	server := thrift.NewServer(ch)
	server.Register(gen.NewTChanSecondServiceServer(benchSecondHandler{}))

	if !*useHyperbahn {
		return []string{ch.PeerInfo().HostPort}, nil
	}

	// Set up a Hyperbahn client and advertise it.
	nodes := strings.Split(*hyperbahnNodes, ",")
	config := hyperbahn.Configuration{InitialNodes: nodes}
	hc, err := hyperbahn.NewClient(ch, config, nil)
	if err := hc.Advertise(); err != nil {
		return nil, err
	}

	return nodes, nil
}
Пример #2
0
func setupServer(h *mocks.TChanSimpleService, sh *mocks.TChanSecondService) (*tchannel.Channel, *Server, error) {
	ch, err := testutils.NewServerChannel(nil)
	if err != nil {
		return nil, nil, err
	}

	server := NewServer(ch)
	server.Register(gen.NewTChanSimpleServiceServer(h))
	server.Register(gen.NewTChanSecondServiceServer(sh))
	return ch, server, nil
}
func setupServer(h *mocks.TChanTCollector) (*tchannel.Channel, error) {
	tchan, err := testutils.NewServerChannel(&testutils.ChannelOpts{
		ServiceName: tcollectorServiceName,
	})
	if err != nil {
		return nil, err
	}

	server := thrift.NewServer(tchan)
	server.Register(gen.NewTChanTCollectorServer(h))
	return tchan, nil
}
Пример #4
0
func withNewServerClient(svcName string, f func(server, client *tchannel.Channel)) {
	opts := testutils.NewOpts().SetServiceName(svcName)
	server, err := testutils.NewServerChannel(opts)
	if err != nil {
		panic(err)
	}
	defer server.Close()

	client, err := testutils.NewClientChannel(opts)
	if err != nil {
		panic(err)
	}
	defer client.Close()

	f(server, client)
}