Skip to content

Commit 16d63fb

Browse files
brucegpull[bot]
authored andcommitted
chore(dev): Add wrapper for enrichment to vector-lib (#18977)
1 parent 3cbc85c commit 16d63fb

File tree

31 files changed

+83
-64
lines changed

31 files changed

+83
-64
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ pin-project.workspace = true
130130

131131
# Internal libs
132132
dnsmsg-parser = { path = "lib/dnsmsg-parser", optional = true }
133-
enrichment = { path = "lib/enrichment" }
134133
fakedata = { path = "lib/fakedata", optional = true }
135134
file-source = { path = "lib/file-source", optional = true }
136135
lookup = { package = "vector-lookup", path = "lib/vector-lookup" }

lib/vector-lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ publish = false
77

88
[dependencies]
99
codecs = { path = "../codecs", default-features = false }
10+
enrichment = { path = "../enrichment" }
1011
vector-buffers = { path = "../vector-buffers", default-features = false }
1112
vector-common = { path = "../vector-common" }
1213
vector-config = { path = "../vector-config" }

lib/vector-lib/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub use codecs;
2+
pub use enrichment;
23
pub use vector_buffers as buffers;
34
pub use vector_common::{
45
assert_event_data_eq, btreemap, byte_size_of, byte_size_of::ByteSizeOf, conversion,

src/conditions/datadog_search.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ impl Conditional for DatadogSearchRunner {
3838
}
3939

4040
impl ConditionalConfig for DatadogSearchConfig {
41-
fn build(&self, _enrichment_tables: &enrichment::TableRegistry) -> crate::Result<Condition> {
41+
fn build(
42+
&self,
43+
_enrichment_tables: &vector_lib::enrichment::TableRegistry,
44+
) -> crate::Result<Condition> {
4245
let node = parse(&self.source)?;
4346
let matcher = as_log(build_matcher(&node, &EventFilter));
4447

src/conditions/mod.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ pub enum ConditionConfig {
116116
}
117117

118118
impl ConditionConfig {
119-
pub fn build(&self, enrichment_tables: &enrichment::TableRegistry) -> crate::Result<Condition> {
119+
pub fn build(
120+
&self,
121+
enrichment_tables: &vector_lib::enrichment::TableRegistry,
122+
) -> crate::Result<Condition> {
120123
match self {
121124
ConditionConfig::IsLog => Ok(Condition::IsLog),
122125
ConditionConfig::IsMetric => Ok(Condition::IsMetric),
@@ -148,7 +151,10 @@ pub trait Conditional: std::fmt::Debug {
148151
}
149152

150153
pub trait ConditionalConfig: std::fmt::Debug + Send + Sync + dyn_clone::DynClone {
151-
fn build(&self, enrichment_tables: &enrichment::TableRegistry) -> crate::Result<Condition>;
154+
fn build(
155+
&self,
156+
enrichment_tables: &vector_lib::enrichment::TableRegistry,
157+
) -> crate::Result<Condition>;
152158
}
153159

154160
dyn_clone::clone_trait_object!(ConditionalConfig);
@@ -184,7 +190,10 @@ pub enum AnyCondition {
184190
}
185191

186192
impl AnyCondition {
187-
pub fn build(&self, enrichment_tables: &enrichment::TableRegistry) -> crate::Result<Condition> {
193+
pub fn build(
194+
&self,
195+
enrichment_tables: &vector_lib::enrichment::TableRegistry,
196+
) -> crate::Result<Condition> {
188197
match self {
189198
AnyCondition::String(s) => {
190199
let vrl_config = VrlConfig {

src/conditions/vrl.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ pub struct VrlConfig {
3030
impl_generate_config_from_default!(VrlConfig);
3131

3232
impl ConditionalConfig for VrlConfig {
33-
fn build(&self, enrichment_tables: &enrichment::TableRegistry) -> crate::Result<Condition> {
33+
fn build(
34+
&self,
35+
enrichment_tables: &vector_lib::enrichment::TableRegistry,
36+
) -> crate::Result<Condition> {
3437
// TODO(jean): re-add this to VRL
3538
// let constraint = TypeConstraint {
3639
// allow_any: false,
@@ -43,7 +46,7 @@ impl ConditionalConfig for VrlConfig {
4346

4447
let functions = vrl::stdlib::all()
4548
.into_iter()
46-
.chain(enrichment::vrl_functions())
49+
.chain(vector_lib::enrichment::vrl_functions())
4750
.chain(vector_vrl_functions::all())
4851
.collect::<Vec<_>>();
4952

src/config/enrichment_table.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ pub trait EnrichmentTableConfig: NamedComponent + core::fmt::Debug + Send + Sync
3737
async fn build(
3838
&self,
3939
globals: &GlobalOptions,
40-
) -> crate::Result<Box<dyn enrichment::Table + Send + Sync>>;
40+
) -> crate::Result<Box<dyn vector_lib::enrichment::Table + Send + Sync>>;
4141
}

src/config/graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl Graph {
7777
Node::Transform {
7878
in_ty: transform.inner.input().data_type(),
7979
outputs: transform.inner.outputs(
80-
enrichment::TableRegistry::default(),
80+
vector_lib::enrichment::TableRegistry::default(),
8181
&[(id.into(), schema::Definition::any())],
8282
schema.log_namespace(),
8383
),

src/config/transform.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub struct TransformContext {
105105

106106
pub globals: GlobalOptions,
107107

108-
pub enrichment_tables: enrichment::TableRegistry,
108+
pub enrichment_tables: vector_lib::enrichment::TableRegistry,
109109

110110
/// Tracks the schema IDs assigned to schemas exposed by the transform.
111111
///
@@ -193,7 +193,7 @@ pub trait TransformConfig: DynClone + NamedComponent + core::fmt::Debug + Send +
193193
/// of events flowing through the transform.
194194
fn outputs(
195195
&self,
196-
enrichment_tables: enrichment::TableRegistry,
196+
enrichment_tables: vector_lib::enrichment::TableRegistry,
197197
input_definitions: &[(OutputId, schema::Definition)],
198198

199199
// This only exists for transforms that create logs from non-logs, to know which namespace
@@ -250,7 +250,7 @@ pub fn get_transform_output_ids<T: TransformConfig + ?Sized>(
250250
) -> impl Iterator<Item = OutputId> + '_ {
251251
transform
252252
.outputs(
253-
enrichment::TableRegistry::default(),
253+
vector_lib::enrichment::TableRegistry::default(),
254254
&[(key.clone().into(), schema::Definition::any())],
255255
global_log_namespace,
256256
)

0 commit comments

Comments
 (0)