grpcio
  • grpc package
    • Subpackages
      • grpc.early_adopter package
        • Submodules
        • grpc.early_adopter.implementations module
        • grpc.early_adopter.implementations_test module
        • Module contents
      • grpc.framework package
        • Subpackages
        • Module contents
    • Module contents
 
grpcio
  • Docs »
  • grpc package »
  • grpc.framework package »
  • grpc.framework.interfaces package »
  • grpc.framework.interfaces.links package
  • View page source

grpc.framework.interfaces.links package¶

Submodules¶

grpc.framework.interfaces.links.links module¶

The low-level ticket-exchanging-links interface of RPC Framework.

class grpc.framework.interfaces.links.links.Link[source]¶

Bases: object

Accepts and emits tickets.

accept_ticket(ticket)[source]¶

Accept a Ticket.

Parameters:ticket – Any Ticket.
join_link(link)[source]¶

Mates this object with a peer with which it will exchange tickets.

class grpc.framework.interfaces.links.links.Ticket[source]¶

Bases: grpc.framework.interfaces.links.links.Ticket

A sum type for all values sent from a front to a back.

operation_id¶

A unique-with-respect-to-equality hashable object identifying a particular operation.

sequence_number¶

A zero-indexed integer sequence number identifying the ticket’s place in the stream of tickets sent in one direction for the particular operation.

group¶

The group to which the method of the operation belongs. Must be present in the first ticket from invocation side to service side. Ignored for all other tickets exchanged during the operation.

method¶

The name of an operation. Must be present in the first ticket from invocation side to service side. Ignored for all other tickets exchanged during the operation.

subscription¶

A Subscription value describing the interest one side has in receiving information from the other side. Must be present in the first ticket from either side. Ignored for all other tickets exchanged during the operation.

timeout¶

A nonzero length of time (measured from the beginning of the operation) to allow for the entire operation. Must be present in the first ticket from invocation side to service side. Optional for all other tickets exchanged during the operation. Receipt of a value from the other side of the operation indicates the value in use by that side. Setting a value on a later ticket allows either side to request time extensions (or even time reductions!) on in-progress operations.

allowance¶

A positive integer granting permission for a number of payloads to be transmitted to the communicating side of the operation, or None if no additional allowance is being granted with this ticket.

initial_metadata¶

An optional metadata value communicated from one side to the other at the beginning of the operation. May be non-None in at most one ticket from each side. Any non-None value must appear no later than the first payload value.

payload¶

A customer payload object. May be None.

terminal_metadata¶

A metadata value comminicated from one side to the other at the end of the operation. May be non-None in the same ticket as the code and message, but must be None for all earlier tickets.

code¶

A value communicated at operation completion. May be None.

message¶

A value communicated at operation completion. May be None.

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.

class Subscription[source]¶

Bases: enum.Enum

Identifies the level of subscription of a side of an operation.

class Ticket.Termination[source]¶

Bases: enum.Enum

Identifies the termination of an operation.

grpc.framework.interfaces.links.test_cases module¶

Tests of the links interface of RPC Framework.

class grpc.framework.interfaces.links.test_cases.TransmissionTest[source]¶

Bases: object

Tests ticket transmission between two connected links.

This class must be mixed into a unittest.TestCase that implements the abstract methods it provides.

assertMetadataTransmitted(original_metadata, transmitted_metadata)[source]¶

Asserts that transmitted_metadata contains original_metadata.

Parameters:
  • original_metadata – A metadata object used in this test.
  • transmitted_metadata – A metadata object obtained after transmission through the system under test.
Raises:

AssertionError – if the transmitted_metadata object does not contain original_metadata.

create_invocation_completion()[source]¶

Creates values for use as invocation-side code and message.

Returns:An invocation-side code value and an invocation-side message value. Either or both may be None if invocation-side code and/or invocation-side message transmission is not supported by the links under test.
create_invocation_initial_metadata()[source]¶

Creates a value for use as invocation-side initial metadata.

Returns:A metadata value appropriate for use as invocation-side initial metadata or None if invocation-side initial metadata transmission is not supported by the links under test.
create_invocation_terminal_metadata()[source]¶

Creates a value for use as invocation-side terminal metadata.

Returns:A metadata value appropriate for use as invocation-side terminal metadata or None if invocation-side terminal metadata transmission is not supported by the links under test.
create_service_completion()[source]¶

Creates values for use as service-side code and message.

Returns:A service-side code value and a service-side message value. Either or both may be None if service-side code and/or service-side message transmission is not supported by the links under test.
create_service_initial_metadata()[source]¶

Creates a value for use as service-side initial metadata.

Returns:A metadata value appropriate for use as service-side initial metadata or None if service-side initial metadata transmission is not supported by the links under test.
create_service_terminal_metadata()[source]¶

Creates a value for use as service-side terminal metadata.

Returns:A metadata value appropriate for use as service-side terminal metadata or None if service-side terminal metadata transmission is not supported by the links under test.
create_transmitting_links()[source]¶

Creates two connected links for use in this test.

Returns:Two links.Links, the first of which will be used on the invocation side of RPCs and the second of which will be used on the service side of RPCs.
deserialize_request(serialized_request)[source]¶

Deserializes a request value used in this test case.

Parameters:serialized_request – A bytestring that is the serialization of some request used in this test case.
Returns:The request value encoded by the given bytestring.
deserialize_response(serialized_response)[source]¶

Deserializes a response value used in this test case.

Parameters:serialized_response – A bytestring that is the serialization of some response used in this test case.
Returns:The response value encoded by the given bytestring.
destroy_transmitting_links(invocation_side_link, service_side_link)[source]¶

Destroys the two connected links created for this test.

Parameters:
  • invocation_side_link – The link used on the invocation side of RPCs in this test.
  • service_side_link – The link used on the service side of RPCs in this test.
group_and_method()[source]¶

Returns the group and method used in this test case.

Returns:A pair of the group and method used in this test case.
serialize_request(request)[source]¶

Serializes a request value used in this test case.

Parameters:request – A request value created by this test case.
Returns:A bytestring that is the serialization of the given request.
serialize_response(response)[source]¶

Serializes a response value used in this test case.

Parameters:response – A response value created by this test case.
Returns:A bytestring that is the serialization of the given response.
setUp()[source]¶
tearDown()[source]¶
testSimplestRoundTrip()[source]¶

Tests transmission of one ticket in each direction.

grpc.framework.interfaces.links.test_cases.at_least_n_payloads_received_predicate(n)[source]¶
grpc.framework.interfaces.links.test_cases.terminated(ticket_sequence)[source]¶

grpc.framework.interfaces.links.test_utilities module¶

State and behavior appropriate for use in tests.

class grpc.framework.interfaces.links.test_utilities.RecordingLink[source]¶

Bases: grpc.framework.interfaces.links.links.Link

A Link that records every ticket passed to it.

accept_ticket(ticket)[source]¶
block_until_tickets_satisfy(predicate)[source]¶

Blocks until the received tickets satisfy the given predicate.

Parameters:predicate – A callable that takes a sequence of tickets and returns a boolean value.
join_link(link)[source]¶
tickets()[source]¶

Returns a copy of the list of all tickets received by this Link.

grpc.framework.interfaces.links.utilities module¶

Utilities provided as part of the links interface.

Module contents¶

Previous

© Copyright 2015, Author.

Built with Sphinx using a theme provided by Read the Docs.