OLD | NEW |
(Empty) | |
| 1 # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! |
| 2 import grpc |
| 3 from grpc.framework.common import cardinality |
| 4 from grpc.framework.interfaces.face import utilities as face_utilities |
| 5 |
| 6 import bytestream_pb2 as bytestream__pb2 |
| 7 |
| 8 |
| 9 class ByteStreamStub(object): |
| 10 """#### Introduction |
| 11 |
| 12 The Byte Stream API enables a client to read and write a stream of bytes to |
| 13 and from a resource. Resources have names, and these names are supplied in |
| 14 the API calls below to identify the resource that is being read from or |
| 15 written to. |
| 16 |
| 17 All implementations of the Byte Stream API export the interface defined here: |
| 18 |
| 19 * `Read()`: Reads the contents of a resource. |
| 20 |
| 21 * `Write()`: Writes the contents of a resource. The client can call `Write()` |
| 22 multiple times with the same resource and can check the status of the write |
| 23 by calling `QueryWriteStatus()`. |
| 24 |
| 25 #### Service parameters and metadata |
| 26 |
| 27 The ByteStream API provides no direct way to access/modify any metadata |
| 28 associated with the resource. |
| 29 |
| 30 #### Errors |
| 31 |
| 32 The errors returned by the service are in the Google canonical error space. |
| 33 """ |
| 34 |
| 35 def __init__(self, channel): |
| 36 """Constructor. |
| 37 |
| 38 Args: |
| 39 channel: A grpc.Channel. |
| 40 """ |
| 41 self.Read = channel.unary_stream( |
| 42 '/google.bytestream.ByteStream/Read', |
| 43 request_serializer=bytestream__pb2.ReadRequest.SerializeToString, |
| 44 response_deserializer=bytestream__pb2.ReadResponse.FromString, |
| 45 ) |
| 46 self.Write = channel.stream_unary( |
| 47 '/google.bytestream.ByteStream/Write', |
| 48 request_serializer=bytestream__pb2.WriteRequest.SerializeToString, |
| 49 response_deserializer=bytestream__pb2.WriteResponse.FromString, |
| 50 ) |
| 51 self.QueryWriteStatus = channel.unary_unary( |
| 52 '/google.bytestream.ByteStream/QueryWriteStatus', |
| 53 request_serializer=bytestream__pb2.QueryWriteStatusRequest.SerializeToSt
ring, |
| 54 response_deserializer=bytestream__pb2.QueryWriteStatusResponse.FromStrin
g, |
| 55 ) |
| 56 |
| 57 |
| 58 class ByteStreamServicer(object): |
| 59 """#### Introduction |
| 60 |
| 61 The Byte Stream API enables a client to read and write a stream of bytes to |
| 62 and from a resource. Resources have names, and these names are supplied in |
| 63 the API calls below to identify the resource that is being read from or |
| 64 written to. |
| 65 |
| 66 All implementations of the Byte Stream API export the interface defined here: |
| 67 |
| 68 * `Read()`: Reads the contents of a resource. |
| 69 |
| 70 * `Write()`: Writes the contents of a resource. The client can call `Write()` |
| 71 multiple times with the same resource and can check the status of the write |
| 72 by calling `QueryWriteStatus()`. |
| 73 |
| 74 #### Service parameters and metadata |
| 75 |
| 76 The ByteStream API provides no direct way to access/modify any metadata |
| 77 associated with the resource. |
| 78 |
| 79 #### Errors |
| 80 |
| 81 The errors returned by the service are in the Google canonical error space. |
| 82 """ |
| 83 |
| 84 def Read(self, request, context): |
| 85 """`Read()` is used to retrieve the contents of a resource as a sequence |
| 86 of bytes. The bytes are returned in a sequence of responses, and the |
| 87 responses are delivered as the results of a server-side streaming RPC. |
| 88 """ |
| 89 context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 90 context.set_details('Method not implemented!') |
| 91 raise NotImplementedError('Method not implemented!') |
| 92 |
| 93 def Write(self, request_iterator, context): |
| 94 """`Write()` is used to send the contents of a resource as a sequence of |
| 95 bytes. The bytes are sent in a sequence of request protos of a client-side |
| 96 streaming RPC. |
| 97 |
| 98 A `Write()` action is resumable. If there is an error or the connection is |
| 99 broken during the `Write()`, the client should check the status of the |
| 100 `Write()` by calling `QueryWriteStatus()` and continue writing from the |
| 101 returned `committed_size`. This may be less than the amount of data the |
| 102 client previously sent. |
| 103 |
| 104 Calling `Write()` on a resource name that was previously written and |
| 105 finalized could cause an error, depending on whether the underlying service |
| 106 allows over-writing of previously written resources. |
| 107 |
| 108 When the client closes the request channel, the service will respond with |
| 109 a `WriteResponse`. The service will not view the resource as `complete` |
| 110 until the client has sent a `WriteRequest` with `finish_write` set to |
| 111 `true`. Sending any requests on a stream after sending a request with |
| 112 `finish_write` set to `true` will cause an error. The client **should** |
| 113 check the `WriteResponse` it receives to determine how much data the |
| 114 service was able to commit and whether the service views the resource as |
| 115 `complete` or not. |
| 116 """ |
| 117 context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 118 context.set_details('Method not implemented!') |
| 119 raise NotImplementedError('Method not implemented!') |
| 120 |
| 121 def QueryWriteStatus(self, request, context): |
| 122 """`QueryWriteStatus()` is used to find the `committed_size` for a resource |
| 123 that is being written, which can then be used as the `write_offset` for |
| 124 the next `Write()` call. |
| 125 |
| 126 If the resource does not exist (i.e., the resource has been deleted, or the |
| 127 first `Write()` has not yet reached the service), this method returns the |
| 128 error `NOT_FOUND`. |
| 129 |
| 130 The client **may** call `QueryWriteStatus()` at any time to determine how |
| 131 much data has been processed for this resource. This is useful if the |
| 132 client is buffering data and needs to know which data can be safely |
| 133 evicted. For any sequence of `QueryWriteStatus()` calls for a given |
| 134 resource name, the sequence of returned `committed_size` values will be |
| 135 non-decreasing. |
| 136 """ |
| 137 context.set_code(grpc.StatusCode.UNIMPLEMENTED) |
| 138 context.set_details('Method not implemented!') |
| 139 raise NotImplementedError('Method not implemented!') |
| 140 |
| 141 |
| 142 def add_ByteStreamServicer_to_server(servicer, server): |
| 143 rpc_method_handlers = { |
| 144 'Read': grpc.unary_stream_rpc_method_handler( |
| 145 servicer.Read, |
| 146 request_deserializer=bytestream__pb2.ReadRequest.FromString, |
| 147 response_serializer=bytestream__pb2.ReadResponse.SerializeToString, |
| 148 ), |
| 149 'Write': grpc.stream_unary_rpc_method_handler( |
| 150 servicer.Write, |
| 151 request_deserializer=bytestream__pb2.WriteRequest.FromString, |
| 152 response_serializer=bytestream__pb2.WriteResponse.SerializeToString, |
| 153 ), |
| 154 'QueryWriteStatus': grpc.unary_unary_rpc_method_handler( |
| 155 servicer.QueryWriteStatus, |
| 156 request_deserializer=bytestream__pb2.QueryWriteStatusRequest.FromStrin
g, |
| 157 response_serializer=bytestream__pb2.QueryWriteStatusResponse.Serialize
ToString, |
| 158 ), |
| 159 } |
| 160 generic_handler = grpc.method_handlers_generic_handler( |
| 161 'google.bytestream.ByteStream', rpc_method_handlers) |
| 162 server.add_generic_rpc_handlers((generic_handler,)) |
OLD | NEW |