@@ -2,24 +2,27 @@ use std::{convert::TryInto, io::ErrorKind};
2
2
3
3
use async_compression:: tokio:: bufread;
4
4
use aws_sdk_s3:: types:: ByteStream ;
5
+ use codecs:: decoding:: { DeserializerConfig , FramingConfig , NewlineDelimitedDecoderOptions } ;
5
6
use codecs:: BytesDeserializerConfig ;
6
7
use futures:: { stream, stream:: StreamExt , TryStreamExt } ;
7
8
use lookup:: owned_value_path;
8
9
use snafu:: Snafu ;
9
10
use tokio_util:: io:: StreamReader ;
10
11
use value:: { kind:: Collection , Kind } ;
11
12
use vector_config:: configurable_component;
12
- use vector_core:: config:: { DataType , LegacyKey , LogNamespace } ;
13
+ use vector_core:: config:: { LegacyKey , LogNamespace } ;
13
14
14
15
use super :: util:: MultilineConfig ;
16
+ use crate :: codecs:: DecodingConfig ;
17
+ use crate :: config:: DataType ;
15
18
use crate :: {
16
19
aws:: { auth:: AwsAuthentication , create_client, RegionOrEndpoint } ,
17
20
common:: { s3:: S3ClientBuilder , sqs:: SqsClientBuilder } ,
18
21
config:: {
19
22
ProxyConfig , SourceAcknowledgementsConfig , SourceConfig , SourceContext , SourceOutput ,
20
23
} ,
21
24
line_agg,
22
- serde:: bool_or_struct,
25
+ serde:: { bool_or_struct, default_decoding } ,
23
26
tls:: TlsConfig ,
24
27
} ;
25
28
@@ -71,7 +74,8 @@ enum Strategy {
71
74
//
72
75
// Maybe showing defaults at all, when there are required properties, doesn't actually make sense? :thinkies:
73
76
#[ configurable_component( source( "aws_s3" , "Collect logs from AWS S3." ) ) ]
74
- #[ derive( Clone , Debug , Default ) ]
77
+ #[ derive( Clone , Debug , Derivative ) ]
78
+ #[ derivative( Default ) ]
75
79
#[ serde( default , deny_unknown_fields) ]
76
80
pub struct AwsS3Config {
77
81
#[ serde( flatten) ]
@@ -115,6 +119,23 @@ pub struct AwsS3Config {
115
119
#[ configurable( metadata( docs:: hidden) ) ]
116
120
#[ serde( default ) ]
117
121
log_namespace : Option < bool > ,
122
+
123
+ #[ configurable( derived) ]
124
+ #[ serde( default = "default_framing" ) ]
125
+ #[ derivative( Default ( value = "default_framing()" ) ) ]
126
+ pub framing : FramingConfig ,
127
+
128
+ #[ configurable( derived) ]
129
+ #[ serde( default = "default_decoding" ) ]
130
+ #[ derivative( Default ( value = "default_decoding()" ) ) ]
131
+ pub decoding : DeserializerConfig ,
132
+ }
133
+
134
+ const fn default_framing ( ) -> FramingConfig {
135
+ // This is used for backwards compatibility. It used to be the only (hardcoded) option.
136
+ FramingConfig :: NewlineDelimited {
137
+ newline_delimited : NewlineDelimitedDecoderOptions { max_length : None } ,
138
+ }
118
139
}
119
140
120
141
impl_generate_config_from_default ! ( AwsS3Config ) ;
@@ -133,7 +154,7 @@ impl SourceConfig for AwsS3Config {
133
154
134
155
match self . strategy {
135
156
Strategy :: Sqs => Ok ( Box :: pin (
136
- self . create_sqs_ingestor ( multiline_config, & cx. proxy )
157
+ self . create_sqs_ingestor ( multiline_config, & cx. proxy , log_namespace )
137
158
. await ?
138
159
. run ( cx, self . acknowledgements , log_namespace) ,
139
160
) ) ,
@@ -200,6 +221,7 @@ impl AwsS3Config {
200
221
& self ,
201
222
multiline : Option < line_agg:: Config > ,
202
223
proxy : & ProxyConfig ,
224
+ log_namespace : LogNamespace ,
203
225
) -> crate :: Result < sqs:: Ingestor > {
204
226
let region = self
205
227
. region
@@ -221,6 +243,9 @@ impl AwsS3Config {
221
243
)
222
244
. await ?;
223
245
246
+ let decoder =
247
+ DecodingConfig :: new ( self . framing . clone ( ) , self . decoding . clone ( ) , log_namespace) . build ( ) ;
248
+
224
249
match self . sqs {
225
250
Some ( ref sqs) => {
226
251
let sqs_client = create_client :: < SqsClientBuilder > (
@@ -240,6 +265,7 @@ impl AwsS3Config {
240
265
sqs. clone ( ) ,
241
266
self . compression ,
242
267
multiline,
268
+ decoder,
243
269
)
244
270
. await ?;
245
271
0 commit comments