Skip to content

Commit 9aa9923

Browse files
committed
Remove once_cell dependency
1 parent cfb53e9 commit 9aa9923

File tree

87 files changed

+355
-419
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+355
-419
lines changed

quickwit/CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ When the client is unlikely to match on an error, you can rely on the crate leve
8787
### Design Patterns
8888
- **Trait-based services**: `SearchService`, `MetastoreService`, etc. — enables mocking and multiple implementations
8989
- **Feature gates**: Cloud backends (`azure`, `gcs`), message sources (`kafka`, `kinesis`, `pulsar`, `sqs`, `gcp-pubsub`), `postgres` metastore, `multilang` tokenizers
90-
- **Metrics**: `once_cell::sync::Lazy` statics with `quickwit_common::metrics::*` factories
90+
- **Metrics**: `std::sync::LazyLock` statics with `quickwit_common::metrics::*` factories
9191

9292
### Key Dependencies
9393
- **Tantivy**: Search engine library (custom fork)

quickwit/Cargo.lock

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

quickwit/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,6 @@ mrecordlog = { git = "https://github.com/quickwit-oss/mrecordlog", rev = "306c0a
162162
new_string_template = "1.5"
163163
nom = "8.0"
164164
numfmt = "1.2"
165-
once_cell = "1"
166165
oneshot = "0.1"
167166
openssl = { version = "0.10", default-features = false }
168167
openssl-probe = "0.1"

quickwit/quickwit-actors/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ anyhow = { workspace = true }
1515
async-trait = { workspace = true }
1616
flume = { workspace = true }
1717
futures = { workspace = true }
18-
once_cell = { workspace = true }
1918
serde = { workspace = true }
2019
serde_json = { workspace = true }
2120
sync_wrapper = { workspace = true }

quickwit/quickwit-actors/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
2525
use std::fmt;
2626
use std::num::NonZeroU64;
27+
use std::sync::LazyLock;
2728

28-
use once_cell::sync::Lazy;
2929
use tokio::time::Duration;
3030
mod actor;
3131
mod actor_context;
@@ -70,7 +70,7 @@ pub use self::supervisor::{Supervisor, SupervisorMetrics, SupervisorState};
7070
/// If an actor does not advertise a progress within an interval of duration `HEARTBEAT`,
7171
/// its supervisor will consider it as blocked and will proceed to kill it, as well
7272
/// as all of the actors all the actors that share the killswitch.
73-
pub static HEARTBEAT: Lazy<Duration> = Lazy::new(heartbeat_from_env_or_default);
73+
pub static HEARTBEAT: LazyLock<Duration> = LazyLock::new(heartbeat_from_env_or_default);
7474

7575
/// Returns the actor's heartbeat duration:
7676
/// - Derived from `QW_ACTOR_HEARTBEAT_SECS` if set and valid.

quickwit/quickwit-actors/src/mailbox.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::any::Any;
1616
use std::convert::Infallible;
1717
use std::fmt;
1818
use std::sync::atomic::{AtomicUsize, Ordering};
19-
use std::sync::{Arc, OnceLock, Weak};
19+
use std::sync::{Arc, LazyLock, Weak};
2020
use std::time::Instant;
2121

2222
use quickwit_common::metrics::{GaugeGuard, IntCounter, IntGauge};
@@ -386,16 +386,15 @@ impl<A: Actor> Inbox<A> {
386386
}
387387

388388
fn get_actor_inboxes_count_gauge_guard() -> GaugeGuard<'static> {
389-
static INBOX_GAUGE: std::sync::OnceLock<IntGauge> = OnceLock::new();
390-
let gauge = INBOX_GAUGE.get_or_init(|| {
389+
static INBOX_GAUGE: LazyLock<IntGauge> = LazyLock::new(|| {
391390
quickwit_common::metrics::new_gauge(
392391
"inboxes_count",
393392
"overall count of actors",
394393
"actor",
395394
&[],
396395
)
397396
});
398-
let mut gauge_guard = GaugeGuard::from_gauge(gauge);
397+
let mut gauge_guard = GaugeGuard::from_gauge(&INBOX_GAUGE);
399398
gauge_guard.add(1);
400399
gauge_guard
401400
}

quickwit/quickwit-cli/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ humantime = { workspace = true }
3434
indicatif = { workspace = true }
3535
itertools = { workspace = true }
3636
numfmt = { workspace = true }
37-
once_cell = { workspace = true }
3837
openssl-probe = { workspace = true, optional = true }
3938
opentelemetry = { workspace = true }
4039
opentelemetry-appender-tracing = { workspace = true }

quickwit/quickwit-cli/src/lib.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
use std::collections::HashSet;
1818
use std::str::FromStr;
19-
use std::sync::OnceLock;
19+
use std::sync::LazyLock;
2020

2121
use anyhow::Context;
2222
use clap::{Arg, ArgMatches, arg};
@@ -109,13 +109,13 @@ fn client_args() -> Vec<Arg> {
109109
}
110110

111111
pub fn install_default_crypto_ring_provider() {
112-
static CALL_ONLY_ONCE: OnceLock<Result<(), ()>> = OnceLock::new();
112+
static CALL_ONLY_ONCE: LazyLock<Result<(), ()>> = LazyLock::new(|| {
113+
rustls::crypto::ring::default_provider()
114+
.install_default()
115+
.map_err(|_| ())
116+
});
113117
CALL_ONLY_ONCE
114-
.get_or_init(|| {
115-
rustls::crypto::ring::default_provider()
116-
.install_default()
117-
.map_err(|_| ())
118-
})
118+
.as_ref()
119119
.expect("rustls crypto ring default provider installation should not fail");
120120
}
121121

@@ -348,16 +348,16 @@ fn prompt_confirmation(prompt: &str, default: bool) -> bool {
348348
}
349349

350350
pub mod busy_detector {
351+
use std::sync::LazyLock;
351352
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
352353
use std::time::Instant;
353354

354-
use once_cell::sync::Lazy;
355355
use tracing::debug;
356356

357357
use crate::metrics::CLI_METRICS;
358358

359359
// we need that time reference to use an atomic and not a mutex for LAST_UNPARK
360-
static TIME_REF: Lazy<Instant> = Lazy::new(Instant::now);
360+
static TIME_REF: LazyLock<Instant> = LazyLock::new(Instant::now);
361361
static ENABLED: AtomicBool = AtomicBool::new(false);
362362

363363
const ALLOWED_DELAY_MICROS: u64 = 5000;

quickwit/quickwit-cli/src/metrics.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
use once_cell::sync::Lazy;
15+
use std::sync::LazyLock;
16+
1617
use quickwit_common::metrics::{HistogramVec, new_histogram_vec};
1718

1819
pub struct CliMetrics {
@@ -35,4 +36,4 @@ impl Default for CliMetrics {
3536
}
3637

3738
/// Serve counters exposes a bunch a set of metrics about the request received to quickwit.
38-
pub static CLI_METRICS: Lazy<CliMetrics> = Lazy::new(CliMetrics::default);
39+
pub static CLI_METRICS: LazyLock<CliMetrics> = LazyLock::new(CliMetrics::default);

quickwit/quickwit-cluster/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ bytesize = { workspace = true }
1717
chitchat = { workspace = true }
1818
futures = { workspace = true }
1919
itertools = { workspace = true }
20-
once_cell = { workspace = true }
2120
pin-project = { workspace = true }
2221
rand = { workspace = true }
2322
serde = { workspace = true }

0 commit comments

Comments
 (0)