diff options
author | Masood Malekghassemi <soltanmm@users.noreply.github.com> | 2015-08-24 15:07:55 -0700 |
---|---|---|
committer | Masood Malekghassemi <soltanmm@users.noreply.github.com> | 2015-08-24 15:07:55 -0700 |
commit | 8c4549aec780e2cdeb72f028d9a44ad9fd853c33 (patch) | |
tree | 349b571192e7218af723ccfd1ff5d280ebd44078 /src/python/grpcio | |
parent | d7af736794fcdc3b8dd1ffda4a97f12b58e326c8 (diff) | |
parent | 2432c224d9e18f9db3e6852b3f7154e5691de32b (diff) |
Merge pull request #3039 from nathanielmanistaatgoogle/transport-objects
Add a "transport" field to links.Ticket
Diffstat (limited to 'src/python/grpcio')
-rw-r--r-- | src/python/grpcio/grpc/_links/invocation.py | 8 | ||||
-rw-r--r-- | src/python/grpcio/grpc/_links/service.py | 10 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/core/_transmission.py | 14 | ||||
-rw-r--r-- | src/python/grpcio/grpc/framework/interfaces/links/links.py | 24 |
4 files changed, 38 insertions, 18 deletions
diff --git a/src/python/grpcio/grpc/_links/invocation.py b/src/python/grpcio/grpc/_links/invocation.py index 0058ae91f8..a74c77ebcc 100644 --- a/src/python/grpcio/grpc/_links/invocation.py +++ b/src/python/grpcio/grpc/_links/invocation.py @@ -101,7 +101,7 @@ class _Kernel(object): else: ticket = links.Ticket( operation_id, rpc_state.sequence_number, None, None, None, None, 1, - None, None, None, None, None, None) + None, None, None, None, None, None, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) rpc_state.low_write = _LowWrite.OPEN @@ -118,7 +118,7 @@ class _Kernel(object): ticket = links.Ticket( operation_id, rpc_state.sequence_number, None, None, None, None, None, None, rpc_state.response_deserializer(event.bytes), None, None, None, - None) + None, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) @@ -129,7 +129,7 @@ class _Kernel(object): ticket = links.Ticket( operation_id, rpc_state.sequence_number, None, None, links.Ticket.Subscription.FULL, None, None, event.metadata, None, None, - None, None, None) + None, None, None, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) @@ -146,7 +146,7 @@ class _Kernel(object): ticket = links.Ticket( operation_id, rpc_state.sequence_number, None, None, None, None, None, None, None, event.metadata, event.status.code, event.status.details, - termination) + termination, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) diff --git a/src/python/grpcio/grpc/_links/service.py b/src/python/grpcio/grpc/_links/service.py index 5c636d61ab..de78e82cd6 100644 --- a/src/python/grpcio/grpc/_links/service.py +++ b/src/python/grpcio/grpc/_links/service.py @@ -131,7 +131,7 @@ class _Kernel(object): ticket = links.Ticket( call, 0, group, method, links.Ticket.Subscription.FULL, service_acceptance.deadline - time.time(), None, event.metadata, None, - None, None, None, None) + None, None, None, None, 'TODO: Service Context Object!') self._relay.add_value(ticket) def _on_read_event(self, event): @@ -157,7 +157,7 @@ class _Kernel(object): # rpc_state.read = _Read.AWAITING_ALLOWANCE ticket = links.Ticket( call, rpc_state.sequence_number, None, None, None, None, None, None, - payload, None, None, None, termination) + payload, None, None, None, termination, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) @@ -176,7 +176,7 @@ class _Kernel(object): else: ticket = links.Ticket( call, rpc_state.sequence_number, None, None, None, None, 1, None, - None, None, None, None, None) + None, None, None, None, None, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) rpc_state.low_write = _LowWrite.OPEN @@ -198,7 +198,7 @@ class _Kernel(object): termination = links.Ticket.Termination.TRANSMISSION_FAILURE ticket = links.Ticket( call, rpc_state.sequence_number, None, None, None, None, None, None, - None, None, None, None, termination) + None, None, None, None, termination, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) @@ -259,7 +259,7 @@ class _Kernel(object): termination = links.Ticket.Termination.COMPLETION ticket = links.Ticket( call, rpc_state.sequence_number, None, None, None, None, None, - None, payload, None, None, None, termination) + None, payload, None, None, None, termination, None) rpc_state.sequence_number += 1 self._relay.add_value(ticket) diff --git a/src/python/grpcio/grpc/framework/core/_transmission.py b/src/python/grpcio/grpc/framework/core/_transmission.py index 01894d398d..03644f4d49 100644 --- a/src/python/grpcio/grpc/framework/core/_transmission.py +++ b/src/python/grpcio/grpc/framework/core/_transmission.py @@ -107,7 +107,7 @@ class TransmissionManager(_interfaces.TransmissionManager): return links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, None, None, None, None, None, None, None, None, - termination) + termination, None) action = False # TODO(nathaniel): Support other subscriptions. @@ -144,7 +144,7 @@ class TransmissionManager(_interfaces.TransmissionManager): ticket = links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, local_subscription, timeout, allowance, initial_metadata, payload, - terminal_metadata, code, message, termination) + terminal_metadata, code, message, termination, None) self._lowest_unused_sequence_number += 1 return ticket else: @@ -191,7 +191,7 @@ class TransmissionManager(_interfaces.TransmissionManager): ticket = links.Ticket( self._operation_id, 0, group, method, subscription, timeout, allowance, initial_metadata, payload, terminal_metadata, code, message, - termination) + termination, None) self._lowest_unused_sequence_number = 1 self._transmit(ticket) @@ -236,7 +236,7 @@ class TransmissionManager(_interfaces.TransmissionManager): ticket = links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, None, None, allowance, effective_initial_metadata, ticket_payload, - terminal_metadata, code, message, termination) + terminal_metadata, code, message, termination, None) self._lowest_unused_sequence_number += 1 self._transmit(ticket) @@ -247,7 +247,7 @@ class TransmissionManager(_interfaces.TransmissionManager): else: ticket = links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, - None, timeout, None, None, None, None, None, None, None) + None, timeout, None, None, None, None, None, None, None, None) self._lowest_unused_sequence_number += 1 self._transmit(ticket) @@ -268,7 +268,7 @@ class TransmissionManager(_interfaces.TransmissionManager): ticket = links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, None, None, None, None, payload, terminal_metadata, code, message, - termination) + termination, None) self._lowest_unused_sequence_number += 1 self._transmit(ticket) @@ -290,5 +290,5 @@ class TransmissionManager(_interfaces.TransmissionManager): ticket = links.Ticket( self._operation_id, self._lowest_unused_sequence_number, None, None, None, None, None, None, None, None, None, None, - termination) + termination, None) self._transmit(ticket) diff --git a/src/python/grpcio/grpc/framework/interfaces/links/links.py b/src/python/grpcio/grpc/framework/interfaces/links/links.py index 069ff024dd..b98a30a399 100644 --- a/src/python/grpcio/grpc/framework/interfaces/links/links.py +++ b/src/python/grpcio/grpc/framework/interfaces/links/links.py @@ -34,12 +34,30 @@ import collections import enum +class Transport(collections.namedtuple('Transport', ('kind', 'value',))): + """A sum type for handles to an underlying transport system. + + Attributes: + kind: A Kind value identifying the kind of value being passed to or from + the underlying transport. + value: The value being passed through RPC Framework between the high-level + application and the underlying transport. + """ + + @enum.unique + class Kind(enum.Enum): + CALL_OPTION = 'call option' + SERVICER_CONTEXT = 'servicer context' + INVOCATION_CONTEXT = 'invocation context' + + class Ticket( collections.namedtuple( 'Ticket', - ['operation_id', 'sequence_number', 'group', 'method', 'subscription', + ('operation_id', 'sequence_number', 'group', 'method', 'subscription', 'timeout', 'allowance', 'initial_metadata', 'payload', - 'terminal_metadata', 'code', 'message', 'termination'])): + 'terminal_metadata', 'code', 'message', 'termination', + 'transport',))): """A sum type for all values sent from a front to a back. Attributes: @@ -81,6 +99,8 @@ class Ticket( termination: A Termination value describing the end of the operation, or None if the operation has not yet terminated. If set, no further tickets may be sent in the same direction. + transport: A Transport value or None, with further semantics being a matter + between high-level application and underlying transport. """ @enum.unique |