|
|
@ -26,7 +26,6 @@ |
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
|
|
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
|
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
|
|
|
|
|
|
|
|
|
|
"""Interfaces defining the Face layer of RPC Framework.""" |
|
|
|
"""Interfaces defining the Face layer of RPC Framework.""" |
|
|
|
|
|
|
|
|
|
|
|
import abc |
|
|
|
import abc |
|
|
@ -45,33 +44,38 @@ from grpc.framework.foundation import stream # pylint: disable=unused-import |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NoSuchMethodError(Exception): |
|
|
|
class NoSuchMethodError(Exception): |
|
|
|
"""Raised by customer code to indicate an unrecognized method. |
|
|
|
"""Raised by customer code to indicate an unrecognized method. |
|
|
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
Attributes: |
|
|
|
group: The group of the unrecognized method. |
|
|
|
group: The group of the unrecognized method. |
|
|
|
name: The name of the unrecognized method. |
|
|
|
name: The name of the unrecognized method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, group, method): |
|
|
|
def __init__(self, group, method): |
|
|
|
"""Constructor. |
|
|
|
"""Constructor. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the unrecognized RPC name. |
|
|
|
group: The group identifier of the unrecognized RPC name. |
|
|
|
method: The method identifier of the unrecognized RPC name. |
|
|
|
method: The method identifier of the unrecognized RPC name. |
|
|
|
""" |
|
|
|
""" |
|
|
|
super(NoSuchMethodError, self).__init__() |
|
|
|
super(NoSuchMethodError, self).__init__() |
|
|
|
self.group = group |
|
|
|
self.group = group |
|
|
|
self.method = method |
|
|
|
self.method = method |
|
|
|
|
|
|
|
|
|
|
|
def __repr__(self): |
|
|
|
def __repr__(self): |
|
|
|
return 'face.NoSuchMethodError(%s, %s)' % (self.group, self.method,) |
|
|
|
return 'face.NoSuchMethodError(%s, %s)' % ( |
|
|
|
|
|
|
|
self.group, |
|
|
|
|
|
|
|
self.method,) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Abortion( |
|
|
|
class Abortion( |
|
|
|
collections.namedtuple( |
|
|
|
collections.namedtuple('Abortion', ( |
|
|
|
'Abortion', |
|
|
|
'kind', |
|
|
|
('kind', 'initial_metadata', 'terminal_metadata', 'code', 'details',))): |
|
|
|
'initial_metadata', |
|
|
|
"""A value describing RPC abortion. |
|
|
|
'terminal_metadata', |
|
|
|
|
|
|
|
'code', |
|
|
|
|
|
|
|
'details',))): |
|
|
|
|
|
|
|
"""A value describing RPC abortion. |
|
|
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
Attributes: |
|
|
|
kind: A Kind value identifying how the RPC failed. |
|
|
|
kind: A Kind value identifying how the RPC failed. |
|
|
@ -85,21 +89,21 @@ class Abortion( |
|
|
|
details value was received. |
|
|
|
details value was received. |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
@enum.unique |
|
|
|
@enum.unique |
|
|
|
class Kind(enum.Enum): |
|
|
|
class Kind(enum.Enum): |
|
|
|
"""Types of RPC abortion.""" |
|
|
|
"""Types of RPC abortion.""" |
|
|
|
|
|
|
|
|
|
|
|
CANCELLED = 'cancelled' |
|
|
|
CANCELLED = 'cancelled' |
|
|
|
EXPIRED = 'expired' |
|
|
|
EXPIRED = 'expired' |
|
|
|
LOCAL_SHUTDOWN = 'local shutdown' |
|
|
|
LOCAL_SHUTDOWN = 'local shutdown' |
|
|
|
REMOTE_SHUTDOWN = 'remote shutdown' |
|
|
|
REMOTE_SHUTDOWN = 'remote shutdown' |
|
|
|
NETWORK_FAILURE = 'network failure' |
|
|
|
NETWORK_FAILURE = 'network failure' |
|
|
|
LOCAL_FAILURE = 'local failure' |
|
|
|
LOCAL_FAILURE = 'local failure' |
|
|
|
REMOTE_FAILURE = 'remote failure' |
|
|
|
REMOTE_FAILURE = 'remote failure' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)): |
|
|
|
class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)): |
|
|
|
"""Common super type for exceptions indicating RPC abortion. |
|
|
|
"""Common super type for exceptions indicating RPC abortion. |
|
|
|
|
|
|
|
|
|
|
|
initial_metadata: The initial metadata from the other side of the RPC or |
|
|
|
initial_metadata: The initial metadata from the other side of the RPC or |
|
|
|
None if no initial metadata value was received. |
|
|
|
None if no initial metadata value was received. |
|
|
@ -111,100 +115,100 @@ class AbortionError(six.with_metaclass(abc.ABCMeta, Exception)): |
|
|
|
details value was received. |
|
|
|
details value was received. |
|
|
|
""" |
|
|
|
""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, initial_metadata, terminal_metadata, code, details): |
|
|
|
def __init__(self, initial_metadata, terminal_metadata, code, details): |
|
|
|
super(AbortionError, self).__init__() |
|
|
|
super(AbortionError, self).__init__() |
|
|
|
self.initial_metadata = initial_metadata |
|
|
|
self.initial_metadata = initial_metadata |
|
|
|
self.terminal_metadata = terminal_metadata |
|
|
|
self.terminal_metadata = terminal_metadata |
|
|
|
self.code = code |
|
|
|
self.code = code |
|
|
|
self.details = details |
|
|
|
self.details = details |
|
|
|
|
|
|
|
|
|
|
|
def __str__(self): |
|
|
|
def __str__(self): |
|
|
|
return '%s(code=%s, details="%s")' % ( |
|
|
|
return '%s(code=%s, details="%s")' % (self.__class__.__name__, |
|
|
|
self.__class__.__name__, self.code, self.details) |
|
|
|
self.code, self.details) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CancellationError(AbortionError): |
|
|
|
class CancellationError(AbortionError): |
|
|
|
"""Indicates that an RPC has been cancelled.""" |
|
|
|
"""Indicates that an RPC has been cancelled.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ExpirationError(AbortionError): |
|
|
|
class ExpirationError(AbortionError): |
|
|
|
"""Indicates that an RPC has expired ("timed out").""" |
|
|
|
"""Indicates that an RPC has expired ("timed out").""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LocalShutdownError(AbortionError): |
|
|
|
class LocalShutdownError(AbortionError): |
|
|
|
"""Indicates that an RPC has terminated due to local shutdown of RPCs.""" |
|
|
|
"""Indicates that an RPC has terminated due to local shutdown of RPCs.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RemoteShutdownError(AbortionError): |
|
|
|
class RemoteShutdownError(AbortionError): |
|
|
|
"""Indicates that an RPC has terminated due to remote shutdown of RPCs.""" |
|
|
|
"""Indicates that an RPC has terminated due to remote shutdown of RPCs.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NetworkError(AbortionError): |
|
|
|
class NetworkError(AbortionError): |
|
|
|
"""Indicates that some error occurred on the network.""" |
|
|
|
"""Indicates that some error occurred on the network.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LocalError(AbortionError): |
|
|
|
class LocalError(AbortionError): |
|
|
|
"""Indicates that an RPC has terminated due to a local defect.""" |
|
|
|
"""Indicates that an RPC has terminated due to a local defect.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RemoteError(AbortionError): |
|
|
|
class RemoteError(AbortionError): |
|
|
|
"""Indicates that an RPC has terminated due to a remote defect.""" |
|
|
|
"""Indicates that an RPC has terminated due to a remote defect.""" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class RpcContext(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class RpcContext(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Provides RPC-related information and action.""" |
|
|
|
"""Provides RPC-related information and action.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def is_active(self): |
|
|
|
def is_active(self): |
|
|
|
"""Describes whether the RPC is active or has terminated.""" |
|
|
|
"""Describes whether the RPC is active or has terminated.""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def time_remaining(self): |
|
|
|
def time_remaining(self): |
|
|
|
"""Describes the length of allowed time remaining for the RPC. |
|
|
|
"""Describes the length of allowed time remaining for the RPC. |
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A nonnegative float indicating the length of allowed time in seconds |
|
|
|
A nonnegative float indicating the length of allowed time in seconds |
|
|
|
remaining for the RPC to complete before it is considered to have timed |
|
|
|
remaining for the RPC to complete before it is considered to have timed |
|
|
|
out. |
|
|
|
out. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def add_abortion_callback(self, abortion_callback): |
|
|
|
def add_abortion_callback(self, abortion_callback): |
|
|
|
"""Registers a callback to be called if the RPC is aborted. |
|
|
|
"""Registers a callback to be called if the RPC is aborted. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
abortion_callback: A callable to be called and passed an Abortion value |
|
|
|
abortion_callback: A callable to be called and passed an Abortion value |
|
|
|
in the event of RPC abortion. |
|
|
|
in the event of RPC abortion. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def cancel(self): |
|
|
|
def cancel(self): |
|
|
|
"""Cancels the RPC. |
|
|
|
"""Cancels the RPC. |
|
|
|
|
|
|
|
|
|
|
|
Idempotent and has no effect if the RPC has already terminated. |
|
|
|
Idempotent and has no effect if the RPC has already terminated. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def protocol_context(self): |
|
|
|
def protocol_context(self): |
|
|
|
"""Accesses a custom object specified by an implementation provider. |
|
|
|
"""Accesses a custom object specified by an implementation provider. |
|
|
|
|
|
|
|
|
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A value specified by the provider of a Face interface implementation |
|
|
|
A value specified by the provider of a Face interface implementation |
|
|
|
affording custom state and behavior. |
|
|
|
affording custom state and behavior. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
"""Invocation-side utility object for an RPC.""" |
|
|
|
"""Invocation-side utility object for an RPC.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def initial_metadata(self): |
|
|
|
def initial_metadata(self): |
|
|
|
"""Accesses the initial metadata from the service-side of the RPC. |
|
|
|
"""Accesses the initial metadata from the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
emitted from the service-side of the RPC. |
|
|
|
emitted from the service-side of the RPC. |
|
|
@ -213,11 +217,11 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
The initial metadata object emitted by the service-side of the RPC, or |
|
|
|
The initial metadata object emitted by the service-side of the RPC, or |
|
|
|
None if there was no such value. |
|
|
|
None if there was no such value. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def terminal_metadata(self): |
|
|
|
def terminal_metadata(self): |
|
|
|
"""Accesses the terminal metadata from the service-side of the RPC. |
|
|
|
"""Accesses the terminal metadata from the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
emitted from the service-side of the RPC. |
|
|
|
emitted from the service-side of the RPC. |
|
|
@ -226,11 +230,11 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
The terminal metadata object emitted by the service-side of the RPC, or |
|
|
|
The terminal metadata object emitted by the service-side of the RPC, or |
|
|
|
None if there was no such value. |
|
|
|
None if there was no such value. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def code(self): |
|
|
|
def code(self): |
|
|
|
"""Accesses the code emitted by the service-side of the RPC. |
|
|
|
"""Accesses the code emitted by the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
emitted from the service-side of the RPC. |
|
|
|
emitted from the service-side of the RPC. |
|
|
@ -239,11 +243,11 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
The code object emitted by the service-side of the RPC, or None if there |
|
|
|
The code object emitted by the service-side of the RPC, or None if there |
|
|
|
was no such value. |
|
|
|
was no such value. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def details(self): |
|
|
|
def details(self): |
|
|
|
"""Accesses the details value emitted by the service-side of the RPC. |
|
|
|
"""Accesses the details value emitted by the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
emitted from the service-side of the RPC. |
|
|
|
emitted from the service-side of the RPC. |
|
|
@ -252,15 +256,15 @@ class Call(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
The details value emitted by the service-side of the RPC, or None if there |
|
|
|
The details value emitted by the service-side of the RPC, or None if there |
|
|
|
was no such value. |
|
|
|
was no such value. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
"""A context object passed to method implementations.""" |
|
|
|
"""A context object passed to method implementations.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def invocation_metadata(self): |
|
|
|
def invocation_metadata(self): |
|
|
|
"""Accesses the metadata from the invocation-side of the RPC. |
|
|
|
"""Accesses the metadata from the invocation-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
This method blocks until the value is available or is known not to have been |
|
|
|
emitted from the invocation-side of the RPC. |
|
|
|
emitted from the invocation-side of the RPC. |
|
|
@ -269,11 +273,11 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
The metadata object emitted by the invocation-side of the RPC, or None if |
|
|
|
The metadata object emitted by the invocation-side of the RPC, or None if |
|
|
|
there was no such value. |
|
|
|
there was no such value. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def initial_metadata(self, initial_metadata): |
|
|
|
def initial_metadata(self, initial_metadata): |
|
|
|
"""Accepts the service-side initial metadata value of the RPC. |
|
|
|
"""Accepts the service-side initial metadata value of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
service-side initial metadata to transmit. |
|
|
|
service-side initial metadata to transmit. |
|
|
@ -282,11 +286,11 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
initial_metadata: The service-side initial metadata value of the RPC to |
|
|
|
initial_metadata: The service-side initial metadata value of the RPC to |
|
|
|
be transmitted to the invocation side of the RPC. |
|
|
|
be transmitted to the invocation side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def terminal_metadata(self, terminal_metadata): |
|
|
|
def terminal_metadata(self, terminal_metadata): |
|
|
|
"""Accepts the service-side terminal metadata value of the RPC. |
|
|
|
"""Accepts the service-side terminal metadata value of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
service-side terminal metadata to transmit. |
|
|
|
service-side terminal metadata to transmit. |
|
|
@ -295,11 +299,11 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
terminal_metadata: The service-side terminal metadata value of the RPC to |
|
|
|
terminal_metadata: The service-side terminal metadata value of the RPC to |
|
|
|
be transmitted to the invocation side of the RPC. |
|
|
|
be transmitted to the invocation side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def code(self, code): |
|
|
|
def code(self, code): |
|
|
|
"""Accepts the service-side code of the RPC. |
|
|
|
"""Accepts the service-side code of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
code to transmit. |
|
|
|
code to transmit. |
|
|
@ -308,11 +312,11 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
code: The code of the RPC to be transmitted to the invocation side of the |
|
|
|
code: The code of the RPC to be transmitted to the invocation side of the |
|
|
|
RPC. |
|
|
|
RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def details(self, details): |
|
|
|
def details(self, details): |
|
|
|
"""Accepts the service-side details of the RPC. |
|
|
|
"""Accepts the service-side details of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
This method need not be called by method implementations if they have no |
|
|
|
service-side details to transmit. |
|
|
|
service-side details to transmit. |
|
|
@ -321,34 +325,34 @@ class ServicerContext(six.with_metaclass(abc.ABCMeta, RpcContext)): |
|
|
|
details: The service-side details value of the RPC to be transmitted to |
|
|
|
details: The service-side details value of the RPC to be transmitted to |
|
|
|
the invocation side of the RPC. |
|
|
|
the invocation side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ResponseReceiver(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class ResponseReceiver(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Invocation-side object used to accept the output of an RPC.""" |
|
|
|
"""Invocation-side object used to accept the output of an RPC.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def initial_metadata(self, initial_metadata): |
|
|
|
def initial_metadata(self, initial_metadata): |
|
|
|
"""Receives the initial metadata from the service-side of the RPC. |
|
|
|
"""Receives the initial metadata from the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
initial_metadata: The initial metadata object emitted from the |
|
|
|
initial_metadata: The initial metadata object emitted from the |
|
|
|
service-side of the RPC. |
|
|
|
service-side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def response(self, response): |
|
|
|
def response(self, response): |
|
|
|
"""Receives a response from the service-side of the RPC. |
|
|
|
"""Receives a response from the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
response: A response object emitted from the service-side of the RPC. |
|
|
|
response: A response object emitted from the service-side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def complete(self, terminal_metadata, code, details): |
|
|
|
def complete(self, terminal_metadata, code, details): |
|
|
|
"""Receives the completion values emitted from the service-side of the RPC. |
|
|
|
"""Receives the completion values emitted from the service-side of the RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
terminal_metadata: The terminal metadata object emitted from the |
|
|
|
terminal_metadata: The terminal metadata object emitted from the |
|
|
@ -356,17 +360,20 @@ class ResponseReceiver(six.with_metaclass(abc.ABCMeta)): |
|
|
|
code: The code object emitted from the service-side of the RPC. |
|
|
|
code: The code object emitted from the service-side of the RPC. |
|
|
|
details: The details object emitted from the service-side of the RPC. |
|
|
|
details: The details object emitted from the service-side of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords invoking a unary-unary RPC in any call style.""" |
|
|
|
"""Affords invoking a unary-unary RPC in any call style.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def __call__( |
|
|
|
def __call__(self, |
|
|
|
self, request, timeout, metadata=None, with_call=False, |
|
|
|
request, |
|
|
|
protocol_options=None): |
|
|
|
timeout, |
|
|
|
"""Synchronously invokes the underlying RPC. |
|
|
|
metadata=None, |
|
|
|
|
|
|
|
with_call=False, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Synchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request: The request value for the RPC. |
|
|
|
request: The request value for the RPC. |
|
|
@ -385,11 +392,11 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Raises: |
|
|
|
Raises: |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def future(self, request, timeout, metadata=None, protocol_options=None): |
|
|
|
def future(self, request, timeout, metadata=None, protocol_options=None): |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request: The request value for the RPC. |
|
|
|
request: The request value for the RPC. |
|
|
@ -405,13 +412,17 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event( |
|
|
|
def event(self, |
|
|
|
self, request, receiver, abortion_callback, timeout, |
|
|
|
request, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
receiver, |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request: The request value for the RPC. |
|
|
|
request: The request value for the RPC. |
|
|
@ -427,15 +438,15 @@ class UnaryUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A Call for the RPC. |
|
|
|
A Call for the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords invoking a unary-stream RPC in any call style.""" |
|
|
|
"""Affords invoking a unary-stream RPC in any call style.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def __call__(self, request, timeout, metadata=None, protocol_options=None): |
|
|
|
def __call__(self, request, timeout, metadata=None, protocol_options=None): |
|
|
|
"""Invokes the underlying RPC. |
|
|
|
"""Invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request: The request value for the RPC. |
|
|
|
request: The request value for the RPC. |
|
|
@ -450,13 +461,17 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event( |
|
|
|
def event(self, |
|
|
|
self, request, receiver, abortion_callback, timeout, |
|
|
|
request, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
receiver, |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request: The request value for the RPC. |
|
|
|
request: The request value for the RPC. |
|
|
@ -472,17 +487,20 @@ class UnaryStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A Call object for the RPC. |
|
|
|
A Call object for the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords invoking a stream-unary RPC in any call style.""" |
|
|
|
"""Affords invoking a stream-unary RPC in any call style.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def __call__( |
|
|
|
def __call__(self, |
|
|
|
self, request_iterator, timeout, metadata=None, |
|
|
|
request_iterator, |
|
|
|
with_call=False, protocol_options=None): |
|
|
|
timeout, |
|
|
|
"""Synchronously invokes the underlying RPC. |
|
|
|
metadata=None, |
|
|
|
|
|
|
|
with_call=False, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Synchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
@ -501,12 +519,15 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Raises: |
|
|
|
Raises: |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def future( |
|
|
|
def future(self, |
|
|
|
self, request_iterator, timeout, metadata=None, protocol_options=None): |
|
|
|
request_iterator, |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
@ -522,13 +543,16 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event( |
|
|
|
def event(self, |
|
|
|
self, receiver, abortion_callback, timeout, metadata=None, |
|
|
|
receiver, |
|
|
|
protocol_options=None): |
|
|
|
abortion_callback, |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
receiver: A ResponseReceiver to be passed the response data of the RPC. |
|
|
|
receiver: A ResponseReceiver to be passed the response data of the RPC. |
|
|
@ -544,16 +568,19 @@ class StreamUnaryMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
A single object that is both a Call object for the RPC and a |
|
|
|
A single object that is both a Call object for the RPC and a |
|
|
|
stream.Consumer to which the request values of the RPC should be passed. |
|
|
|
stream.Consumer to which the request values of the RPC should be passed. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords invoking a stream-stream RPC in any call style.""" |
|
|
|
"""Affords invoking a stream-stream RPC in any call style.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def __call__( |
|
|
|
def __call__(self, |
|
|
|
self, request_iterator, timeout, metadata=None, protocol_options=None): |
|
|
|
request_iterator, |
|
|
|
"""Invokes the underlying RPC. |
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
|
request_iterator: An iterator that yields request values for the RPC. |
|
|
@ -568,13 +595,16 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event( |
|
|
|
def event(self, |
|
|
|
self, receiver, abortion_callback, timeout, metadata=None, |
|
|
|
receiver, |
|
|
|
protocol_options=None): |
|
|
|
abortion_callback, |
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Asynchronously invokes the underlying RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
receiver: A ResponseReceiver to be passed the response data of the RPC. |
|
|
|
receiver: A ResponseReceiver to be passed the response data of the RPC. |
|
|
@ -590,11 +620,11 @@ class StreamStreamMultiCallable(six.with_metaclass(abc.ABCMeta)): |
|
|
|
A single object that is both a Call object for the RPC and a |
|
|
|
A single object that is both a Call object for the RPC and a |
|
|
|
stream.Consumer to which the request values of the RPC should be passed. |
|
|
|
stream.Consumer to which the request values of the RPC should be passed. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class MethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""A sum type that describes a method implementation. |
|
|
|
"""A sum type that describes a method implementation. |
|
|
|
|
|
|
|
|
|
|
|
Attributes: |
|
|
|
Attributes: |
|
|
|
cardinality: A cardinality.Cardinality value. |
|
|
|
cardinality: A cardinality.Cardinality value. |
|
|
@ -639,11 +669,11 @@ class MethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""A general type able to service many methods.""" |
|
|
|
"""A general type able to service many methods.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def service(self, group, method, response_consumer, context): |
|
|
|
def service(self, group, method, response_consumer, context): |
|
|
|
"""Services an RPC. |
|
|
|
"""Services an RPC. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -666,17 +696,22 @@ class MultiMethodImplementation(six.with_metaclass(abc.ABCMeta)): |
|
|
|
NoSuchMethodError: If this MultiMethod does not recognize the given group |
|
|
|
NoSuchMethodError: If this MultiMethod does not recognize the given group |
|
|
|
and name for the RPC and is not able to service the RPC. |
|
|
|
and name for the RPC and is not able to service the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords RPC invocation via generic methods.""" |
|
|
|
"""Affords RPC invocation via generic methods.""" |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def blocking_unary_unary( |
|
|
|
def blocking_unary_unary(self, |
|
|
|
self, group, method, request, timeout, metadata=None, |
|
|
|
group, |
|
|
|
with_call=False, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a unary-request-unary-response method. |
|
|
|
request, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
with_call=False, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a unary-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until either returning the response value of the RPC |
|
|
|
This method blocks until either returning the response value of the RPC |
|
|
|
(in the event of RPC completion) or raising an exception (in the event of |
|
|
|
(in the event of RPC completion) or raising an exception (in the event of |
|
|
@ -700,13 +735,17 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Raises: |
|
|
|
Raises: |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def future_unary_unary( |
|
|
|
def future_unary_unary(self, |
|
|
|
self, group, method, request, timeout, metadata=None, |
|
|
|
group, |
|
|
|
protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a unary-request-unary-response method. |
|
|
|
request, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a unary-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -723,13 +762,17 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def inline_unary_stream( |
|
|
|
def inline_unary_stream(self, |
|
|
|
self, group, method, request, timeout, metadata=None, |
|
|
|
group, |
|
|
|
protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a unary-request-stream-response method. |
|
|
|
request, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a unary-request-stream-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -745,13 +788,18 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def blocking_stream_unary( |
|
|
|
def blocking_stream_unary(self, |
|
|
|
self, group, method, request_iterator, timeout, metadata=None, |
|
|
|
group, |
|
|
|
with_call=False, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a stream-request-unary-response method. |
|
|
|
request_iterator, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
with_call=False, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a stream-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
This method blocks until either returning the response value of the RPC |
|
|
|
This method blocks until either returning the response value of the RPC |
|
|
|
(in the event of RPC completion) or raising an exception (in the event of |
|
|
|
(in the event of RPC completion) or raising an exception (in the event of |
|
|
@ -775,13 +823,17 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Raises: |
|
|
|
Raises: |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
AbortionError: Indicating that the RPC was aborted. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def future_stream_unary( |
|
|
|
def future_stream_unary(self, |
|
|
|
self, group, method, request_iterator, timeout, metadata=None, |
|
|
|
group, |
|
|
|
protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a stream-request-unary-response method. |
|
|
|
request_iterator, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a stream-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -798,13 +850,17 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
response value of the RPC. In the event of RPC abortion, the returned |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
Future's exception value will be an AbortionError. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def inline_stream_stream( |
|
|
|
def inline_stream_stream(self, |
|
|
|
self, group, method, request_iterator, timeout, metadata=None, |
|
|
|
group, |
|
|
|
protocol_options=None): |
|
|
|
method, |
|
|
|
"""Invokes a stream-request-stream-response method. |
|
|
|
request_iterator, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Invokes a stream-request-stream-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -820,13 +876,19 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
values. Drawing response values from the returned iterator may raise |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
AbortionError indicating abortion of the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event_unary_unary( |
|
|
|
def event_unary_unary(self, |
|
|
|
self, group, method, request, receiver, abortion_callback, timeout, |
|
|
|
group, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Event-driven invocation of a unary-request-unary-response method. |
|
|
|
request, |
|
|
|
|
|
|
|
receiver, |
|
|
|
|
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Event-driven invocation of a unary-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -843,13 +905,19 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A Call for the RPC. |
|
|
|
A Call for the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event_unary_stream( |
|
|
|
def event_unary_stream(self, |
|
|
|
self, group, method, request, receiver, abortion_callback, timeout, |
|
|
|
group, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Event-driven invocation of a unary-request-stream-response method. |
|
|
|
request, |
|
|
|
|
|
|
|
receiver, |
|
|
|
|
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Event-driven invocation of a unary-request-stream-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -866,13 +934,18 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A Call for the RPC. |
|
|
|
A Call for the RPC. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event_stream_unary( |
|
|
|
def event_stream_unary(self, |
|
|
|
self, group, method, receiver, abortion_callback, timeout, |
|
|
|
group, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Event-driven invocation of a unary-request-unary-response method. |
|
|
|
receiver, |
|
|
|
|
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Event-driven invocation of a unary-request-unary-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -889,13 +962,18 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
A pair of a Call object for the RPC and a stream.Consumer to which the |
|
|
|
A pair of a Call object for the RPC and a stream.Consumer to which the |
|
|
|
request values of the RPC should be passed. |
|
|
|
request values of the RPC should be passed. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def event_stream_stream( |
|
|
|
def event_stream_stream(self, |
|
|
|
self, group, method, receiver, abortion_callback, timeout, |
|
|
|
group, |
|
|
|
metadata=None, protocol_options=None): |
|
|
|
method, |
|
|
|
"""Event-driven invocation of a unary-request-stream-response method. |
|
|
|
receiver, |
|
|
|
|
|
|
|
abortion_callback, |
|
|
|
|
|
|
|
timeout, |
|
|
|
|
|
|
|
metadata=None, |
|
|
|
|
|
|
|
protocol_options=None): |
|
|
|
|
|
|
|
"""Event-driven invocation of a unary-request-stream-response method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -912,11 +990,11 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
A pair of a Call object for the RPC and a stream.Consumer to which the |
|
|
|
A pair of a Call object for the RPC and a stream.Consumer to which the |
|
|
|
request values of the RPC should be passed. |
|
|
|
request values of the RPC should be passed. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def unary_unary(self, group, method): |
|
|
|
def unary_unary(self, group, method): |
|
|
|
"""Creates a UnaryUnaryMultiCallable for a unary-unary method. |
|
|
|
"""Creates a UnaryUnaryMultiCallable for a unary-unary method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -925,11 +1003,11 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A UnaryUnaryMultiCallable value for the named unary-unary method. |
|
|
|
A UnaryUnaryMultiCallable value for the named unary-unary method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def unary_stream(self, group, method): |
|
|
|
def unary_stream(self, group, method): |
|
|
|
"""Creates a UnaryStreamMultiCallable for a unary-stream method. |
|
|
|
"""Creates a UnaryStreamMultiCallable for a unary-stream method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -938,11 +1016,11 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A UnaryStreamMultiCallable value for the name unary-stream method. |
|
|
|
A UnaryStreamMultiCallable value for the name unary-stream method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def stream_unary(self, group, method): |
|
|
|
def stream_unary(self, group, method): |
|
|
|
"""Creates a StreamUnaryMultiCallable for a stream-unary method. |
|
|
|
"""Creates a StreamUnaryMultiCallable for a stream-unary method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -951,11 +1029,11 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A StreamUnaryMultiCallable value for the named stream-unary method. |
|
|
|
A StreamUnaryMultiCallable value for the named stream-unary method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
@abc.abstractmethod |
|
|
|
@abc.abstractmethod |
|
|
|
def stream_stream(self, group, method): |
|
|
|
def stream_stream(self, group, method): |
|
|
|
"""Creates a StreamStreamMultiCallable for a stream-stream method. |
|
|
|
"""Creates a StreamStreamMultiCallable for a stream-stream method. |
|
|
|
|
|
|
|
|
|
|
|
Args: |
|
|
|
Args: |
|
|
|
group: The group identifier of the RPC. |
|
|
|
group: The group identifier of the RPC. |
|
|
@ -964,11 +1042,11 @@ class GenericStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
Returns: |
|
|
|
Returns: |
|
|
|
A StreamStreamMultiCallable value for the named stream-stream method. |
|
|
|
A StreamStreamMultiCallable value for the named stream-stream method. |
|
|
|
""" |
|
|
|
""" |
|
|
|
raise NotImplementedError() |
|
|
|
raise NotImplementedError() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DynamicStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
class DynamicStub(six.with_metaclass(abc.ABCMeta)): |
|
|
|
"""Affords RPC invocation via attributes corresponding to afforded methods. |
|
|
|
"""Affords RPC invocation via attributes corresponding to afforded methods. |
|
|
|
|
|
|
|
|
|
|
|
Instances of this type may be scoped to a single group so that attribute |
|
|
|
Instances of this type may be scoped to a single group so that attribute |
|
|
|
access is unambiguous. |
|
|
|
access is unambiguous. |
|
|
|