func getClient(dst string) (tchannel.TraceReporter, error) { tchan, err := testutils.NewClientChannel(nil) if err != nil { return nil, err } tchan.Peers().Add(dst) return NewZipkinTraceReporter(tchan), nil }
func getClients(serverCh *tchannel.Channel) (gen.TChanSimpleService, gen.TChanSecondService, error) { serverInfo := serverCh.PeerInfo() ch, err := testutils.NewClientChannel(nil) if err != nil { return nil, nil, err } ch.Peers().Add(serverInfo.HostPort) client := NewClient(ch, serverInfo.ServiceName, nil) simpleClient := gen.NewTChanSimpleServiceClient(client) secondClient := gen.NewTChanSecondServiceClient(client) return simpleClient, secondClient, nil }
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) }
func main() { flag.Parse() ch, err := testutils.NewClientChannel(nil) if err != nil { log.Fatalf("Failed to create client channel: %v", err) } for _, host := range flag.Args() { ch.Peers().Add(host) } thriftClient := thrift.NewClient(ch, *serviceName, nil) client := gen.NewTChanSecondServiceClient(thriftClient) fmt.Println("bench-client started") rdr := bufio.NewReader(os.Stdin) for { line, err := rdr.ReadString('\n') if err != nil { if err == io.EOF { return } log.Fatalf("stdin read failed: %v", err) } line = strings.TrimSuffix(line, "\n") switch line { case "call": makeCall(client) case "quit": return default: log.Fatalf("unrecognized command: %v", line) } } }