Пример #1
0
func TestAll(t *testing.T) {
	onceAll.Do(func() {
		go listenAndServeArithAndEchoService("tcp", ":1984")
	})

	conn, err := net.Dial("tcp", "127.0.0.1:1984")
	if err != nil {
		t.Fatalf(`net.Dial("tcp", "127.0.0.1:1984"): %v`, err)
	}
	client := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
	defer client.Close()

	testArithClient(t, client)
	testEchoClient(t, client)

	arithStub := NewArithServiceStub(client)
	echoStub := NewEchoServiceStub(client)

	testArithStub(t, arithStub)
	testEchoStub(t, echoStub)
}
Пример #2
0
// NewEchoServiceBClient returns a EchoServiceB rpc.Client and stub to handle
// requests to the set of EchoServiceB at the other end of the connection.
func NewEchoServiceBClient(conn io.ReadWriteCloser) (*rpc.Client, EchoServiceB) {
	c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
	return c, &rpcEchoServiceBStub{c}
}
Пример #3
0
// NewArithServiceClient returns a ArithService rpc.Client and stub to handle
// requests to the set of ArithService at the other end of the connection.
func NewArithServiceClient(conn io.ReadWriteCloser) (*rpc.Client, ArithService) {
	c := rpc.NewClientWithCodec(protorpc.NewClientCodec(conn))
	return c, &rpcArithServiceStub{c}
}