1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
import enum
import collections
@enum.unique
class Status(enum.Enum):
"""Predefined gRPC status codes represented as enum
See also: https://github.com/grpc/grpc/blob/master/doc/statuscodes.md
"""
#: The operation completed successfully
OK = 0
#: The operation was cancelled (typically by the caller)
CANCELLED = 1
#: Generic status to describe error when it can't be described using
#: other statuses
UNKNOWN = 2
#: Client specified an invalid argument
INVALID_ARGUMENT = 3
#: Deadline expired before operation could complete
DEADLINE_EXCEEDED = 4
#: Some requested entity was not found
NOT_FOUND = 5
#: Some entity that we attempted to create already exists
ALREADY_EXISTS = 6
#: The caller does not have permission to execute the specified operation
PERMISSION_DENIED = 7
#: Some resource has been exhausted, perhaps a per-user quota, or perhaps
#: the entire file system is out of space
RESOURCE_EXHAUSTED = 8
#: Operation was rejected because the system is not in a state required
#: for the operation's execution
FAILED_PRECONDITION = 9
#: The operation was aborted
ABORTED = 10
#: Operation was attempted past the valid range
OUT_OF_RANGE = 11
#: Operation is not implemented or not supported/enabled in this service
UNIMPLEMENTED = 12
#: Internal errors
INTERNAL = 13
#: The service is currently unavailable
UNAVAILABLE = 14
#: Unrecoverable data loss or corruption
DATA_LOSS = 15
#: The request does not have valid authentication credentials for the
#: operation
UNAUTHENTICATED = 16
_Cardinality = collections.namedtuple(
'_Cardinality', 'client_streaming, server_streaming',
)
@enum.unique
class Cardinality(_Cardinality, enum.Enum):
UNARY_UNARY = _Cardinality(False, False)
UNARY_STREAM = _Cardinality(False, True)
STREAM_UNARY = _Cardinality(True, False)
STREAM_STREAM = _Cardinality(True, True)
Handler = collections.namedtuple(
'Handler', 'func, cardinality, request_type, reply_type',
)
|