Skip to content

chore(vrl): Reduce VRL core such that it doesn't have any other dependencies to VRL #11492

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ members = [
"lib/vrl/stdlib",
"lib/vrl/tests",
"lib/vrl/proptests",
"lib/vrl/vrl",
"lib/vector-vrl-functions",
"lib/datadog/grok",
"lib/datadog/search-syntax",
Expand Down Expand Up @@ -205,7 +206,7 @@ sha2 = { version = "0.10.2", optional = true }
hex = { version = "0.4.3", optional = true }

# VRL Lang
vrl = { path = "lib/vrl/core" }
vrl = { path = "lib/vrl/vrl" }
vrl-stdlib = { path = "lib/vrl/stdlib" }

# Lookup
Expand Down
3 changes: 1 addition & 2 deletions lib/enrichment/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ arc-swap = { version = "1.4.0", default-features = false }
dyn-clone = { version = "1.0.4", default-features = false }
chrono = { version = "0.4.19", default-features = false }
vector_common = { path = "../vector-common", default-features = false, features = [ "btreemap", "conversion" ] }
vrl-core = { package = "vrl", path = "../vrl/core" }

vrl = { package = "vrl", path = "../vrl/vrl" }
4 changes: 2 additions & 2 deletions lib/enrichment/src/find_enrichment_table_records.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;

use vrl_core::prelude::*;
use vrl::prelude::*;

use crate::{
vrl_util::{self, add_index, evaluate_condition},
Expand Down Expand Up @@ -196,7 +196,7 @@ mod tests {

let tz = TimeZone::default();
let mut object: Value = BTreeMap::new().into();
let mut runtime_state = vrl_core::state::Runtime::default();
let mut runtime_state = vrl::state::Runtime::default();
let mut ctx = Context::new(&mut object, &mut runtime_state, &tz);

registry.finish_load();
Expand Down
4 changes: 2 additions & 2 deletions lib/enrichment/src/get_enrichment_table_record.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::BTreeMap;

use vrl_core::prelude::*;
use vrl::prelude::*;

use crate::{
vrl_util::{self, add_index, evaluate_condition},
Expand Down Expand Up @@ -188,7 +188,7 @@ mod tests {

let tz = TimeZone::default();
let mut object: Value = BTreeMap::new().into();
let mut runtime_state = vrl_core::state::Runtime::default();
let mut runtime_state = vrl::state::Runtime::default();
let mut ctx = Context::new(&mut object, &mut runtime_state, &tz);

registry.finish_load();
Expand Down
8 changes: 4 additions & 4 deletions lib/enrichment/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::collections::BTreeMap;

use dyn_clone::DynClone;
pub use tables::{TableRegistry, TableSearch};
use vrl_core::Value;
use vrl::Value;

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

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

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

dyn_clone::clone_trait_object!(Table);

pub fn vrl_functions() -> Vec<Box<dyn vrl_core::Function>> {
pub fn vrl_functions() -> Vec<Box<dyn vrl::Function>> {
vec![
Box::new(get_enrichment_table_record::GetEnrichmentTableRecord) as _,
Box::new(find_enrichment_table_records::FindEnrichmentTableRecords) as _,
Expand Down
6 changes: 3 additions & 3 deletions lib/enrichment/src/tables.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ impl TableSearch {
condition: &'a [Condition<'a>],
select: Option<&[String]>,
index: Option<IndexHandle>,
) -> Result<BTreeMap<String, vrl_core::Value>, String> {
) -> Result<BTreeMap<String, vrl::Value>, String> {
let tables = self.0.load();
if let Some(ref tables) = **tables {
match tables.get(table) {
Expand All @@ -226,7 +226,7 @@ impl TableSearch {
condition: &'a [Condition<'a>],
select: Option<&[String]>,
index: Option<IndexHandle>,
) -> Result<Vec<BTreeMap<String, vrl_core::Value>>, String> {
) -> Result<Vec<BTreeMap<String, vrl::Value>>, String> {
let tables = self.0.load();
if let Some(ref tables) = **tables {
match tables.get(table) {
Expand Down Expand Up @@ -272,7 +272,7 @@ fn fmt_enrichment_table(
#[cfg(test)]
mod tests {
use vector_common::btreemap;
use vrl_core::Value;
use vrl::Value;

use super::*;
use crate::test_util::DummyEnrichmentTable;
Expand Down
2 changes: 1 addition & 1 deletion lib/enrichment/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::{
};

use vector_common::btreemap;
use vrl_core::Value;
use vrl::Value;

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

Expand Down
2 changes: 1 addition & 1 deletion lib/enrichment/src/vrl_util.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Utilities shared between both VRL functions.
use std::collections::BTreeMap;

use vrl_core::{
use vrl::{
diagnostic::{Label, Span},
prelude::*,
};
Expand Down
6 changes: 4 additions & 2 deletions lib/vector-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ twox-hash = { version = "1.6.2", default-features = false }
value = { path = "../value", default-features = false, features = ["lua", "toml", "json", "api"] }
vector_buffers = { path = "../vector-buffers", default-features = false }
vector_common = { path = "../vector-common" }
vrl-core = { package = "vrl", path = "../vrl/core", optional = true }
# Rename to "vrl" once we use a release with stable `-Z namespaced-features`:
# https://doc.rust-lang.org/cargo/reference/unstable.html#namespaced-features
vrl-lib = { package = "vrl", path = "../vrl/vrl", optional = true }

[build-dependencies]
prost-build = "0.9"
Expand All @@ -81,7 +83,7 @@ value = { path = "../value", default-features = false, features = ["lua", "toml"
api = ["async-graphql", "value/api"]
default = []
lua = ["mlua", "tokio-stream"]
vrl = ["vrl-core", "enrichment"]
vrl = ["vrl-lib", "enrichment"]
test = ["vector_common/test"]

[[bench]]
Expand Down
12 changes: 6 additions & 6 deletions lib/vector-core/src/event/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use getset::{Getters, MutGetters};
use serde::{Deserialize, Serialize};
use vector_common::EventDataEq;
#[cfg(feature = "vrl")]
use vrl_core::prelude::VrlValueConvert;
use vrl_lib::prelude::VrlValueConvert;

use crate::{
event::{BatchNotifier, EventFinalizer, EventFinalizers, EventMetadata, Finalizable},
Expand Down Expand Up @@ -128,10 +128,10 @@ pub enum MetricKind {
}

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

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

#[cfg(feature = "vrl")]
impl From<MetricKind> for vrl_core::Value {
impl From<MetricKind> for vrl_lib::Value {
fn from(kind: MetricKind) -> Self {
match kind {
MetricKind::Incremental => "incremental".into(),
Expand Down Expand Up @@ -470,7 +470,7 @@ pub fn zip_quantiles(
/// Currently vrl can only read the type of the value and doesn't consider
/// any actual metric values.
#[cfg(feature = "vrl")]
impl From<MetricValue> for vrl_core::Value {
impl From<MetricValue> for vrl_lib::Value {
fn from(value: MetricValue) -> Self {
value.as_name().into()
}
Expand Down Expand Up @@ -525,7 +525,7 @@ impl ByteSizeOf for MetricSketch {
/// Currently vrl can only read the type of the value and doesn't consider
/// any actual metric values.
#[cfg(feature = "vrl")]
impl From<MetricSketch> for vrl_core::Value {
impl From<MetricSketch> for vrl_lib::Value {
fn from(value: MetricSketch) -> Self {
value.as_name().into()
}
Expand Down
Loading