prpc.protocol.constants

class prpc.protocol.constants.MessageType

Capstone enumeration of all protocol message types.

Each message has it’s own payload format, as defined in prpc.protocol.messages module.

REQUEST_HANDSHAKE = 1
REQUEST_CALL_START = 2
REQUEST_CALL_CANCEL = 3
REQUEST_STREAM_MESSAGE = 4
REQUEST_STREAM_CLOSE = 5
RESPONSE_HANDSHAKE = 6
RESPONSE_RESULT = 7
RESPONSE_STREAM_MESSAGE = 8
RESPONSE_STREAM_CLOSE = 9
class prpc.protocol.constants.CallType

Enumerates all possible call types.

Note

Stream direction is considered from caller’s perspective.

Note

HANDSHAKE call type also uses a dedicated message type.

HANDSHAKE = 10
UNARY = 20
ISTREAM = 30
OSTREAM = 40
BISTREAM = 50
class prpc.protocol.constants.CallState

Enumerates call FSM states.

In absence of fatal errors, transition table looks as follows:
  • NEW -> SENDING, ACCEPTING
  • SENDING -> FINISHED, CANCELED
  • ACCEPTING -> ACCEPTED
  • ACCEPTED -> FINISHED, CANCELED
  • CANCELED -> <terminal>
  • FINISHED -> <terminal>

If an error occurs, any state may (and should) transition to FINISHED.

NEW = 0
SENDING = 10
ACCEPTING = 20
ACCEPTED = 30
CANCELLED = 40
FINISHED = 50
class prpc.protocol.constants.ResponseStatus

Enumerates remote call statuses.

Statuses other than success are mapped to exception on the calling side.

SUCCESS = 0
METHOD_ERROR = 10
METHOD_NOT_FOUND = 20
SERVER_ERROR = 30
class prpc.protocol.constants.ConnectionMode

Enumerates possible connection modes.

Protocol is mostly symmetric, but handshakes are not. Also, who is who may be important for reconnect implementation, if we get to it (reconnect should be initiated by client).

NEW = 0
CLIENT = 10
SERVER = 20
class prpc.protocol.constants.ConnectionState

Enumerates connection FSM states.

Note

Disconnected logic is not implemented yet.

Transition table looks as follows:
  • NEW -> PENDING
  • PENDING -> CONNECTED
  • CONNECTED -> DISCONNECTED, CLOSING
  • DISCONNECTED -> CONNECTED, CLOSING
  • CLOSING -> CLOSED
  • CLOSED -> <terminal>
NEW = 0
PENDING = 10
CONNECTED = 20
DISCONNECTED = 30
CLOSING = 40
CLOSED = 50
class prpc.protocol.constants.StreamState

Stream FSM states.

Transition table:
  • NEW -> OPEN, CLOSED
  • OPEN -> CLOSING
  • CLOSING -> CLOSED
  • CLOSED -> <terminal>
NEW = 0
OPEN = 10
CLOSING = 20
CLOSED = 30
class prpc.protocol.constants.StreamMode

Stream open mode flags enumeration.

READ = 1
WRITE = 2