Skip to content

Commit

Permalink
chore: reformatting imports (vectordotdev#10496)
Browse files Browse the repository at this point in the history
With

```
imports_granularity = "Crate"
group_imports = "StdExternalCrate"
```

Both of these are unstable though so I just left them commented in
rustfmt.toml.

Signed-off-by: Jesse Szwedko <[email protected]>
  • Loading branch information
jszwedko authored Dec 16, 2021
1 parent 598d73e commit bd8f097
Show file tree
Hide file tree
Showing 801 changed files with 6,210 additions and 4,628 deletions.
2 changes: 2 additions & 0 deletions .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Using defaults.
# Not stable yet.
# indent_style = "Block"
# group_imports = "StdExternalCrate"
# imports_granularity = "Crate"
reorder_imports = true
edition = "2021"
3 changes: 2 additions & 1 deletion benches/batch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{convert::Infallible, time::Duration};

use bytes::Bytes;
use criterion::{criterion_group, Criterion, SamplingMode, Throughput};
use futures::{future, stream, SinkExt, StreamExt};
use std::{convert::Infallible, time::Duration};
use vector::{
sinks::util::{
batch::{Batch, BatchConfig, BatchError, BatchSettings, BatchSize, PushResult},
Expand Down
12 changes: 5 additions & 7 deletions benches/distribution_statistic.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};

use rand::distributions::Distribution;
use rand::distributions::Uniform;
use rand::seq::SliceRandom;

use vector::event::metric::Sample;
use vector::sinks::util::statistic::DistributionStatistic;
use rand::{
distributions::{Distribution, Uniform},
seq::SliceRandom,
};
use vector::{event::metric::Sample, sinks::util::statistic::DistributionStatistic};

fn generate_samples(mut size: u32, max_bin_count: u32) -> Vec<Sample> {
let mut rng = rand::thread_rng();
Expand Down
6 changes: 4 additions & 2 deletions benches/dnstap/mod.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use bytes::Bytes;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion, Throughput};
use vector::event::Event;
use vector::sources::dnstap::{schema::DnstapEventSchema, DnstapParser};
use vector::{
event::Event,
sources::dnstap::{schema::DnstapEventSchema, DnstapParser},
};

fn benchmark_query_parsing(c: &mut Criterion) {
let mut event = Event::new_empty_log();
Expand Down
3 changes: 2 additions & 1 deletion benches/enrichment_tables_file.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use std::{collections::BTreeMap, time::SystemTime};

use chrono::prelude::*;
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use enrichment::Case;
use std::{collections::BTreeMap, time::SystemTime};
use vector::enrichment_tables::{file::File, Condition, Table};
use vrl::Value;

Expand Down
4 changes: 2 additions & 2 deletions benches/files.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use std::{convert::TryInto, path::PathBuf};

use bytes::Bytes;
use criterion::{criterion_group, BatchSize, Criterion, SamplingMode, Throughput};
use futures::{stream, SinkExt, StreamExt};
use std::convert::TryInto;
use std::path::PathBuf;
use tempfile::tempdir;
use tokio::fs::OpenOptions;
use tokio_util::codec::{BytesCodec, FramedWrite};
Expand Down
3 changes: 2 additions & 1 deletion benches/http.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use std::net::SocketAddr;

use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, SamplingMode, Throughput};
use futures::TryFutureExt;
use hyper::{
service::{make_service_fn, service_fn},
Body, Response, Server,
};
use std::net::SocketAddr;
use tokio::runtime::Runtime;
use vector::{
config, sinks,
Expand Down
6 changes: 3 additions & 3 deletions benches/loki.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use std::convert::TryFrom;
use vector::sinks::loki::valid_label_name;
use vector::template::Template;

use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use vector::{sinks::loki::valid_label_name, template::Template};

const VALID: [&str; 4] = ["name", " name ", "bee_bop", "a09b"];
const INVALID: [&str; 4] = ["0ab", "*", "", " "];
Expand Down
3 changes: 2 additions & 1 deletion benches/lua.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::pin::Pin;

use criterion::{criterion_group, BatchSize, Criterion, Throughput};
use futures::{stream, SinkExt, Stream, StreamExt};
use indexmap::IndexMap;
use indoc::indoc;
use std::pin::Pin;
use transforms::lua::v2::LuaConfig;
use vector::{
config::{TransformConfig, TransformContext},
Expand Down
2 changes: 0 additions & 2 deletions benches/regex.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use criterion::{criterion_group, BatchSize, Criterion, Throughput};

use rand::{rngs::SmallRng, thread_rng, Rng, SeedableRng};
use rand_distr::{Alphanumeric, Distribution, Uniform};

use vector::{
config::{TransformConfig, TransformContext},
event::Event,
Expand Down
3 changes: 2 additions & 1 deletion benches/remap.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use std::collections::HashMap;

use chrono::{DateTime, Utc};
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use indexmap::IndexMap;
use shared::TimeZone;
use std::collections::HashMap;
use vector::{
event::{Event, Value},
transforms::{
Expand Down
5 changes: 2 additions & 3 deletions benches/template.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use criterion::{criterion_group, BatchSize, Criterion};

use chrono::Utc;
use std::convert::TryFrom;

use chrono::Utc;
use criterion::{criterion_group, BatchSize, Criterion};
use vector::{config::log_schema, event::Event};

fn bench_elasticsearch_index(c: &mut Criterion) {
Expand Down
1 change: 0 additions & 1 deletion benches/topology.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use criterion::{criterion_group, BatchSize, Criterion, SamplingMode, Throughput}
use futures::{future, stream, StreamExt};
use indoc::indoc;
use rand::{rngs::SmallRng, thread_rng, Rng, SeedableRng};

use vector::{
config, sinks, sources,
test_util::{
Expand Down
15 changes: 8 additions & 7 deletions benches/transform/common.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
//! A common suite of structs, functions et al that are useful for the
//! benchmarking of vector transforms.
use futures::task::noop_waker;
use futures::Stream;
use std::num::NonZeroUsize;
use std::pin::Pin;
use std::task::{Context, Poll};
use vector::conditions::Condition;
use vector::event::Event;
use std::{
num::NonZeroUsize,
pin::Pin,
task::{Context, Poll},
};

use futures::{task::noop_waker, Stream};
use vector::{conditions::Condition, event::Event};

// == Conditions ==

Expand Down
12 changes: 6 additions & 6 deletions benches/transform/dedupe.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::common::{consume, FixedLogStream};
use core::fmt;
use criterion::BenchmarkId;
use std::{num::NonZeroUsize, time::Duration};

use criterion::{
criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion, SamplingMode,
Throughput,
criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion,
SamplingMode, Throughput,
};
use std::num::NonZeroUsize;
use std::time::Duration;
use vector::transforms::dedupe::{CacheConfig, Dedupe, DedupeConfig, FieldMatchConfig};
use vector_core::transform::Transform;

use crate::common::{consume, FixedLogStream};

#[derive(Debug)]
struct Param {
slug: &'static str,
Expand Down
14 changes: 8 additions & 6 deletions benches/transform/filter.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
use crate::common::AlwaysFail;
use crate::common::AlwaysPass;
use std::time::Duration;

use criterion::{
criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion, SamplingMode,
Throughput,
};
use std::time::Duration;
use vector::conditions::Condition;
use vector::transforms::filter::Filter;
use vector::transforms::FunctionTransform;
use vector::{
conditions::Condition,
transforms::{filter::Filter, FunctionTransform},
};
use vector_core::event::{Event, LogEvent};

use crate::common::{AlwaysFail, AlwaysPass};

#[derive(Debug)]
struct Payload {
filter: Filter,
Expand Down
12 changes: 6 additions & 6 deletions benches/transform/reduce.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
use crate::common::{consume, FixedLogStream};
use core::fmt;
use criterion::BenchmarkId;
use std::{num::NonZeroUsize, time::Duration};

use criterion::{
criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, Criterion, SamplingMode,
Throughput,
criterion_group, measurement::WallTime, BatchSize, BenchmarkGroup, BenchmarkId, Criterion,
SamplingMode, Throughput,
};
use indexmap::IndexMap;
use std::num::NonZeroUsize;
use std::time::Duration;
use vector::transforms::reduce::{Reduce, ReduceConfig};
use vector_core::transform::Transform;

use crate::common::{consume, FixedLogStream};

#[derive(Debug)]
struct Param {
slug: &'static str,
Expand Down
6 changes: 4 additions & 2 deletions lib/datadog/filter/src/filter.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use super::{Matcher, Run};
use std::fmt::Debug;

use datadog_search_syntax::{Comparison, ComparisonValue, Field};
use dyn_clone::{clone_trait_object, DynClone};
use std::fmt::Debug;

use super::{Matcher, Run};

/// A `Filter` is a generic type that contains methods that are invoked by the `build_filter`
/// function. Each method returns a heap-allocated `Matcher<V>` (typically a closure) containing
Expand Down
6 changes: 4 additions & 2 deletions lib/datadog/filter/src/matcher.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use crate::{Filter, Resolver};
use std::{fmt, marker::PhantomData};

use datadog_search_syntax::{BooleanType, QueryNode};
use dyn_clone::{clone_trait_object, DynClone};
use std::{fmt, marker::PhantomData};

use crate::{Filter, Resolver};

/// A `Matcher` is a type that contains a "run" method which returns true/false if value `V`
/// matches a filter.
Expand Down
17 changes: 9 additions & 8 deletions lib/datadog/grok/src/filters/array.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
use crate::grok_filter::GrokFilter;
use crate::{
ast::{Function, FunctionArgument},
parse_grok_rules::Error as GrokStaticError,
};
use std::convert::TryFrom;

use bytes::Bytes;
use nom::{
branch::alt,
bytes::complete::{tag, take, take_until},
character::complete::char,
combinator::cut,
combinator::map,
combinator::{cut, map},
multi::separated_list0,
sequence::{preceded, terminated},
IResult,
};
use std::convert::TryFrom;
use vrl_compiler::Value;

use crate::{
ast::{Function, FunctionArgument},
grok_filter::GrokFilter,
parse_grok_rules::Error as GrokStaticError,
};

pub fn filter_from_function(f: &Function) -> Result<GrokFilter, GrokStaticError> {
let args = f.args.as_ref();
let args_len = args.map_or(0, |args| args.len());
Expand Down
19 changes: 11 additions & 8 deletions lib/datadog/grok/src/filters/keyvalue.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
use crate::{
ast::{Function, FunctionArgument},
grok_filter::GrokFilter,
parse_grok::Error as GrokRuntimeError,
parse_grok_rules::Error as GrokStaticError,
};
use std::fmt::Formatter;

use bytes::Bytes;
use nom::{
self,
Expand All @@ -19,9 +15,15 @@ use nom::{
use nom_regex::str::re_find;
use ordered_float::NotNan;
use regex::Regex;
use std::fmt::Formatter;
use vrl_compiler::Value;

use crate::{
ast::{Function, FunctionArgument},
grok_filter::GrokFilter,
parse_grok::Error as GrokRuntimeError,
parse_grok_rules::Error as GrokStaticError,
};

pub fn filter_from_function(f: &Function) -> Result<GrokFilter, GrokStaticError> {
{
let args_len = f.args.as_ref().map_or(0, |args| args.len());
Expand Down Expand Up @@ -362,9 +364,10 @@ fn parse_key<'a>(

#[cfg(test)]
mod tests {
use super::*;
use regex::Regex;

use super::*;

#[test]
fn test_parse_keyvalue() {
// DD examples from https://docs.datadoghq.com/logs/log_configuration/parsing/?tab=filters#key-value-or-logfmt
Expand Down
10 changes: 6 additions & 4 deletions lib/datadog/grok/src/grok_filter.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use std::{convert::TryFrom, string::ToString};

use ordered_float::NotNan;
use strum_macros::Display;
use vrl_compiler::Value;

use crate::{
ast::{Function, FunctionArgument},
filters::{array, keyvalue, keyvalue::KeyValueFilter},
matchers::date::{apply_date_filter, DateFilter},
parse_grok::Error as GrokRuntimeError,
parse_grok_rules::Error as GrokStaticError,
};
use ordered_float::NotNan;
use std::{convert::TryFrom, string::ToString};
use strum_macros::Display;
use vrl_compiler::Value;

#[derive(Debug, Display, Clone)]
pub enum GrokFilter {
Expand Down
3 changes: 2 additions & 1 deletion lib/datadog/grok/src/lexer.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use ordered_float::NotNan;
use std::{iter::Peekable, str::CharIndices};

use ordered_float::NotNan;

pub type Tok<'input> = Token<&'input str>;
pub type SpannedResult<'input, Loc> = Result<Spanned<'input, Loc>, Error>;
pub type Spanned<'input, Loc> = (Loc, Tok<'input>, Loc);
Expand Down
6 changes: 4 additions & 2 deletions lib/datadog/grok/src/matchers/date.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use crate::parse_grok::Error as GrokRuntimeError;
use std::fmt::Formatter;

use chrono::{DateTime, FixedOffset, NaiveDate, NaiveDateTime, NaiveTime, Offset, TimeZone, Utc};
use chrono_tz::{Tz, UTC};
use peeking_take_while::PeekableExt;
use regex::Regex;
use std::fmt::Formatter;
use vrl_compiler::Value;

use crate::parse_grok::Error as GrokRuntimeError;

/// converts Joda time format to strptime format
pub fn convert_time_format(format: &str) -> std::result::Result<String, String> {
let mut time_format = String::new();
Expand Down
Loading

0 comments on commit bd8f097

Please sign in to comment.