@@ -123,22 +123,30 @@ pub async fn ingest(
123123
124124 //if stream exists, fetch the stream log source
125125 //return error if the stream log source is otel traces or otel metrics
126- if let Ok ( stream) = PARSEABLE . get_stream ( & stream_name) {
127- stream
128- . get_log_source ( )
129- . iter ( )
130- . find ( |& stream_log_source_entry| {
131- stream_log_source_entry. log_source_format != LogSource :: OtelTraces
132- && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
133- } )
134- . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
135- }
126+ let stream = match PARSEABLE . get_stream ( & stream_name) {
127+ Ok ( stream) => {
128+ stream
129+ . get_log_source ( )
130+ . iter ( )
131+ . find ( |& stream_log_source_entry| {
132+ stream_log_source_entry. log_source_format != LogSource :: OtelTraces
133+ && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
134+ } )
135+ . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
136+ stream
137+ }
138+ Err ( e) => return Err ( PostError :: from ( e) ) ,
139+ } ;
136140
137141 PARSEABLE
138142 . add_update_log_source ( & stream_name, log_source_entry)
139143 . await ?;
140144
141- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
145+ if stream. get_time_partition ( ) . is_some ( ) {
146+ return Err ( PostError :: IngestionNotAllowedWithTimePartition ) ;
147+ }
148+
149+ flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields, None ) . await ?;
142150
143151 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
144152}
@@ -267,6 +275,7 @@ where
267275 stream_name,
268276 log_source,
269277 & p_custom_fields,
278+ None ,
270279 )
271280 . await ?;
272281 } else if content_type == CONTENT_TYPE_PROTOBUF {
@@ -281,7 +290,8 @@ where
281290 match decode_protobuf ( body) {
282291 Ok ( decoded) => {
283292 for record in flatten_protobuf ( & decoded) {
284- push_logs ( stream_name, record, log_source, & p_custom_fields) . await ?;
293+ push_logs ( stream_name, record, log_source, & p_custom_fields, None )
294+ . await ?;
285295 }
286296 }
287297 Err ( e) => {
@@ -452,18 +462,31 @@ pub async fn post_event(
452462
453463 //if stream exists, fetch the stream log source
454464 //return error if the stream log source is otel traces or otel metrics
455- if let Ok ( stream) = PARSEABLE . get_stream ( & stream_name) {
456- stream
457- . get_log_source ( )
458- . iter ( )
459- . find ( |& stream_log_source_entry| {
460- stream_log_source_entry. log_source_format != LogSource :: OtelTraces
461- && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
462- } )
463- . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
464- }
465+ let stream = match PARSEABLE . get_stream ( & stream_name) {
466+ Ok ( stream) => {
467+ stream
468+ . get_log_source ( )
469+ . iter ( )
470+ . find ( |& stream_log_source_entry| {
471+ stream_log_source_entry. log_source_format != LogSource :: OtelTraces
472+ && stream_log_source_entry. log_source_format != LogSource :: OtelMetrics
473+ } )
474+ . ok_or ( PostError :: IncorrectLogFormat ( stream_name. clone ( ) ) ) ?;
475+ stream
476+ }
477+ Err ( e) => return Err ( PostError :: from ( e) ) ,
478+ } ;
465479
466- flatten_and_push_logs ( json, & stream_name, & log_source, & p_custom_fields) . await ?;
480+ let time_partition = stream. get_time_partition ( ) ;
481+
482+ flatten_and_push_logs (
483+ json,
484+ & stream_name,
485+ & log_source,
486+ & p_custom_fields,
487+ time_partition,
488+ )
489+ . await ?;
467490
468491 Ok ( HttpResponse :: Ok ( ) . finish ( ) )
469492}
@@ -543,6 +566,8 @@ pub enum PostError {
543566 InvalidQueryParameter ,
544567 #[ error( "Missing query parameter" ) ]
545568 MissingQueryParameter ,
569+ #[ error( "Ingestion is not allowed to stream with time partition" ) ]
570+ IngestionNotAllowedWithTimePartition ,
546571}
547572
548573impl actix_web:: ResponseError for PostError {
@@ -574,6 +599,7 @@ impl actix_web::ResponseError for PostError {
574599 PostError :: FieldsCountLimitExceeded ( _, _, _) => StatusCode :: BAD_REQUEST ,
575600 PostError :: InvalidQueryParameter => StatusCode :: BAD_REQUEST ,
576601 PostError :: MissingQueryParameter => StatusCode :: BAD_REQUEST ,
602+ PostError :: IngestionNotAllowedWithTimePartition => StatusCode :: BAD_REQUEST ,
577603 }
578604 }
579605
0 commit comments