Added delete option to database storage.
This commit is contained in:
parent
308604a33c
commit
963b5bc68b
1868 changed files with 192402 additions and 13278 deletions
13
venv/Lib/site-packages/grpc/framework/__init__.py
Normal file
13
venv/Lib/site-packages/grpc/framework/__init__.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
13
venv/Lib/site-packages/grpc/framework/common/__init__.py
Normal file
13
venv/Lib/site-packages/grpc/framework/common/__init__.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
26
venv/Lib/site-packages/grpc/framework/common/cardinality.py
Normal file
26
venv/Lib/site-packages/grpc/framework/common/cardinality.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Defines an enum for classifying RPC methods by streaming semantics."""
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
@enum.unique
|
||||
class Cardinality(enum.Enum):
|
||||
"""Describes the streaming semantics of an RPC method."""
|
||||
|
||||
UNARY_UNARY = 'request-unary/response-unary'
|
||||
UNARY_STREAM = 'request-unary/response-streaming'
|
||||
STREAM_UNARY = 'request-streaming/response-unary'
|
||||
STREAM_STREAM = 'request-streaming/response-streaming'
|
24
venv/Lib/site-packages/grpc/framework/common/style.py
Normal file
24
venv/Lib/site-packages/grpc/framework/common/style.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Defines an enum for classifying RPC methods by control flow semantics."""
|
||||
|
||||
import enum
|
||||
|
||||
|
||||
@enum.unique
|
||||
class Service(enum.Enum):
|
||||
"""Describes the control flow style of RPC method implementation."""
|
||||
|
||||
INLINE = 'inline'
|
||||
EVENT = 'event'
|
13
venv/Lib/site-packages/grpc/framework/foundation/__init__.py
Normal file
13
venv/Lib/site-packages/grpc/framework/foundation/__init__.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Utilities for indicating abandonment of computation."""
|
||||
|
||||
|
||||
class Abandoned(Exception):
|
||||
"""Indicates that some computation is being abandoned.
|
||||
|
||||
Abandoning a computation is different than returning a value or raising
|
||||
an exception indicating some operational or programming defect.
|
||||
"""
|
|
@ -0,0 +1,96 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Utilities for working with callables."""
|
||||
|
||||
import abc
|
||||
import collections
|
||||
import enum
|
||||
import functools
|
||||
import logging
|
||||
|
||||
import six
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Outcome(six.with_metaclass(abc.ABCMeta)):
|
||||
"""A sum type describing the outcome of some call.
|
||||
|
||||
Attributes:
|
||||
kind: One of Kind.RETURNED or Kind.RAISED respectively indicating that the
|
||||
call returned a value or raised an exception.
|
||||
return_value: The value returned by the call. Must be present if kind is
|
||||
Kind.RETURNED.
|
||||
exception: The exception raised by the call. Must be present if kind is
|
||||
Kind.RAISED.
|
||||
"""
|
||||
|
||||
@enum.unique
|
||||
class Kind(enum.Enum):
|
||||
"""Identifies the general kind of the outcome of some call."""
|
||||
|
||||
RETURNED = object()
|
||||
RAISED = object()
|
||||
|
||||
|
||||
class _EasyOutcome(
|
||||
collections.namedtuple('_EasyOutcome',
|
||||
['kind', 'return_value', 'exception']), Outcome):
|
||||
"""A trivial implementation of Outcome."""
|
||||
|
||||
|
||||
def _call_logging_exceptions(behavior, message, *args, **kwargs):
|
||||
try:
|
||||
return _EasyOutcome(Outcome.Kind.RETURNED, behavior(*args, **kwargs),
|
||||
None)
|
||||
except Exception as e: # pylint: disable=broad-except
|
||||
_LOGGER.exception(message)
|
||||
return _EasyOutcome(Outcome.Kind.RAISED, None, e)
|
||||
|
||||
|
||||
def with_exceptions_logged(behavior, message):
|
||||
"""Wraps a callable in a try-except that logs any exceptions it raises.
|
||||
|
||||
Args:
|
||||
behavior: Any callable.
|
||||
message: A string to log if the behavior raises an exception.
|
||||
|
||||
Returns:
|
||||
A callable that when executed invokes the given behavior. The returned
|
||||
callable takes the same arguments as the given behavior but returns a
|
||||
future.Outcome describing whether the given behavior returned a value or
|
||||
raised an exception.
|
||||
"""
|
||||
|
||||
@functools.wraps(behavior)
|
||||
def wrapped_behavior(*args, **kwargs):
|
||||
return _call_logging_exceptions(behavior, message, *args, **kwargs)
|
||||
|
||||
return wrapped_behavior
|
||||
|
||||
|
||||
def call_logging_exceptions(behavior, message, *args, **kwargs):
|
||||
"""Calls a behavior in a try-except that logs any exceptions it raises.
|
||||
|
||||
Args:
|
||||
behavior: Any callable.
|
||||
message: A string to log if the behavior raises an exception.
|
||||
*args: Positional arguments to pass to the given behavior.
|
||||
**kwargs: Keyword arguments to pass to the given behavior.
|
||||
|
||||
Returns:
|
||||
An Outcome describing whether the given behavior returned a value or raised
|
||||
an exception.
|
||||
"""
|
||||
return _call_logging_exceptions(behavior, message, *args, **kwargs)
|
221
venv/Lib/site-packages/grpc/framework/foundation/future.py
Normal file
221
venv/Lib/site-packages/grpc/framework/foundation/future.py
Normal file
|
@ -0,0 +1,221 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""A Future interface.
|
||||
|
||||
Python doesn't have a Future interface in its standard library. In the absence
|
||||
of such a standard, three separate, incompatible implementations
|
||||
(concurrent.futures.Future, ndb.Future, and asyncio.Future) have appeared. This
|
||||
interface attempts to be as compatible as possible with
|
||||
concurrent.futures.Future. From ndb.Future it adopts a traceback-object accessor
|
||||
method.
|
||||
|
||||
Unlike the concrete and implemented Future classes listed above, the Future
|
||||
class defined in this module is an entirely abstract interface that anyone may
|
||||
implement and use.
|
||||
|
||||
The one known incompatibility between this interface and the interface of
|
||||
concurrent.futures.Future is that this interface defines its own CancelledError
|
||||
and TimeoutError exceptions rather than raising the implementation-private
|
||||
concurrent.futures._base.CancelledError and the
|
||||
built-in-but-only-in-3.3-and-later TimeoutError.
|
||||
"""
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class TimeoutError(Exception):
|
||||
"""Indicates that a particular call timed out."""
|
||||
|
||||
|
||||
class CancelledError(Exception):
|
||||
"""Indicates that the computation underlying a Future was cancelled."""
|
||||
|
||||
|
||||
class Future(six.with_metaclass(abc.ABCMeta)):
|
||||
"""A representation of a computation in another control flow.
|
||||
|
||||
Computations represented by a Future may be yet to be begun, may be ongoing,
|
||||
or may have already completed.
|
||||
"""
|
||||
|
||||
# NOTE(nathaniel): This isn't the return type that I would want to have if it
|
||||
# were up to me. Were this interface being written from scratch, the return
|
||||
# type of this method would probably be a sum type like:
|
||||
#
|
||||
# NOT_COMMENCED
|
||||
# COMMENCED_AND_NOT_COMPLETED
|
||||
# PARTIAL_RESULT<Partial_Result_Type>
|
||||
# COMPLETED<Result_Type>
|
||||
# UNCANCELLABLE
|
||||
# NOT_IMMEDIATELY_DETERMINABLE
|
||||
@abc.abstractmethod
|
||||
def cancel(self):
|
||||
"""Attempts to cancel the computation.
|
||||
|
||||
This method does not block.
|
||||
|
||||
Returns:
|
||||
True if the computation has not yet begun, will not be allowed to take
|
||||
place, and determination of both was possible without blocking. False
|
||||
under all other circumstances including but not limited to the
|
||||
computation's already having begun, the computation's already having
|
||||
finished, and the computation's having been scheduled for execution on a
|
||||
remote system for which a determination of whether or not it commenced
|
||||
before being cancelled cannot be made without blocking.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
# NOTE(nathaniel): Here too this isn't the return type that I'd want this
|
||||
# method to have if it were up to me. I think I'd go with another sum type
|
||||
# like:
|
||||
#
|
||||
# NOT_CANCELLED (this object's cancel method hasn't been called)
|
||||
# NOT_COMMENCED
|
||||
# COMMENCED_AND_NOT_COMPLETED
|
||||
# PARTIAL_RESULT<Partial_Result_Type>
|
||||
# COMPLETED<Result_Type>
|
||||
# UNCANCELLABLE
|
||||
# NOT_IMMEDIATELY_DETERMINABLE
|
||||
#
|
||||
# Notice how giving the cancel method the right semantics obviates most
|
||||
# reasons for this method to exist.
|
||||
@abc.abstractmethod
|
||||
def cancelled(self):
|
||||
"""Describes whether the computation was cancelled.
|
||||
|
||||
This method does not block.
|
||||
|
||||
Returns:
|
||||
True if the computation was cancelled any time before its result became
|
||||
immediately available. False under all other circumstances including but
|
||||
not limited to this object's cancel method not having been called and
|
||||
the computation's result having become immediately available.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def running(self):
|
||||
"""Describes whether the computation is taking place.
|
||||
|
||||
This method does not block.
|
||||
|
||||
Returns:
|
||||
True if the computation is scheduled to take place in the future or is
|
||||
taking place now, or False if the computation took place in the past or
|
||||
was cancelled.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
# NOTE(nathaniel): These aren't quite the semantics I'd like here either. I
|
||||
# would rather this only returned True in cases in which the underlying
|
||||
# computation completed successfully. A computation's having been cancelled
|
||||
# conflicts with considering that computation "done".
|
||||
@abc.abstractmethod
|
||||
def done(self):
|
||||
"""Describes whether the computation has taken place.
|
||||
|
||||
This method does not block.
|
||||
|
||||
Returns:
|
||||
True if the computation is known to have either completed or have been
|
||||
unscheduled or interrupted. False if the computation may possibly be
|
||||
executing or scheduled to execute later.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def result(self, timeout=None):
|
||||
"""Accesses the outcome of the computation or raises its exception.
|
||||
|
||||
This method may return immediately or may block.
|
||||
|
||||
Args:
|
||||
timeout: The length of time in seconds to wait for the computation to
|
||||
finish or be cancelled, or None if this method should block until the
|
||||
computation has finished or is cancelled no matter how long that takes.
|
||||
|
||||
Returns:
|
||||
The return value of the computation.
|
||||
|
||||
Raises:
|
||||
TimeoutError: If a timeout value is passed and the computation does not
|
||||
terminate within the allotted time.
|
||||
CancelledError: If the computation was cancelled.
|
||||
Exception: If the computation raised an exception, this call will raise
|
||||
the same exception.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def exception(self, timeout=None):
|
||||
"""Return the exception raised by the computation.
|
||||
|
||||
This method may return immediately or may block.
|
||||
|
||||
Args:
|
||||
timeout: The length of time in seconds to wait for the computation to
|
||||
terminate or be cancelled, or None if this method should block until
|
||||
the computation is terminated or is cancelled no matter how long that
|
||||
takes.
|
||||
|
||||
Returns:
|
||||
The exception raised by the computation, or None if the computation did
|
||||
not raise an exception.
|
||||
|
||||
Raises:
|
||||
TimeoutError: If a timeout value is passed and the computation does not
|
||||
terminate within the allotted time.
|
||||
CancelledError: If the computation was cancelled.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def traceback(self, timeout=None):
|
||||
"""Access the traceback of the exception raised by the computation.
|
||||
|
||||
This method may return immediately or may block.
|
||||
|
||||
Args:
|
||||
timeout: The length of time in seconds to wait for the computation to
|
||||
terminate or be cancelled, or None if this method should block until
|
||||
the computation is terminated or is cancelled no matter how long that
|
||||
takes.
|
||||
|
||||
Returns:
|
||||
The traceback of the exception raised by the computation, or None if the
|
||||
computation did not raise an exception.
|
||||
|
||||
Raises:
|
||||
TimeoutError: If a timeout value is passed and the computation does not
|
||||
terminate within the allotted time.
|
||||
CancelledError: If the computation was cancelled.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def add_done_callback(self, fn):
|
||||
"""Adds a function to be called at completion of the computation.
|
||||
|
||||
The callback will be passed this Future object describing the outcome of
|
||||
the computation.
|
||||
|
||||
If the computation has already completed, the callback will be called
|
||||
immediately.
|
||||
|
||||
Args:
|
||||
fn: A callable taking this Future object as its single parameter.
|
||||
"""
|
||||
raise NotImplementedError()
|
|
@ -0,0 +1,72 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""A thread pool that logs exceptions raised by tasks executed within it."""
|
||||
|
||||
import logging
|
||||
|
||||
from concurrent import futures
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _wrap(behavior):
|
||||
"""Wraps an arbitrary callable behavior in exception-logging."""
|
||||
|
||||
def _wrapping(*args, **kwargs):
|
||||
try:
|
||||
return behavior(*args, **kwargs)
|
||||
except Exception:
|
||||
_LOGGER.exception(
|
||||
'Unexpected exception from %s executed in logging pool!',
|
||||
behavior)
|
||||
raise
|
||||
|
||||
return _wrapping
|
||||
|
||||
|
||||
class _LoggingPool(object):
|
||||
"""An exception-logging futures.ThreadPoolExecutor-compatible thread pool."""
|
||||
|
||||
def __init__(self, backing_pool):
|
||||
self._backing_pool = backing_pool
|
||||
|
||||
def __enter__(self):
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||
self._backing_pool.shutdown(wait=True)
|
||||
|
||||
def submit(self, fn, *args, **kwargs):
|
||||
return self._backing_pool.submit(_wrap(fn), *args, **kwargs)
|
||||
|
||||
def map(self, func, *iterables, **kwargs):
|
||||
return self._backing_pool.map(_wrap(func),
|
||||
*iterables,
|
||||
timeout=kwargs.get('timeout', None))
|
||||
|
||||
def shutdown(self, wait=True):
|
||||
self._backing_pool.shutdown(wait=wait)
|
||||
|
||||
|
||||
def pool(max_workers):
|
||||
"""Creates a thread pool that logs exceptions raised by the tasks within it.
|
||||
|
||||
Args:
|
||||
max_workers: The maximum number of worker threads to allow the pool.
|
||||
|
||||
Returns:
|
||||
A futures.ThreadPoolExecutor-compatible thread pool that logs exceptions
|
||||
raised by the tasks executed within it.
|
||||
"""
|
||||
return _LoggingPool(futures.ThreadPoolExecutor(max_workers))
|
45
venv/Lib/site-packages/grpc/framework/foundation/stream.py
Normal file
45
venv/Lib/site-packages/grpc/framework/foundation/stream.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Interfaces related to streams of values or objects."""
|
||||
|
||||
import abc
|
||||
|
||||
import six
|
||||
|
||||
|
||||
class Consumer(six.with_metaclass(abc.ABCMeta)):
|
||||
"""Interface for consumers of finite streams of values or objects."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def consume(self, value):
|
||||
"""Accepts a value.
|
||||
|
||||
Args:
|
||||
value: Any value accepted by this Consumer.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def terminate(self):
|
||||
"""Indicates to this Consumer that no more values will be supplied."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def consume_and_terminate(self, value):
|
||||
"""Supplies a value and signals that no more values will be supplied.
|
||||
|
||||
Args:
|
||||
value: Any value accepted by this Consumer.
|
||||
"""
|
||||
raise NotImplementedError()
|
148
venv/Lib/site-packages/grpc/framework/foundation/stream_util.py
Normal file
148
venv/Lib/site-packages/grpc/framework/foundation/stream_util.py
Normal file
|
@ -0,0 +1,148 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Helpful utilities related to the stream module."""
|
||||
|
||||
import logging
|
||||
import threading
|
||||
|
||||
from grpc.framework.foundation import stream
|
||||
|
||||
_NO_VALUE = object()
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TransformingConsumer(stream.Consumer):
|
||||
"""A stream.Consumer that passes a transformation of its input to another."""
|
||||
|
||||
def __init__(self, transformation, downstream):
|
||||
self._transformation = transformation
|
||||
self._downstream = downstream
|
||||
|
||||
def consume(self, value):
|
||||
self._downstream.consume(self._transformation(value))
|
||||
|
||||
def terminate(self):
|
||||
self._downstream.terminate()
|
||||
|
||||
def consume_and_terminate(self, value):
|
||||
self._downstream.consume_and_terminate(self._transformation(value))
|
||||
|
||||
|
||||
class IterableConsumer(stream.Consumer):
|
||||
"""A Consumer that when iterated over emits the values it has consumed."""
|
||||
|
||||
def __init__(self):
|
||||
self._condition = threading.Condition()
|
||||
self._values = []
|
||||
self._active = True
|
||||
|
||||
def consume(self, value):
|
||||
with self._condition:
|
||||
if self._active:
|
||||
self._values.append(value)
|
||||
self._condition.notify()
|
||||
|
||||
def terminate(self):
|
||||
with self._condition:
|
||||
self._active = False
|
||||
self._condition.notify()
|
||||
|
||||
def consume_and_terminate(self, value):
|
||||
with self._condition:
|
||||
if self._active:
|
||||
self._values.append(value)
|
||||
self._active = False
|
||||
self._condition.notify()
|
||||
|
||||
def __iter__(self):
|
||||
return self
|
||||
|
||||
def __next__(self):
|
||||
return self.next()
|
||||
|
||||
def next(self):
|
||||
with self._condition:
|
||||
while self._active and not self._values:
|
||||
self._condition.wait()
|
||||
if self._values:
|
||||
return self._values.pop(0)
|
||||
else:
|
||||
raise StopIteration()
|
||||
|
||||
|
||||
class ThreadSwitchingConsumer(stream.Consumer):
|
||||
"""A Consumer decorator that affords serialization and asynchrony."""
|
||||
|
||||
def __init__(self, sink, pool):
|
||||
self._lock = threading.Lock()
|
||||
self._sink = sink
|
||||
self._pool = pool
|
||||
# True if self._spin has been submitted to the pool to be called once and
|
||||
# that call has not yet returned, False otherwise.
|
||||
self._spinning = False
|
||||
self._values = []
|
||||
self._active = True
|
||||
|
||||
def _spin(self, sink, value, terminate):
|
||||
while True:
|
||||
try:
|
||||
if value is _NO_VALUE:
|
||||
sink.terminate()
|
||||
elif terminate:
|
||||
sink.consume_and_terminate(value)
|
||||
else:
|
||||
sink.consume(value)
|
||||
except Exception as e: # pylint:disable=broad-except
|
||||
_LOGGER.exception(e)
|
||||
|
||||
with self._lock:
|
||||
if terminate:
|
||||
self._spinning = False
|
||||
return
|
||||
elif self._values:
|
||||
value = self._values.pop(0)
|
||||
terminate = not self._values and not self._active
|
||||
elif not self._active:
|
||||
value = _NO_VALUE
|
||||
terminate = True
|
||||
else:
|
||||
self._spinning = False
|
||||
return
|
||||
|
||||
def consume(self, value):
|
||||
with self._lock:
|
||||
if self._active:
|
||||
if self._spinning:
|
||||
self._values.append(value)
|
||||
else:
|
||||
self._pool.submit(self._spin, self._sink, value, False)
|
||||
self._spinning = True
|
||||
|
||||
def terminate(self):
|
||||
with self._lock:
|
||||
if self._active:
|
||||
self._active = False
|
||||
if not self._spinning:
|
||||
self._pool.submit(self._spin, self._sink, _NO_VALUE, True)
|
||||
self._spinning = True
|
||||
|
||||
def consume_and_terminate(self, value):
|
||||
with self._lock:
|
||||
if self._active:
|
||||
self._active = False
|
||||
if self._spinning:
|
||||
self._values.append(value)
|
||||
else:
|
||||
self._pool.submit(self._spin, self._sink, value, True)
|
||||
self._spinning = True
|
13
venv/Lib/site-packages/grpc/framework/interfaces/__init__.py
Normal file
13
venv/Lib/site-packages/grpc/framework/interfaces/__init__.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
330
venv/Lib/site-packages/grpc/framework/interfaces/base/base.py
Normal file
330
venv/Lib/site-packages/grpc/framework/interfaces/base/base.py
Normal file
|
@ -0,0 +1,330 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""The base interface of RPC Framework.
|
||||
|
||||
Implementations of this interface support the conduct of "operations":
|
||||
exchanges between two distinct ends of an arbitrary number of data payloads
|
||||
and metadata such as a name for the operation, initial and terminal metadata
|
||||
in each direction, and flow control. These operations may be used for transfers
|
||||
of data, remote procedure calls, status indication, or anything else
|
||||
applications choose.
|
||||
"""
|
||||
|
||||
# threading is referenced from specification in this module.
|
||||
import abc
|
||||
import enum
|
||||
import threading # pylint: disable=unused-import
|
||||
|
||||
import six
|
||||
|
||||
# abandonment is referenced from specification in this module.
|
||||
from grpc.framework.foundation import abandonment # pylint: disable=unused-import
|
||||
|
||||
# pylint: disable=too-many-arguments
|
||||
|
||||
|
||||
class NoSuchMethodError(Exception):
|
||||
"""Indicates that an unrecognized operation has been called.
|
||||
|
||||
Attributes:
|
||||
code: A code value to communicate to the other side of the operation
|
||||
along with indication of operation termination. May be None.
|
||||
details: A details value to communicate to the other side of the
|
||||
operation along with indication of operation termination. May be None.
|
||||
"""
|
||||
|
||||
def __init__(self, code, details):
|
||||
"""Constructor.
|
||||
|
||||
Args:
|
||||
code: A code value to communicate to the other side of the operation
|
||||
along with indication of operation termination. May be None.
|
||||
details: A details value to communicate to the other side of the
|
||||
operation along with indication of operation termination. May be None.
|
||||
"""
|
||||
super(NoSuchMethodError, self).__init__()
|
||||
self.code = code
|
||||
self.details = details
|
||||
|
||||
|
||||
class Outcome(object):
|
||||
"""The outcome of an operation.
|
||||
|
||||
Attributes:
|
||||
kind: A Kind value coarsely identifying how the operation terminated.
|
||||
code: An application-specific code value or None if no such value was
|
||||
provided.
|
||||
details: An application-specific details value or None if no such value was
|
||||
provided.
|
||||
"""
|
||||
|
||||
@enum.unique
|
||||
class Kind(enum.Enum):
|
||||
"""Ways in which an operation can terminate."""
|
||||
|
||||
COMPLETED = 'completed'
|
||||
CANCELLED = 'cancelled'
|
||||
EXPIRED = 'expired'
|
||||
LOCAL_SHUTDOWN = 'local shutdown'
|
||||
REMOTE_SHUTDOWN = 'remote shutdown'
|
||||
RECEPTION_FAILURE = 'reception failure'
|
||||
TRANSMISSION_FAILURE = 'transmission failure'
|
||||
LOCAL_FAILURE = 'local failure'
|
||||
REMOTE_FAILURE = 'remote failure'
|
||||
|
||||
|
||||
class Completion(six.with_metaclass(abc.ABCMeta)):
|
||||
"""An aggregate of the values exchanged upon operation completion.
|
||||
|
||||
Attributes:
|
||||
terminal_metadata: A terminal metadata value for the operaton.
|
||||
code: A code value for the operation.
|
||||
message: A message value for the operation.
|
||||
"""
|
||||
|
||||
|
||||
class OperationContext(six.with_metaclass(abc.ABCMeta)):
|
||||
"""Provides operation-related information and action."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def outcome(self):
|
||||
"""Indicates the operation's outcome (or that the operation is ongoing).
|
||||
|
||||
Returns:
|
||||
None if the operation is still active or the Outcome value for the
|
||||
operation if it has terminated.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def add_termination_callback(self, callback):
|
||||
"""Adds a function to be called upon operation termination.
|
||||
|
||||
Args:
|
||||
callback: A callable to be passed an Outcome value on operation
|
||||
termination.
|
||||
|
||||
Returns:
|
||||
None if the operation has not yet terminated and the passed callback will
|
||||
later be called when it does terminate, or if the operation has already
|
||||
terminated an Outcome value describing the operation termination and the
|
||||
passed callback will not be called as a result of this method call.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def time_remaining(self):
|
||||
"""Describes the length of allowed time remaining for the operation.
|
||||
|
||||
Returns:
|
||||
A nonnegative float indicating the length of allowed time in seconds
|
||||
remaining for the operation to complete before it is considered to have
|
||||
timed out. Zero is returned if the operation has terminated.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def cancel(self):
|
||||
"""Cancels the operation if the operation has not yet terminated."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def fail(self, exception):
|
||||
"""Indicates that the operation has failed.
|
||||
|
||||
Args:
|
||||
exception: An exception germane to the operation failure. May be None.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class Operator(six.with_metaclass(abc.ABCMeta)):
|
||||
"""An interface through which to participate in an operation."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def advance(self,
|
||||
initial_metadata=None,
|
||||
payload=None,
|
||||
completion=None,
|
||||
allowance=None):
|
||||
"""Progresses the operation.
|
||||
|
||||
Args:
|
||||
initial_metadata: An initial metadata value. Only one may ever be
|
||||
communicated in each direction for an operation, and they must be
|
||||
communicated no later than either the first payload or the completion.
|
||||
payload: A payload value.
|
||||
completion: A Completion value. May only ever be non-None once in either
|
||||
direction, and no payloads may be passed after it has been communicated.
|
||||
allowance: A positive integer communicating the number of additional
|
||||
payloads allowed to be passed by the remote side of the operation.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class ProtocolReceiver(six.with_metaclass(abc.ABCMeta)):
|
||||
"""A means of receiving protocol values during an operation."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def context(self, protocol_context):
|
||||
"""Accepts the protocol context object for the operation.
|
||||
|
||||
Args:
|
||||
protocol_context: The protocol context object for the operation.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class Subscription(six.with_metaclass(abc.ABCMeta)):
|
||||
"""Describes customer code's interest in values from the other side.
|
||||
|
||||
Attributes:
|
||||
kind: A Kind value describing the overall kind of this value.
|
||||
termination_callback: A callable to be passed the Outcome associated with
|
||||
the operation after it has terminated. Must be non-None if kind is
|
||||
Kind.TERMINATION_ONLY. Must be None otherwise.
|
||||
allowance: A callable behavior that accepts positive integers representing
|
||||
the number of additional payloads allowed to be passed to the other side
|
||||
of the operation. Must be None if kind is Kind.FULL. Must not be None
|
||||
otherwise.
|
||||
operator: An Operator to be passed values from the other side of the
|
||||
operation. Must be non-None if kind is Kind.FULL. Must be None otherwise.
|
||||
protocol_receiver: A ProtocolReceiver to be passed protocol objects as they
|
||||
become available during the operation. Must be non-None if kind is
|
||||
Kind.FULL.
|
||||
"""
|
||||
|
||||
@enum.unique
|
||||
class Kind(enum.Enum):
|
||||
|
||||
NONE = 'none'
|
||||
TERMINATION_ONLY = 'termination only'
|
||||
FULL = 'full'
|
||||
|
||||
|
||||
class Servicer(six.with_metaclass(abc.ABCMeta)):
|
||||
"""Interface for service implementations."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def service(self, group, method, context, output_operator):
|
||||
"""Services an operation.
|
||||
|
||||
Args:
|
||||
group: The group identifier of the operation to be serviced.
|
||||
method: The method identifier of the operation to be serviced.
|
||||
context: An OperationContext object affording contextual information and
|
||||
actions.
|
||||
output_operator: An Operator that will accept output values of the
|
||||
operation.
|
||||
|
||||
Returns:
|
||||
A Subscription via which this object may or may not accept more values of
|
||||
the operation.
|
||||
|
||||
Raises:
|
||||
NoSuchMethodError: If this Servicer does not handle operations with the
|
||||
given group and method.
|
||||
abandonment.Abandoned: If the operation has been aborted and there no
|
||||
longer is any reason to service the operation.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class End(six.with_metaclass(abc.ABCMeta)):
|
||||
"""Common type for entry-point objects on both sides of an operation."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def start(self):
|
||||
"""Starts this object's service of operations."""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def stop(self, grace):
|
||||
"""Stops this object's service of operations.
|
||||
|
||||
This object will refuse service of new operations as soon as this method is
|
||||
called but operations under way at the time of the call may be given a
|
||||
grace period during which they are allowed to finish.
|
||||
|
||||
Args:
|
||||
grace: A duration of time in seconds to allow ongoing operations to
|
||||
terminate before being forcefully terminated by the stopping of this
|
||||
End. May be zero to terminate all ongoing operations and immediately
|
||||
stop.
|
||||
|
||||
Returns:
|
||||
A threading.Event that will be set to indicate all operations having
|
||||
terminated and this End having completely stopped. The returned event
|
||||
may not be set until after the full grace period (if some ongoing
|
||||
operation continues for the full length of the period) or it may be set
|
||||
much sooner (if for example this End had no operations in progress at
|
||||
the time its stop method was called).
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def operate(self,
|
||||
group,
|
||||
method,
|
||||
subscription,
|
||||
timeout,
|
||||
initial_metadata=None,
|
||||
payload=None,
|
||||
completion=None,
|
||||
protocol_options=None):
|
||||
"""Commences an operation.
|
||||
|
||||
Args:
|
||||
group: The group identifier of the invoked operation.
|
||||
method: The method identifier of the invoked operation.
|
||||
subscription: A Subscription to which the results of the operation will be
|
||||
passed.
|
||||
timeout: A length of time in seconds to allow for the operation.
|
||||
initial_metadata: An initial metadata value to be sent to the other side
|
||||
of the operation. May be None if the initial metadata will be later
|
||||
passed via the returned operator or if there will be no initial metadata
|
||||
passed at all.
|
||||
payload: An initial payload for the operation.
|
||||
completion: A Completion value indicating the end of transmission to the
|
||||
other side of the operation.
|
||||
protocol_options: A value specified by the provider of a Base interface
|
||||
implementation affording custom state and behavior.
|
||||
|
||||
Returns:
|
||||
A pair of objects affording information about the operation and action
|
||||
continuing the operation. The first element of the returned pair is an
|
||||
OperationContext for the operation and the second element of the
|
||||
returned pair is an Operator to which operation values not passed in
|
||||
this call should later be passed.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def operation_stats(self):
|
||||
"""Reports the number of terminated operations broken down by outcome.
|
||||
|
||||
Returns:
|
||||
A dictionary from Outcome.Kind value to an integer identifying the number
|
||||
of operations that terminated with that outcome kind.
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
@abc.abstractmethod
|
||||
def add_idle_action(self, action):
|
||||
"""Adds an action to be called when this End has no ongoing operations.
|
||||
|
||||
Args:
|
||||
action: A callable that accepts no arguments.
|
||||
"""
|
||||
raise NotImplementedError()
|
|
@ -0,0 +1,71 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Utilities for use with the base interface of RPC Framework."""
|
||||
|
||||
import collections
|
||||
|
||||
from grpc.framework.interfaces.base import base
|
||||
|
||||
|
||||
class _Completion(base.Completion,
|
||||
collections.namedtuple('_Completion', (
|
||||
'terminal_metadata',
|
||||
'code',
|
||||
'message',
|
||||
))):
|
||||
"""A trivial implementation of base.Completion."""
|
||||
|
||||
|
||||
class _Subscription(base.Subscription,
|
||||
collections.namedtuple('_Subscription', (
|
||||
'kind',
|
||||
'termination_callback',
|
||||
'allowance',
|
||||
'operator',
|
||||
'protocol_receiver',
|
||||
))):
|
||||
"""A trivial implementation of base.Subscription."""
|
||||
|
||||
|
||||
_NONE_SUBSCRIPTION = _Subscription(base.Subscription.Kind.NONE, None, None,
|
||||
None, None)
|
||||
|
||||
|
||||
def completion(terminal_metadata, code, message):
|
||||
"""Creates a base.Completion aggregating the given operation values.
|
||||
|
||||
Args:
|
||||
terminal_metadata: A terminal metadata value for an operaton.
|
||||
code: A code value for an operation.
|
||||
message: A message value for an operation.
|
||||
|
||||
Returns:
|
||||
A base.Completion aggregating the given operation values.
|
||||
"""
|
||||
return _Completion(terminal_metadata, code, message)
|
||||
|
||||
|
||||
def full_subscription(operator, protocol_receiver):
|
||||
"""Creates a "full" base.Subscription for the given base.Operator.
|
||||
|
||||
Args:
|
||||
operator: A base.Operator to be used in an operation.
|
||||
protocol_receiver: A base.ProtocolReceiver to be used in an operation.
|
||||
|
||||
Returns:
|
||||
A base.Subscription of kind base.Subscription.Kind.FULL wrapping the given
|
||||
base.Operator and base.ProtocolReceiver.
|
||||
"""
|
||||
return _Subscription(base.Subscription.Kind.FULL, None, None, operator,
|
||||
protocol_receiver)
|
|
@ -0,0 +1,13 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
1052
venv/Lib/site-packages/grpc/framework/interfaces/face/face.py
Normal file
1052
venv/Lib/site-packages/grpc/framework/interfaces/face/face.py
Normal file
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,168 @@
|
|||
# Copyright 2015 gRPC authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
"""Utilities for RPC Framework's Face interface."""
|
||||
|
||||
import collections
|
||||
|
||||
# stream is referenced from specification in this module.
|
||||
from grpc.framework.common import cardinality
|
||||
from grpc.framework.common import style
|
||||
from grpc.framework.foundation import stream # pylint: disable=unused-import
|
||||
from grpc.framework.interfaces.face import face
|
||||
|
||||
|
||||
class _MethodImplementation(face.MethodImplementation,
|
||||
collections.namedtuple('_MethodImplementation', [
|
||||
'cardinality',
|
||||
'style',
|
||||
'unary_unary_inline',
|
||||
'unary_stream_inline',
|
||||
'stream_unary_inline',
|
||||
'stream_stream_inline',
|
||||
'unary_unary_event',
|
||||
'unary_stream_event',
|
||||
'stream_unary_event',
|
||||
'stream_stream_event',
|
||||
])):
|
||||
pass
|
||||
|
||||
|
||||
def unary_unary_inline(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a unary-unary RPC method as a callable value
|
||||
that takes a request value and an face.ServicerContext object and
|
||||
returns a response value.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.UNARY_UNARY,
|
||||
style.Service.INLINE, behavior, None, None,
|
||||
None, None, None, None, None)
|
||||
|
||||
|
||||
def unary_stream_inline(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a unary-stream RPC method as a callable
|
||||
value that takes a request value and an face.ServicerContext object and
|
||||
returns an iterator of response values.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.UNARY_STREAM,
|
||||
style.Service.INLINE, None, behavior, None,
|
||||
None, None, None, None, None)
|
||||
|
||||
|
||||
def stream_unary_inline(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a stream-unary RPC method as a callable
|
||||
value that takes an iterator of request values and an
|
||||
face.ServicerContext object and returns a response value.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.STREAM_UNARY,
|
||||
style.Service.INLINE, None, None, behavior,
|
||||
None, None, None, None, None)
|
||||
|
||||
|
||||
def stream_stream_inline(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a stream-stream RPC method as a callable
|
||||
value that takes an iterator of request values and an
|
||||
face.ServicerContext object and returns an iterator of response values.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.STREAM_STREAM,
|
||||
style.Service.INLINE, None, None, None,
|
||||
behavior, None, None, None, None)
|
||||
|
||||
|
||||
def unary_unary_event(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a unary-unary RPC method as a callable
|
||||
value that takes a request value, a response callback to which to pass
|
||||
the response value of the RPC, and an face.ServicerContext.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.UNARY_UNARY,
|
||||
style.Service.EVENT, None, None, None, None,
|
||||
behavior, None, None, None)
|
||||
|
||||
|
||||
def unary_stream_event(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a unary-stream RPC method as a callable
|
||||
value that takes a request value, a stream.Consumer to which to pass the
|
||||
the response values of the RPC, and an face.ServicerContext.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.UNARY_STREAM,
|
||||
style.Service.EVENT, None, None, None, None,
|
||||
None, behavior, None, None)
|
||||
|
||||
|
||||
def stream_unary_event(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a stream-unary RPC method as a callable
|
||||
value that takes a response callback to which to pass the response value
|
||||
of the RPC and an face.ServicerContext and returns a stream.Consumer to
|
||||
which the request values of the RPC should be passed.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.STREAM_UNARY,
|
||||
style.Service.EVENT, None, None, None, None,
|
||||
None, None, behavior, None)
|
||||
|
||||
|
||||
def stream_stream_event(behavior):
|
||||
"""Creates an face.MethodImplementation for the given behavior.
|
||||
|
||||
Args:
|
||||
behavior: The implementation of a stream-stream RPC method as a callable
|
||||
value that takes a stream.Consumer to which to pass the response values
|
||||
of the RPC and an face.ServicerContext and returns a stream.Consumer to
|
||||
which the request values of the RPC should be passed.
|
||||
|
||||
Returns:
|
||||
An face.MethodImplementation derived from the given behavior.
|
||||
"""
|
||||
return _MethodImplementation(cardinality.Cardinality.STREAM_STREAM,
|
||||
style.Service.EVENT, None, None, None, None,
|
||||
None, None, None, behavior)
|
Loading…
Add table
Add a link
Reference in a new issue