@@ -95,6 +95,13 @@ impl PyService {
95
95
) )
96
96
}
97
97
98
+ async fn delete_session ( & self , session_id : session:: Id ) -> Result < ( ) , ServiceError > {
99
+ self . sdk
100
+ . service
101
+ . delete_session ( & self . sdk . agent , session_id)
102
+ . await
103
+ }
104
+
98
105
async fn run_server ( & self , config : PyGrpcServerConfig ) -> Result < ( ) , ServiceError > {
99
106
self . sdk . service . run_server ( & config)
100
107
}
@@ -250,7 +257,7 @@ pub fn create_ff_session(
250
257
config. fire_and_forget_configuration ,
251
258
) )
252
259
. await
253
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
260
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
254
261
} )
255
262
}
256
263
@@ -267,7 +274,7 @@ pub fn create_rr_session(
267
274
config. request_response_configuration ,
268
275
) )
269
276
. await
270
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
277
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
271
278
} )
272
279
}
273
280
@@ -284,7 +291,18 @@ pub fn create_streaming_session(
284
291
config. streaming_configuration ,
285
292
) )
286
293
. await
287
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
294
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
295
+ } )
296
+ }
297
+
298
+ #[ gen_stub_pyfunction]
299
+ #[ pyfunction]
300
+ #[ pyo3( signature = ( svc, session_id) ) ]
301
+ pub fn delete_session ( py : Python , svc : PyService , session_id : u32 ) -> PyResult < Bound < PyAny > > {
302
+ pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
303
+ svc. delete_session ( session_id)
304
+ . await
305
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
288
306
} )
289
307
}
290
308
@@ -299,7 +317,7 @@ pub fn run_server(py: Python, svc: PyService, config: Py<PyDict>) -> PyResult<Bo
299
317
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
300
318
svc. run_server ( config)
301
319
. await
302
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
320
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
303
321
} )
304
322
}
305
323
@@ -313,7 +331,7 @@ pub fn stop_server(py: Python, svc: PyService, endpoint: String) -> PyResult<Bou
313
331
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
314
332
svc. stop_server ( & endpoint)
315
333
. await
316
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
334
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
317
335
} )
318
336
}
319
337
@@ -329,7 +347,7 @@ pub fn connect(py: Python, svc: PyService, config: Py<PyDict>) -> PyResult<Bound
329
347
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
330
348
svc. connect ( config)
331
349
. await
332
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
350
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
333
351
} )
334
352
}
335
353
@@ -339,7 +357,7 @@ pub fn disconnect(py: Python, svc: PyService, conn: u64) -> PyResult<Bound<PyAny
339
357
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
340
358
svc. disconnect ( conn)
341
359
. await
342
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
360
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
343
361
} )
344
362
}
345
363
@@ -356,7 +374,7 @@ pub fn subscribe(
356
374
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
357
375
svc. subscribe ( conn, name, id)
358
376
. await
359
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
377
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
360
378
} )
361
379
}
362
380
@@ -373,7 +391,7 @@ pub fn unsubscribe(
373
391
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
374
392
svc. unsubscribe ( conn, name, id)
375
393
. await
376
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
394
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
377
395
} )
378
396
}
379
397
@@ -390,7 +408,7 @@ pub fn set_route(
390
408
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
391
409
svc. set_route ( conn, name, id)
392
410
. await
393
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
411
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
394
412
} )
395
413
}
396
414
@@ -407,7 +425,7 @@ pub fn remove_route(
407
425
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
408
426
svc. remove_route ( conn, name, id)
409
427
. await
410
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
428
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
411
429
} )
412
430
}
413
431
@@ -426,7 +444,7 @@ pub fn publish(
426
444
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
427
445
svc. publish ( session_info. session_info , fanout, blob, name, id)
428
446
. await
429
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
447
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
430
448
} )
431
449
}
432
450
@@ -440,7 +458,7 @@ pub fn receive(py: Python, svc: PyService) -> PyResult<Bound<PyAny>> {
440
458
async move {
441
459
svc. receive ( )
442
460
. await
443
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
461
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
444
462
} ,
445
463
)
446
464
}
@@ -457,6 +475,6 @@ pub fn create_pyservice(
457
475
pyo3_async_runtimes:: tokio:: future_into_py ( py, async move {
458
476
PyService :: create_pyservice ( organization, namespace, agent_type, id)
459
477
. await
460
- . map_err ( |e| PyErr :: new :: < PyException , _ > ( format ! ( "{}" , e. to_string( ) ) ) )
478
+ . map_err ( |e| PyErr :: new :: < PyException , _ > ( e. to_string ( ) ) )
461
479
} )
462
480
}
0 commit comments