@@ -165,14 +165,15 @@ pub async fn get_retention(stream_name: Path<String>) -> Result<impl Responder,
165
165
// For query mode, if the stream not found in memory map,
166
166
//check if it exists in the storage
167
167
//create stream and schema from storage
168
- if PARSEABLE . options . mode == Mode :: Query {
169
- match PARSEABLE
170
- . create_stream_and_schema_from_storage ( & stream_name)
171
- . await
172
- {
173
- Ok ( true ) => { }
174
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
175
- }
168
+ if PARSEABLE . options . mode == Mode :: Query
169
+ && matches ! (
170
+ PARSEABLE
171
+ . create_stream_and_schema_from_storage( & stream_name)
172
+ . await ,
173
+ Ok ( false ) | Err ( _)
174
+ )
175
+ {
176
+ return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
176
177
}
177
178
178
179
let retention = PARSEABLE
@@ -191,17 +192,18 @@ pub async fn put_retention(
191
192
// For query mode, if the stream not found in memory map,
192
193
//check if it exists in the storage
193
194
//create stream and schema from storage
194
- if PARSEABLE . options . mode == Mode :: Query {
195
- match PARSEABLE
196
- . create_stream_and_schema_from_storage ( & stream_name)
197
- . await
198
- {
199
- Ok ( true ) => { }
200
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
201
- }
195
+ if PARSEABLE . options . mode == Mode :: Query
196
+ && matches ! (
197
+ PARSEABLE
198
+ . create_stream_and_schema_from_storage( & stream_name)
199
+ . await ,
200
+ Ok ( false ) | Err ( _)
201
+ )
202
+ {
203
+ return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
202
204
}
203
- let stream = PARSEABLE . get_stream ( & stream_name) ?;
204
205
206
+ let stream = PARSEABLE . get_stream ( & stream_name) ?;
205
207
let retention: Retention = match serde_json:: from_value ( json) {
206
208
Ok ( retention) => retention,
207
209
Err ( err) => return Err ( StreamError :: InvalidRetentionConfig ( err) ) ,
@@ -231,15 +233,14 @@ pub async fn get_stats(
231
233
// For query mode, if the stream not found in memory map,
232
234
//check if it exists in the storage
233
235
//create stream and schema from storage
234
- if PARSEABLE . options . mode == Mode :: Query {
235
- match PARSEABLE
236
- . create_stream_and_schema_from_storage ( & stream_name)
237
- . await
238
- {
239
- Ok ( true ) => { }
240
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
241
- }
242
- } else {
236
+ if PARSEABLE . options . mode != Mode :: Query
237
+ || matches ! (
238
+ PARSEABLE
239
+ . create_stream_and_schema_from_storage( & stream_name)
240
+ . await ,
241
+ Ok ( false ) | Err ( _)
242
+ )
243
+ {
243
244
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
244
245
}
245
246
}
@@ -325,15 +326,14 @@ pub async fn get_stats(
325
326
pub async fn get_stream_info ( stream_name : Path < String > ) -> Result < impl Responder , StreamError > {
326
327
let stream_name = stream_name. into_inner ( ) ;
327
328
if !PARSEABLE . streams . contains ( & stream_name) {
328
- if PARSEABLE . options . mode == Mode :: Query {
329
- match PARSEABLE
330
- . create_stream_and_schema_from_storage ( & stream_name)
331
- . await
332
- {
333
- Ok ( true ) => { }
334
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
335
- }
336
- } else {
329
+ if PARSEABLE . options . mode != Mode :: Query
330
+ || matches ! (
331
+ PARSEABLE
332
+ . create_stream_and_schema_from_storage( & stream_name)
333
+ . await ,
334
+ Ok ( false ) | Err ( _)
335
+ )
336
+ {
337
337
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
338
338
}
339
339
}
@@ -385,14 +385,15 @@ pub async fn put_stream_hot_tier(
385
385
// For query mode, if the stream not found in memory map,
386
386
//check if it exists in the storage
387
387
//create stream and schema from storage
388
- if PARSEABLE . options . mode == Mode :: Query {
389
- match PARSEABLE
390
- . create_stream_and_schema_from_storage ( & stream_name)
391
- . await
392
- {
393
- Ok ( true ) => { }
394
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
395
- }
388
+ if PARSEABLE . options . mode == Mode :: Query
389
+ && matches ! (
390
+ PARSEABLE
391
+ . create_stream_and_schema_from_storage( & stream_name)
392
+ . await ,
393
+ Ok ( false ) | Err ( _)
394
+ )
395
+ {
396
+ return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
396
397
}
397
398
398
399
let stream = PARSEABLE . get_stream ( & stream_name) ?;
@@ -439,15 +440,14 @@ pub async fn get_stream_hot_tier(stream_name: Path<String>) -> Result<impl Respo
439
440
// For query mode, if the stream not found in memory map,
440
441
//check if it exists in the storage
441
442
//create stream and schema from storage
442
- if PARSEABLE . options . mode == Mode :: Query {
443
- match PARSEABLE
444
- . create_stream_and_schema_from_storage ( & stream_name)
445
- . await
446
- {
447
- Ok ( true ) => { }
448
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
449
- }
450
- } else {
443
+ if PARSEABLE . options . mode != Mode :: Query
444
+ || matches ! (
445
+ PARSEABLE
446
+ . create_stream_and_schema_from_storage( & stream_name)
447
+ . await ,
448
+ Ok ( false ) | Err ( _)
449
+ )
450
+ {
451
451
return Err ( StreamNotFound ( stream_name) . into ( ) ) ;
452
452
}
453
453
}
@@ -468,14 +468,15 @@ pub async fn delete_stream_hot_tier(
468
468
// For query mode, if the stream not found in memory map,
469
469
//check if it exists in the storage
470
470
//create stream and schema from storage
471
- if PARSEABLE . options . mode == Mode :: Query {
472
- match PARSEABLE
473
- . create_stream_and_schema_from_storage ( & stream_name)
474
- . await
475
- {
476
- Ok ( true ) => { }
477
- Ok ( false ) | Err ( _) => return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ,
478
- }
471
+ if PARSEABLE . options . mode == Mode :: Query
472
+ && matches ! (
473
+ PARSEABLE
474
+ . create_stream_and_schema_from_storage( & stream_name)
475
+ . await ,
476
+ Ok ( false ) | Err ( _)
477
+ )
478
+ {
479
+ return Err ( StreamNotFound ( stream_name. clone ( ) ) . into ( ) ) ;
479
480
}
480
481
481
482
if PARSEABLE . get_stream ( & stream_name) ?. get_stream_type ( ) == StreamType :: Internal {
0 commit comments