@@ -2,7 +2,7 @@ use std::{ops::Deref, sync::Arc};
22
33use async_nats:: { Subject , client:: traits:: Publisher , connection:: State } ;
44use pyo3:: {
5- Bound , PyAny , Python , pyclass , pymethods ,
5+ Bound , PyAny , Python ,
66 types:: { PyBytes , PyBytesMethods , PyDict } ,
77} ;
88use tokio:: sync:: RwLock ;
@@ -16,7 +16,7 @@ use crate::{
1616 utils:: { headers:: NatsrpyHeadermapExt , natsrpy_future} ,
1717} ;
1818
19- #[ pyclass]
19+ #[ pyo3 :: pyclass]
2020pub struct JetStream {
2121 ctx : Arc < RwLock < async_nats:: jetstream:: Context > > ,
2222}
@@ -30,7 +30,7 @@ impl JetStream {
3030 }
3131}
3232
33- #[ pymethods]
33+ #[ pyo3 :: pymethods]
3434impl JetStream {
3535 #[ pyo3( signature = (
3636 subject,
@@ -120,6 +120,18 @@ impl JetStream {
120120 } )
121121 }
122122
123+ pub fn get_stream < ' py > (
124+ & self ,
125+ py : Python < ' py > ,
126+ name : String ,
127+ ) -> NatsrpyResult < Bound < ' py , PyAny > > {
128+ let ctx = self . ctx . clone ( ) ;
129+ natsrpy_future ( py, async move {
130+ let js = ctx. read ( ) . await ;
131+ Ok ( super :: stream:: Stream :: new ( js. get_stream ( name) . await ?) )
132+ } )
133+ }
134+
123135 pub fn create_stream < ' py > (
124136 & self ,
125137 py : Python < ' py > ,
@@ -135,15 +147,15 @@ impl JetStream {
135147 } )
136148 }
137149
138- pub fn get_stream < ' py > (
150+ pub fn delete_stream < ' py > (
139151 & self ,
140152 py : Python < ' py > ,
141153 name : String ,
142154 ) -> NatsrpyResult < Bound < ' py , PyAny > > {
143155 let ctx = self . ctx . clone ( ) ;
144156 natsrpy_future ( py, async move {
145157 let js = ctx. read ( ) . await ;
146- Ok ( super :: stream :: Stream :: new ( js. get_stream ( name) . await ?) )
158+ Ok ( js. delete_stream ( name) . await ?. success )
147159 } )
148160 }
149161}
0 commit comments