framework/interfaces/base/utilities.py
Go to the documentation of this file.
1 # Copyright 2015 gRPC authors.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 """Utilities for use with the base interface of RPC Framework."""
15 
16 import collections
17 
18 from grpc.framework.interfaces.base import base
19 
20 
22  collections.namedtuple('_Completion', (
23  'terminal_metadata',
24  'code',
25  'message',
26  ))):
27  """A trivial implementation of base.Completion."""
28 
29 
31  collections.namedtuple('_Subscription', (
32  'kind',
33  'termination_callback',
34  'allowance',
35  'operator',
36  'protocol_receiver',
37  ))):
38  """A trivial implementation of base.Subscription."""
39 
40 
41 _NONE_SUBSCRIPTION = _Subscription(base.Subscription.Kind.NONE, None, None,
42  None, None)
43 
44 
45 def completion(terminal_metadata, code, message):
46  """Creates a base.Completion aggregating the given operation values.
47 
48  Args:
49  terminal_metadata: A terminal metadata value for an operaton.
50  code: A code value for an operation.
51  message: A message value for an operation.
52 
53  Returns:
54  A base.Completion aggregating the given operation values.
55  """
56  return _Completion(terminal_metadata, code, message)
57 
58 
59 def full_subscription(operator, protocol_receiver):
60  """Creates a "full" base.Subscription for the given base.Operator.
61 
62  Args:
63  operator: A base.Operator to be used in an operation.
64  protocol_receiver: A base.ProtocolReceiver to be used in an operation.
65 
66  Returns:
67  A base.Subscription of kind base.Subscription.Kind.FULL wrapping the given
68  base.Operator and base.ProtocolReceiver.
69  """
70  return _Subscription(base.Subscription.Kind.FULL, None, None, operator,
71  protocol_receiver)
grpc.framework.interfaces.base
Definition: src/python/grpcio/grpc/framework/interfaces/base/__init__.py:1
grpc.framework.interfaces.base.utilities.completion
def completion(terminal_metadata, code, message)
Definition: framework/interfaces/base/utilities.py:45
grpc.framework.interfaces.base.base.Subscription
Definition: base.py:186
grpc.framework.interfaces.base.utilities._Completion
Definition: framework/interfaces/base/utilities.py:26
grpc.framework.interfaces.base.utilities.full_subscription
def full_subscription(operator, protocol_receiver)
Definition: framework/interfaces/base/utilities.py:59
grpc.framework.interfaces.base.utilities._Subscription
Definition: framework/interfaces/base/utilities.py:37
grpc.framework.interfaces.base.base.Completion
Definition: base.py:84


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:49