@@ -117,22 +117,30 @@ pub async fn ingest(
117117
118118 //if stream exists, fetch the stream log source
119119 //return error if the stream log source is otel traces or otel metrics
120- if let Ok ( stream) = PARSEABLE . get_stream ( & stream_name) {
121- stream
122- . get_log_source ( )
123- . iter ( )
124- . find ( |& stream_log_source_entry| {
125- stream_log_source_entry. log_source_format != LogSource :: OtelTraces
126- && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
127- } )
128- . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
129- }
120+ let stream = match PARSEABLE . get_stream ( & stream_name) {
121+ Ok ( stream) => {
122+ stream
123+ . get_log_source ( )
124+ . iter ( )
125+ . find ( |& stream_log_source_entry| {
126+ stream_log_source_entry. log_source_format != LogSource :: OtelTraces
127+ && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
128+ } )
129+ . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
130+ stream
131+ }
132+ Err ( e) => return Err ( PostError :: from ( e) ) ,
133+ } ;
130134
131135 PARSEABLE
132136 . add_update_log_source ( & stream_name, log_source_entry)
133137 . await ?;
134138
135- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
139+ if stream. get_time_partition ( ) . is_some ( ) {
140+ return Err ( PostError :: IngestionNotAllowedWithTimePartition ) ;
141+ }
142+
143+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields, None ) . await ?;
136144
137145 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
138146}
@@ -255,6 +263,7 @@ async fn process_otel_content(
255263 stream_name,
256264 log_source,
257265 & p_custom_fields,
266+ None ,
258267 )
259268 . await ?;
260269 } else if content_type == CONTENT_TYPE_PROTOBUF {
@@ -398,18 +407,31 @@ pub async fn post_event(
398407
399408 //if stream exists, fetch the stream log source
400409 //return error if the stream log source is otel traces or otel metrics
401- if let Ok ( stream) = PARSEABLE . get_stream ( & stream_name) {
402- stream
403- . get_log_source ( )
404- . iter ( )
405- . find ( |& stream_log_source_entry| {
406- stream_log_source_entry. log_source_format != LogSource :: OtelTraces
407- && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
408- } )
409- . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
410- }
410+ let stream = match PARSEABLE . get_stream ( & stream_name) {
411+ Ok ( stream) => {
412+ stream
413+ . get_log_source ( )
414+ . iter ( )
415+ . find ( |& stream_log_source_entry| {
416+ stream_log_source_entry. log_source_format != LogSource :: OtelTraces
417+ && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
418+ } )
419+ . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
420+ stream
421+ }
422+ Err ( e) => return Err ( PostError :: from ( e) ) ,
423+ } ;
411424
412- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
425+ let time_partition = stream. get_time_partition ( ) ;
426+
427+ flatten_and_push_logs (
428+ json,
429+ & stream_name,
430+ & log_source,
431+ & p_custom_fields,
432+ time_partition,
433+ )
434+ . await ?;
413435
414436 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
415437}
@@ -489,6 +511,8 @@ pub enum PostError {
489511 InvalidQueryParameter ,
490512 #[ error( "Missing query parameter" ) ]
491513 MissingQueryParameter ,
514+ #[ error( "Ingestion is not allowed to stream with time partition" ) ]
515+ IngestionNotAllowedWithTimePartition ,
492516}
493517
494518impl actix_web:: ResponseError for PostError {
@@ -520,6 +544,7 @@ impl actix_web::ResponseError for PostError {
520544 PostError :: FieldsCountLimitExceeded ( _, _, _) => StatusCode :: BAD_REQUEST ,
521545 PostError :: InvalidQueryParameter => StatusCode :: BAD_REQUEST ,
522546 PostError :: MissingQueryParameter => StatusCode :: BAD_REQUEST ,
547+ PostError :: IngestionNotAllowedWithTimePartition => StatusCode :: BAD_REQUEST ,
523548 }
524549 }
525550
0 commit comments