@@ -129,20 +129,26 @@ class Channel(abc.ABC):
129
129
130
130
# Server Object:
131
131
132
- class Server :
132
+ class Server (metaclass = abc .ABCMeta ):
133
+ @abc .abstractmethod
133
134
def add_generic_rpc_handlers (self , generic_rpc_handlers : Iterable [GenericRpcHandler [typing .Any , typing .Any ]]) -> None : ...
134
135
135
136
# Returns an integer port on which server will accept RPC requests.
137
+ @abc .abstractmethod
136
138
def add_insecure_port (self , address : str ) -> int : ...
137
139
138
140
# Returns an integer port on which server will accept RPC requests.
141
+ @abc .abstractmethod
139
142
def add_secure_port (self , address : str , server_credentials : ServerCredentials ) -> int : ...
143
+ @abc .abstractmethod
140
144
async def start (self ) -> None : ...
141
145
142
146
# Grace period is in seconds.
143
- async def stop (self , grace : float | None = ...) -> None : ...
147
+ @abc .abstractmethod
148
+ async def stop (self , grace : float | None ) -> None : ...
144
149
145
150
# Returns a bool indicates if the operation times out. Timeout is in seconds.
151
+ @abc .abstractmethod
146
152
async def wait_for_termination (self , timeout : float | None = ...) -> bool : ...
147
153
148
154
# Client-Side Context:
@@ -175,43 +181,67 @@ class Call(RpcContext, metaclass=abc.ABCMeta):
175
181
async def wait_for_connection (self ) -> None : ...
176
182
177
183
class UnaryUnaryCall (Call , typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
184
+ @abc .abstractmethod
178
185
def __await__ (self ) -> Generator [None , None , _TResponse ]: ...
179
186
180
187
class UnaryStreamCall (Call , typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
188
+ @abc .abstractmethod
181
189
def __aiter__ (self ) -> AsyncIterator [_TResponse ]: ...
190
+ @abc .abstractmethod
182
191
async def read (self ) -> EOFType | _TResponse : ...
183
192
184
193
class StreamUnaryCall (Call , typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
194
+ @abc .abstractmethod
185
195
async def write (self , request : _TRequest ) -> None : ...
196
+ @abc .abstractmethod
186
197
async def done_writing (self ) -> None : ...
198
+ @abc .abstractmethod
187
199
def __await__ (self ) -> Generator [None , None , _TResponse ]: ...
188
200
189
201
class StreamStreamCall (Call , typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
202
+ @abc .abstractmethod
190
203
def __aiter__ (self ) -> AsyncIterator [_TResponse ]: ...
204
+ @abc .abstractmethod
191
205
async def read (self ) -> EOFType | _TResponse : ...
206
+ @abc .abstractmethod
192
207
async def write (self , request : _TRequest ) -> None : ...
208
+ @abc .abstractmethod
193
209
async def done_writing (self ) -> None : ...
194
210
195
211
# Service-Side Context:
196
212
197
213
class DoneCallback (typing .Generic [_TRequest , _TResponse ]):
198
214
def __call__ (self , ctx : ServicerContext [_TRequest , _TResponse ]) -> None : ...
199
215
200
- class ServicerContext (typing .Generic [_TRequest , _TResponse ]):
216
+ class ServicerContext (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
217
+ @abc .abstractmethod
201
218
async def abort (self , code : StatusCode , details : str = ..., trailing_metadata : MetadataType = ...) -> typing .NoReturn : ...
219
+ @abc .abstractmethod
202
220
async def read (self ) -> _TRequest : ...
221
+ @abc .abstractmethod
203
222
async def write (self , message : _TResponse ) -> None : ...
223
+ @abc .abstractmethod
204
224
async def send_initial_metadata (self , initial_metadata : MetadataType ) -> None : ...
205
225
def add_done_callback (self , callback : DoneCallback [_TRequest , _TResponse ]) -> None : ...
226
+ @abc .abstractmethod
206
227
def set_trailing_metadata (self , trailing_metadata : MetadataType ) -> None : ...
228
+ @abc .abstractmethod
207
229
def invocation_metadata (self ) -> Metadata | None : ...
230
+ @abc .abstractmethod
208
231
def set_code (self , code : StatusCode ) -> None : ...
232
+ @abc .abstractmethod
209
233
def set_details (self , details : str ) -> None : ...
234
+ @abc .abstractmethod
210
235
def set_compression (self , compression : Compression ) -> None : ...
236
+ @abc .abstractmethod
211
237
def disable_next_message_compression (self ) -> None : ...
238
+ @abc .abstractmethod
212
239
def peer (self ) -> str : ...
240
+ @abc .abstractmethod
213
241
def peer_identities (self ) -> Iterable [bytes ] | None : ...
242
+ @abc .abstractmethod
214
243
def peer_identity_key (self ) -> str | None : ...
244
+ @abc .abstractmethod
215
245
def auth_context (self ) -> Mapping [str , Iterable [bytes ]]: ...
216
246
def time_remaining (self ) -> float : ...
217
247
def trailing_metadata (self ) -> Metadata : ...
@@ -290,7 +320,7 @@ class InterceptedUnaryUnaryCall(InterceptedCall[_TRequest, _TResponse]):
290
320
) -> UnaryUnaryCall [_TRequest , _TResponse ]: ...
291
321
def time_remaining (self ) -> float | None : ...
292
322
293
- class UnaryUnaryClientInterceptor (typing .Generic [_TRequest , _TResponse ]):
323
+ class UnaryUnaryClientInterceptor (typing .Generic [_TRequest , _TResponse ], metaclass = abc . ABCMeta ):
294
324
@abc .abstractmethod
295
325
async def intercept_unary_unary (
296
326
self ,
@@ -300,7 +330,7 @@ class UnaryUnaryClientInterceptor(typing.Generic[_TRequest, _TResponse]):
300
330
request : _TRequest ,
301
331
) -> _TResponse : ...
302
332
303
- class UnaryStreamClientInterceptor (typing .Generic [_TRequest , _TResponse ]):
333
+ class UnaryStreamClientInterceptor (typing .Generic [_TRequest , _TResponse ], metaclass = abc . ABCMeta ):
304
334
@abc .abstractmethod
305
335
async def intercept_unary_stream (
306
336
self ,
@@ -309,7 +339,7 @@ class UnaryStreamClientInterceptor(typing.Generic[_TRequest, _TResponse]):
309
339
request : _TRequest ,
310
340
) -> AsyncIterable [_TResponse ] | UnaryStreamCall [_TRequest , _TResponse ]: ...
311
341
312
- class StreamUnaryClientInterceptor (typing .Generic [_TRequest , _TResponse ]):
342
+ class StreamUnaryClientInterceptor (typing .Generic [_TRequest , _TResponse ], metaclass = abc . ABCMeta ):
313
343
@abc .abstractmethod
314
344
async def intercept_stream_unary (
315
345
self ,
@@ -318,7 +348,7 @@ class StreamUnaryClientInterceptor(typing.Generic[_TRequest, _TResponse]):
318
348
request_iterator : AsyncIterable [_TRequest ] | Iterable [_TRequest ],
319
349
) -> AsyncIterable [_TResponse ] | UnaryStreamCall [_TRequest , _TResponse ]: ...
320
350
321
- class StreamStreamClientInterceptor (typing .Generic [_TRequest , _TResponse ]):
351
+ class StreamStreamClientInterceptor (typing .Generic [_TRequest , _TResponse ], metaclass = abc . ABCMeta ):
322
352
@abc .abstractmethod
323
353
async def intercept_stream_stream (
324
354
self ,
@@ -329,7 +359,8 @@ class StreamStreamClientInterceptor(typing.Generic[_TRequest, _TResponse]):
329
359
330
360
# Server-Side Interceptor:
331
361
332
- class ServerInterceptor (typing .Generic [_TRequest , _TResponse ]):
362
+ class ServerInterceptor (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
363
+ @abc .abstractmethod
333
364
async def intercept_service (
334
365
self ,
335
366
continuation : Callable [[HandlerCallDetails ], Awaitable [RpcMethodHandler [_TRequest , _TResponse ]]],
@@ -339,9 +370,11 @@ class ServerInterceptor(typing.Generic[_TRequest, _TResponse]):
339
370
# Multi-Callable Interfaces:
340
371
341
372
class UnaryUnaryMultiCallable (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
373
+ @abc .abstractmethod
342
374
def __call__ (
343
375
self ,
344
376
request : _TRequest ,
377
+ * ,
345
378
timeout : float | None = ...,
346
379
metadata : MetadataType | None = ...,
347
380
credentials : CallCredentials | None = ...,
@@ -351,9 +384,11 @@ class UnaryUnaryMultiCallable(typing.Generic[_TRequest, _TResponse], metaclass=a
351
384
) -> UnaryUnaryCall [_TRequest , _TResponse ]: ...
352
385
353
386
class UnaryStreamMultiCallable (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
387
+ @abc .abstractmethod
354
388
def __call__ (
355
389
self ,
356
390
request : _TRequest ,
391
+ * ,
357
392
timeout : float | None = ...,
358
393
metadata : MetadataType | None = ...,
359
394
credentials : CallCredentials | None = ...,
@@ -363,9 +398,10 @@ class UnaryStreamMultiCallable(typing.Generic[_TRequest, _TResponse], metaclass=
363
398
) -> UnaryStreamCall [_TRequest , _TResponse ]: ...
364
399
365
400
class StreamUnaryMultiCallable (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
401
+ @abc .abstractmethod
366
402
def __call__ (
367
403
self ,
368
- request_iterator : AsyncIterator [_TRequest ] | Iterator [_TRequest ] | None ,
404
+ request_iterator : AsyncIterator [_TRequest ] | Iterator [_TRequest ] | None = None ,
369
405
timeout : float | None = ...,
370
406
metadata : MetadataType | None = ...,
371
407
credentials : CallCredentials | None = ...,
@@ -375,9 +411,10 @@ class StreamUnaryMultiCallable(typing.Generic[_TRequest, _TResponse], metaclass=
375
411
) -> StreamUnaryCall [_TRequest , _TResponse ]: ...
376
412
377
413
class StreamStreamMultiCallable (typing .Generic [_TRequest , _TResponse ], metaclass = abc .ABCMeta ):
414
+ @abc .abstractmethod
378
415
def __call__ (
379
416
self ,
380
- request_iterator : AsyncIterator [_TRequest ] | Iterator [_TRequest ] | None ,
417
+ request_iterator : AsyncIterator [_TRequest ] | Iterator [_TRequest ] | None = None ,
381
418
timeout : float | None = ...,
382
419
metadata : MetadataType | None = ...,
383
420
credentials : CallCredentials | None = ...,
0 commit comments