Skip to content

Commit fd06c17

Browse files
authored
chore(vrl): Reduce VRL core such that it doesn't have any other dependencies to VRL (#11492)
* Rename `lib/vrl/core` -> `lib/vrl/vrl` * Move `compiler::Target` to `core` * Move `compiler::Resolved` to `core` * Use `vrl` over `vrl_` in public feature flag name Signed-off-by: Pablo Sichert <[email protected]>
1 parent 0f1f909 commit fd06c17

36 files changed

+651
-263
lines changed

Cargo.lock

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ members = [
9090
"lib/vrl/stdlib",
9191
"lib/vrl/tests",
9292
"lib/vrl/proptests",
93+
"lib/vrl/vrl",
9394
"lib/vector-vrl-functions",
9495
"lib/datadog/grok",
9596
"lib/datadog/search-syntax",
@@ -205,7 +206,7 @@ hex = { version = "0.4.3", optional = true }
205206
sha2 = { version = "0.10.2", optional = true }
206207

207208
# VRL Lang
208-
vrl = { path = "lib/vrl/core" }
209+
vrl = { path = "lib/vrl/vrl" }
209210
vrl-stdlib = { path = "lib/vrl/stdlib" }
210211

211212
# Lookup

lib/enrichment/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ arc-swap = { version = "1.4.0", default-features = false }
1010
dyn-clone = { version = "1.0.4", default-features = false }
1111
chrono = { version = "0.4.19", default-features = false }
1212
vector_common = { path = "../vector-common", default-features = false, features = [ "btreemap", "conversion" ] }
13-
vrl-core = { package = "vrl", path = "../vrl/core" }
14-
13+
vrl = { package = "vrl", path = "../vrl/vrl" }

lib/enrichment/src/find_enrichment_table_records.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::BTreeMap;
22

3-
use vrl_core::prelude::*;
3+
use vrl::prelude::*;
44

55
use crate::{
66
vrl_util::{self, add_index, evaluate_condition},
@@ -196,7 +196,7 @@ mod tests {
196196

197197
let tz = TimeZone::default();
198198
let mut object: Value = BTreeMap::new().into();
199-
let mut runtime_state = vrl_core::state::Runtime::default();
199+
let mut runtime_state = vrl::state::Runtime::default();
200200
let mut ctx = Context::new(&mut object, &mut runtime_state, &tz);
201201

202202
registry.finish_load();

lib/enrichment/src/get_enrichment_table_record.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::BTreeMap;
22

3-
use vrl_core::prelude::*;
3+
use vrl::prelude::*;
44

55
use crate::{
66
vrl_util::{self, add_index, evaluate_condition},
@@ -188,7 +188,7 @@ mod tests {
188188

189189
let tz = TimeZone::default();
190190
let mut object: Value = BTreeMap::new().into();
191-
let mut runtime_state = vrl_core::state::Runtime::default();
191+
let mut runtime_state = vrl::state::Runtime::default();
192192
let mut ctx = Context::new(&mut object, &mut runtime_state, &tz);
193193

194194
registry.finish_load();

lib/enrichment/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::collections::BTreeMap;
99

1010
use dyn_clone::DynClone;
1111
pub use tables::{TableRegistry, TableSearch};
12-
use vrl_core::Value;
12+
use vrl::Value;
1313

1414
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
1515
pub struct IndexHandle(pub usize);
@@ -46,7 +46,7 @@ pub trait Table: DynClone {
4646
condition: &'a [Condition<'a>],
4747
select: Option<&[String]>,
4848
index: Option<IndexHandle>,
49-
) -> Result<BTreeMap<String, vrl_core::Value>, String>;
49+
) -> Result<BTreeMap<String, vrl::Value>, String>;
5050

5151
/// Search the enrichment table data with the given condition.
5252
/// All conditions must match (AND).
@@ -57,7 +57,7 @@ pub trait Table: DynClone {
5757
condition: &'a [Condition<'a>],
5858
select: Option<&[String]>,
5959
index: Option<IndexHandle>,
60-
) -> Result<Vec<BTreeMap<String, vrl_core::Value>>, String>;
60+
) -> Result<Vec<BTreeMap<String, vrl::Value>>, String>;
6161

6262
/// Hints to the enrichment table what data is going to be searched to allow it to index the
6363
/// data in advance.
@@ -75,7 +75,7 @@ pub trait Table: DynClone {
7575

7676
dyn_clone::clone_trait_object!(Table);
7777

78-
pub fn vrl_functions() -> Vec<Box<dyn vrl_core::Function>> {
78+
pub fn vrl_functions() -> Vec<Box<dyn vrl::Function>> {
7979
vec![
8080
Box::new(get_enrichment_table_record::GetEnrichmentTableRecord) as _,
8181
Box::new(find_enrichment_table_records::FindEnrichmentTableRecords) as _,

lib/enrichment/src/tables.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl TableSearch {
204204
condition: &'a [Condition<'a>],
205205
select: Option<&[String]>,
206206
index: Option<IndexHandle>,
207-
) -> Result<BTreeMap<String, vrl_core::Value>, String> {
207+
) -> Result<BTreeMap<String, vrl::Value>, String> {
208208
let tables = self.0.load();
209209
if let Some(ref tables) = **tables {
210210
match tables.get(table) {
@@ -226,7 +226,7 @@ impl TableSearch {
226226
condition: &'a [Condition<'a>],
227227
select: Option<&[String]>,
228228
index: Option<IndexHandle>,
229-
) -> Result<Vec<BTreeMap<String, vrl_core::Value>>, String> {
229+
) -> Result<Vec<BTreeMap<String, vrl::Value>>, String> {
230230
let tables = self.0.load();
231231
if let Some(ref tables) = **tables {
232232
match tables.get(table) {
@@ -272,7 +272,7 @@ fn fmt_enrichment_table(
272272
#[cfg(test)]
273273
mod tests {
274274
use vector_common::btreemap;
275-
use vrl_core::Value;
275+
use vrl::Value;
276276

277277
use super::*;
278278
use crate::test_util::DummyEnrichmentTable;

lib/enrichment/src/test_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::{
44
};
55

66
use vector_common::btreemap;
7-
use vrl_core::Value;
7+
use vrl::Value;
88

99
use crate::{Case, Condition, IndexHandle, Table, TableRegistry};
1010

lib/enrichment/src/vrl_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Utilities shared between both VRL functions.
22
use std::collections::BTreeMap;
33

4-
use vrl_core::{
4+
use vrl::{
55
diagnostic::{Label, Span},
66
prelude::*,
77
};

lib/vector-core/Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ twox-hash = { version = "1.6.2", default-features = false }
5656
value = { path = "../value", default-features = false, features = ["lua", "toml", "json", "api"] }
5757
vector_buffers = { path = "../vector-buffers", default-features = false }
5858
vector_common = { path = "../vector-common" }
59-
vrl-core = { package = "vrl", path = "../vrl/core", optional = true }
59+
# Rename to "vrl" once we use a release with stable `-Z namespaced-features`:
60+
# https://doc.rust-lang.org/cargo/reference/unstable.html#namespaced-features
61+
vrl-lib = { package = "vrl", path = "../vrl/vrl", optional = true }
6062

6163
[build-dependencies]
6264
prost-build = "0.9"
@@ -81,7 +83,7 @@ value = { path = "../value", default-features = false, features = ["lua", "toml"
8183
api = ["async-graphql", "value/api"]
8284
default = []
8385
lua = ["mlua", "tokio-stream"]
84-
vrl = ["vrl-core", "enrichment"]
86+
vrl = ["vrl-lib", "enrichment"]
8587
test = ["vector_common/test"]
8688

8789
[[bench]]

lib/vector-core/src/event/metric.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use getset::{Getters, MutGetters};
1313
use serde::{Deserialize, Serialize};
1414
use vector_common::EventDataEq;
1515
#[cfg(feature = "vrl")]
16-
use vrl_core::prelude::VrlValueConvert;
16+
use vrl_lib::prelude::VrlValueConvert;
1717

1818
use crate::{
1919
event::{BatchNotifier, EventFinalizer, EventFinalizers, EventMetadata, Finalizable},
@@ -128,10 +128,10 @@ pub enum MetricKind {
128128
}
129129

130130
#[cfg(feature = "vrl")]
131-
impl TryFrom<vrl_core::Value> for MetricKind {
131+
impl TryFrom<vrl_lib::Value> for MetricKind {
132132
type Error = String;
133133

134-
fn try_from(value: vrl_core::Value) -> Result<Self, Self::Error> {
134+
fn try_from(value: vrl_lib::Value) -> Result<Self, Self::Error> {
135135
let value = value.try_bytes().map_err(|e| e.to_string())?;
136136
match std::str::from_utf8(&value).map_err(|e| e.to_string())? {
137137
"incremental" => Ok(Self::Incremental),
@@ -145,7 +145,7 @@ impl TryFrom<vrl_core::Value> for MetricKind {
145145
}
146146

147147
#[cfg(feature = "vrl")]
148-
impl From<MetricKind> for vrl_core::Value {
148+
impl From<MetricKind> for vrl_lib::Value {
149149
fn from(kind: MetricKind) -> Self {
150150
match kind {
151151
MetricKind::Incremental => "incremental".into(),
@@ -470,7 +470,7 @@ pub fn zip_quantiles(
470470
/// Currently vrl can only read the type of the value and doesn't consider
471471
/// any actual metric values.
472472
#[cfg(feature = "vrl")]
473-
impl From<MetricValue> for vrl_core::Value {
473+
impl From<MetricValue> for vrl_lib::Value {
474474
fn from(value: MetricValue) -> Self {
475475
value.as_name().into()
476476
}
@@ -525,7 +525,7 @@ impl ByteSizeOf for MetricSketch {
525525
/// Currently vrl can only read the type of the value and doesn't consider
526526
/// any actual metric values.
527527
#[cfg(feature = "vrl")]
528-
impl From<MetricSketch> for vrl_core::Value {
528+
impl From<MetricSketch> for vrl_lib::Value {
529529
fn from(value: MetricSketch) -> Self {
530530
value.as_name().into()
531531
}

0 commit comments

Comments
 (0)