File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -151,8 +151,11 @@ pub fn configure_routes(cfg: &mut web::ServiceConfig) {
151151 web:: resource ( "/stats" ) . route ( web:: get ( ) . to ( logstream:: get_stats) ) ,
152152 )
153153 . service (
154- // GET "/logstream/{logstream}/retention" ==> Set retention for given logstream
155- web:: resource ( "/retention" ) . route ( web:: put ( ) . to ( logstream:: put_retention) ) ,
154+ web:: resource ( "/retention" )
155+ // PUT "/logstream/{logstream}/retention" ==> Set retention for given logstream
156+ . route ( web:: put ( ) . to ( logstream:: put_retention) )
157+ // GET "/logstream/{logstream}/retention" ==> Get retention for given logstream
158+ . route ( web:: get ( ) . to ( logstream:: get_retention) ) ,
156159 ) ;
157160
158161 cfg. service (
Original file line number Diff line number Diff line change @@ -183,6 +183,23 @@ pub async fn put_alert(
183183 ) )
184184}
185185
186+ pub async fn get_retention ( req : HttpRequest ) -> Result < impl Responder , StreamError > {
187+ let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
188+ let objectstore = CONFIG . storage ( ) . get_object_store ( ) ;
189+
190+ if !objectstore. stream_exists ( & stream_name) . await ? {
191+ return Err ( StreamError :: StreamNotFound ( stream_name. to_string ( ) ) ) ;
192+ }
193+
194+ let retention = CONFIG
195+ . storage ( )
196+ . get_object_store ( )
197+ . get_retention ( & stream_name)
198+ . await ?;
199+
200+ Ok ( ( web:: Json ( retention) , StatusCode :: OK ) )
201+ }
202+
186203pub async fn put_retention (
187204 req : HttpRequest ,
188205 body : web:: Json < serde_json:: Value > ,
You can’t perform that action at this time.
0 commit comments