12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Protocol Buffers - Google's data interchange format
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright 2008 Google Inc.  All rights reserved.
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// http://code.google.com/p/protobuf/
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Redistribution and use in source and binary forms, with or without
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// modification, are permitted provided that the following conditions are
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// met:
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//     * Redistributions of source code must retain the above copyright
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// notice, this list of conditions and the following disclaimer.
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//     * Redistributions in binary form must reproduce the above
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// copyright notice, this list of conditions and the following disclaimer
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// in the documentation and/or other materials provided with the
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// distribution.
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//     * Neither the name of Google Inc. nor the names of its
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// contributors may be used to endorse or promote products derived from
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// this software without specific prior written permission.
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
202a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
262a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)package com.google.protobuf;
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/**
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * <p>Abstract interface for an RPC channel.  An {@code RpcChannel} represents a
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * communication line to a {@link Service} which can be used to call that
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * {@link Service}'s methods.  The {@link Service} may be running on another
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * machine.  Normally, you should not call an {@code RpcChannel} directly, but
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * instead construct a stub {@link Service} wrapping it.  Example:
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * <pre>
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   RpcChannel channel = rpcImpl.newChannel("remotehost.example.com:1234");
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   RpcController controller = rpcImpl.newController();
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   MyService service = MyService.newStub(channel);
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *   service.myMethod(controller, request, callback);
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * </pre>
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * <p>Starting with version 2.3.0, RPC implementations should not try to build
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * on this, but should instead provide code generator plugins which generate
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * code specific to the particular RPC implementation.  This way the generated
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * code can be more appropriate for the implementation in use and can avoid
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * unnecessary layers of indirection.
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * @author kenton@google.com Kenton Varda
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)public interface RpcChannel {
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  /**
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * Call the given method of the remote service.  This method is similar to
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * {@code Service.callMethod()} with one important difference:  the caller
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * decides the types of the {@code Message} objects, not the callee.  The
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * request may be of any type as long as
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * {@code request.getDescriptor() == method.getInputType()}.
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * The response passed to the callback will be of the same type as
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * {@code responsePrototype} (which must have
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   * {@code getDescriptor() == method.getOutputType()}).
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)   */
662a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  void callMethod(Descriptors.MethodDescriptor method,
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  RpcController controller,
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  Message request,
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  Message responsePrototype,
702a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)                  RpcCallback<Message> done);
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}
72