Exemple #1
0
func rpcConnect(doppler, app string) {
	conn, err := grpc.Dial(doppler, grpc.WithInsecure())
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	client := plumbing.NewDopplerClient(conn)

	stream, err := client.Stream(context.Background(), &plumbing.StreamRequest{AppID: app})
	if err != nil {
		panic(err)
	}
	for {
		_, err = stream.Recv()
		if err != nil {
			panic(err)
		}
	}
}
	var waitForPrimer = func(firehose plumbing.Doppler_FirehoseClient) {
		_, err := firehose.Recv()
		Expect(err).ToNot(HaveOccurred())
	}

	var connectToDoppler = func() net.Conn {
		in, err := net.Dial("tcp", fmt.Sprintf(localIPAddress+":4321"))
		Expect(err).ToNot(HaveOccurred())
		return in
	}

	var connectoToFirehose = func() (*grpc.ClientConn, plumbing.Doppler_FirehoseClient) {
		out, err := grpc.Dial(localIPAddress+":5678", grpc.WithInsecure())
		Expect(err).ToNot(HaveOccurred())
		client := plumbing.NewDopplerClient(out)
		ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
		firehose, err := client.Firehose(ctx, &plumbing.FirehoseRequest{})
		Expect(err).ToNot(HaveOccurred())

		return out, firehose
	}

	var connectoToStream = func() (*grpc.ClientConn, plumbing.Doppler_StreamClient) {
		out, err := grpc.Dial(localIPAddress+":5678", grpc.WithInsecure())
		Expect(err).ToNot(HaveOccurred())
		client := plumbing.NewDopplerClient(out)
		ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
		stream, err := client.Stream(ctx, &plumbing.StreamRequest{})
		Expect(err).ToNot(HaveOccurred())