From edf3f08e8167c17fb69a7767753ee07bc59999ee Mon Sep 17 00:00:00 2001 From: Markus Westerlind Date: Wed, 29 Jun 2022 13:27:43 +0200 Subject: [PATCH] refactor: Replace all uses of lazy_static with once_cell Went through and remove all lazy_static uses with once_cell (while waiting for the project to compile). There are still dependencies using lazy_static so it is still in the crate graph but at least there isn't an explicit dependency on it (and it is easier to update to `std::lazy::Lazy` once that is stable). --- Cargo.lock | 7 ++- ingester/Cargo.toml | 2 +- ingester/src/stream_handler/handler.rs | 7 ++- .../stream_handler/sink_instrumentation.rs | 15 +++--- query_functions/Cargo.toml | 2 +- query_functions/src/regex.rs | 49 +++++++++---------- query_functions/src/registry.rs | 7 ++- query_functions/src/window.rs | 45 +++++++++-------- router/Cargo.toml | 2 +- router/benches/schema_validator.rs | 5 +- router/src/dml_handlers/schema_validation.rs | 5 +- test_helpers_end_to_end/Cargo.toml | 1 - test_helpers_end_to_end/src/mini_cluster.rs | 5 +- 13 files changed, 71 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0a05db081c..7101579b1a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2206,12 +2206,12 @@ dependencies = [ "iox_catalog", "iox_query", "iox_time", - "lazy_static", "metric", "mutable_batch", "mutable_batch_lp", "object_store", "observability_deps", + "once_cell", "parking_lot 0.12.1", "parquet_file", "paste", @@ -3919,8 +3919,8 @@ dependencies = [ "datafusion 0.1.0", "datafusion_util", "itertools", - "lazy_static", "observability_deps", + "once_cell", "regex", "regex-syntax", "schema", @@ -4242,13 +4242,13 @@ dependencies = [ "hyper", "iox_catalog", "iox_time", - "lazy_static", "metric", "mutable_batch", "mutable_batch_lp", "mutable_batch_pb", "object_store", "observability_deps", + "once_cell", "parking_lot 0.12.1", "paste", "predicate", @@ -5243,7 +5243,6 @@ dependencies = [ "http", "hyper", "influxdb_iox_client", - "lazy_static", "nix 0.24.1", "observability_deps", "once_cell", diff --git a/ingester/Cargo.toml b/ingester/Cargo.toml index 9bee010215..8e25bcb91d 100644 --- a/ingester/Cargo.toml +++ b/ingester/Cargo.toml @@ -49,7 +49,7 @@ trace = { path = "../trace" } [dev-dependencies] assert_matches = "1.5.0" bitflags = {version = "1.3.2"} -lazy_static = "1.4.0" +once_cell = "1" paste = "1.0.7" test_helpers = { path = "../test_helpers", features = ["future_timeout"] } tokio-stream = {version = "0.1.9", default_features = false } diff --git a/ingester/src/stream_handler/handler.rs b/ingester/src/stream_handler/handler.rs index 83c09f45c6..2cc9779d5a 100644 --- a/ingester/src/stream_handler/handler.rs +++ b/ingester/src/stream_handler/handler.rs @@ -443,16 +443,15 @@ mod tests { use iox_time::{SystemProvider, Time}; use metric::Metric; use mutable_batch_lp::lines_to_batches; + use once_cell::sync::Lazy; use std::sync::Arc; use test_helpers::timeout::FutureTimeout; use tokio::sync::{mpsc, oneshot}; use tokio_stream::wrappers::ReceiverStream; use write_buffer::core::WriteBufferError; - lazy_static::lazy_static! { - static ref TEST_TIME: Time = SystemProvider::default().now(); - static ref TEST_KAFKA_PARTITION: KafkaPartition = KafkaPartition::new(42); - } + static TEST_TIME: Lazy