@@ -4,6 +4,7 @@ use std::path::PathBuf;
4
4
5
5
use bytes:: Bytes ;
6
6
use chrono:: Utc ;
7
+ use derivative:: Derivative ;
7
8
use ordered_float:: NotNan ;
8
9
use prost_reflect:: { DescriptorPool , DynamicMessage , MessageDescriptor , ReflectMessage } ;
9
10
use smallvec:: { smallvec, SmallVec } ;
@@ -22,11 +23,12 @@ use super::Deserializer;
22
23
#[ configurable_component]
23
24
#[ derive( Debug , Clone , Default ) ]
24
25
pub struct ProtobufDeserializerConfig {
25
- /// Path to desc file
26
- desc_file : PathBuf ,
27
-
28
- /// message type. e.g package.message
29
- message_type : String ,
26
+ /// Protobuf-specific decoding options.
27
+ #[ serde(
28
+ default ,
29
+ skip_serializing_if = "vector_core::serde::skip_serializing_if_default"
30
+ ) ]
31
+ pub protobuf : ProtobufDeserializerOptions ,
30
32
}
31
33
32
34
impl ProtobufDeserializerConfig {
@@ -66,6 +68,18 @@ impl ProtobufDeserializerConfig {
66
68
}
67
69
}
68
70
71
+ /// Protobuf-specific decoding options.
72
+ #[ configurable_component]
73
+ #[ derive( Debug , Clone , PartialEq , Eq , Derivative ) ]
74
+ #[ derivative( Default ) ]
75
+ pub struct ProtobufDeserializerOptions {
76
+ /// Path to desc file
77
+ desc_file : PathBuf ,
78
+
79
+ /// message type. e.g package.message
80
+ message_type : String ,
81
+ }
82
+
69
83
/// Deserializer that builds `Event`s from a byte frame containing protobuf.
70
84
#[ derive( Debug , Clone ) ]
71
85
pub struct ProtobufDeserializer {
@@ -125,8 +139,8 @@ impl TryFrom<&ProtobufDeserializerConfig> for ProtobufDeserializer {
125
139
type Error = vector_common:: Error ;
126
140
fn try_from ( config : & ProtobufDeserializerConfig ) -> vector_common:: Result < Self > {
127
141
let message_descriptor = ProtobufDeserializer :: get_message_descriptor (
128
- & config. desc_file ,
129
- config. message_type . clone ( ) ,
142
+ & config. protobuf . desc_file ,
143
+ config. protobuf . message_type . clone ( ) ,
130
144
) ?;
131
145
Ok ( Self :: new ( message_descriptor) )
132
146
}
0 commit comments