@@ -84,6 +84,7 @@ pub async fn delete(req: HttpRequest) -> Result<impl Responder, StreamError> {
8484}
8585
8686pub async fn list ( _: HttpRequest ) -> impl Responder {
87+ //list all streams from storage
8788 let res = CONFIG
8889 . storage ( )
8990 . get_object_store ( )
@@ -118,6 +119,10 @@ pub async fn schema(req: HttpRequest) -> Result<impl Responder, StreamError> {
118119 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
119120 let schema = match STREAM_INFO . schema ( & stream_name) {
120121 Ok ( schema) => schema,
122+
123+ //if schema not found in memory map
124+ //create stream and schema from storage and memory
125+ //return from memory map
121126 Err ( _) if CONFIG . parseable . mode == Mode :: Query => {
122127 if create_stream_and_schema_from_storage ( & stream_name) . await ? {
123128 STREAM_INFO . schema ( & stream_name) ?
@@ -194,6 +199,9 @@ pub async fn put_alert(
194199 validator:: alert ( & alerts) ?;
195200
196201 if !STREAM_INFO . stream_initialized ( & stream_name) ? {
202+ // For query mode, if the stream not found in memory map,
203+ //check if it exists in the storage
204+ //create stream and schema from storage
197205 if CONFIG . parseable . mode == Mode :: Query {
198206 match create_stream_and_schema_from_storage ( & stream_name) . await {
199207 Ok ( true ) => { }
@@ -239,6 +247,9 @@ pub async fn put_alert(
239247pub async fn get_retention ( req : HttpRequest ) -> Result < impl Responder , StreamError > {
240248 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
241249 if !STREAM_INFO . stream_exists ( & stream_name) {
250+ // For query mode, if the stream not found in memory map,
251+ //check if it exists in the storage
252+ //create stream and schema from storage
242253 if CONFIG . parseable . mode == Mode :: Query {
243254 match create_stream_and_schema_from_storage ( & stream_name) . await {
244255 Ok ( true ) => { }
@@ -267,6 +278,21 @@ pub async fn put_retention(
267278 body : web:: Json < serde_json:: Value > ,
268279) -> Result < impl Responder , StreamError > {
269280 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
281+
282+ if !STREAM_INFO . stream_exists ( & stream_name) {
283+ // For query mode, if the stream not found in memory map,
284+ //check if it exists in the storage
285+ //create stream and schema from storage
286+ if CONFIG . parseable . mode == Mode :: Query {
287+ match create_stream_and_schema_from_storage ( & stream_name) . await {
288+ Ok ( true ) => { }
289+ Ok ( false ) | Err ( _) => return Err ( StreamError :: StreamNotFound ( stream_name. clone ( ) ) ) ,
290+ }
291+ } else {
292+ return Err ( StreamError :: StreamNotFound ( stream_name) ) ;
293+ }
294+ }
295+
270296 let body = body. into_inner ( ) ;
271297
272298 let retention: Retention = match serde_json:: from_value ( body) {
@@ -356,6 +382,9 @@ pub async fn get_stats(req: HttpRequest) -> Result<impl Responder, StreamError>
356382 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
357383
358384 if !STREAM_INFO . stream_exists ( & stream_name) {
385+ // For query mode, if the stream not found in memory map,
386+ //check if it exists in the storage
387+ //create stream and schema from storage
359388 if CONFIG . parseable . mode == Mode :: Query {
360389 match create_stream_and_schema_from_storage ( & stream_name) . await {
361390 Ok ( true ) => { }
@@ -582,6 +611,9 @@ pub async fn put_stream_hot_tier(
582611) -> Result < impl Responder , StreamError > {
583612 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
584613 if !STREAM_INFO . stream_exists ( & stream_name) {
614+ // For query mode, if the stream not found in memory map,
615+ //check if it exists in the storage
616+ //create stream and schema from storage
585617 if CONFIG . parseable . mode == Mode :: Query {
586618 match create_stream_and_schema_from_storage ( & stream_name) . await {
587619 Ok ( true ) => { }
@@ -639,6 +671,9 @@ pub async fn get_stream_hot_tier(req: HttpRequest) -> Result<impl Responder, Str
639671 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
640672
641673 if !STREAM_INFO . stream_exists ( & stream_name) {
674+ // For query mode, if the stream not found in memory map,
675+ //check if it exists in the storage
676+ //create stream and schema from storage
642677 if CONFIG . parseable . mode == Mode :: Query {
643678 match create_stream_and_schema_from_storage ( & stream_name) . await {
644679 Ok ( true ) => { }
@@ -671,6 +706,9 @@ pub async fn delete_stream_hot_tier(req: HttpRequest) -> Result<impl Responder,
671706 let stream_name: String = req. match_info ( ) . get ( "logstream" ) . unwrap ( ) . parse ( ) . unwrap ( ) ;
672707
673708 if !STREAM_INFO . stream_exists ( & stream_name) {
709+ // For query mode, if the stream not found in memory map,
710+ //check if it exists in the storage
711+ //create stream and schema from storage
674712 if CONFIG . parseable . mode == Mode :: Query {
675713 match create_stream_and_schema_from_storage ( & stream_name) . await {
676714 Ok ( true ) => { }
0 commit comments