Skip to content

Commit 75b5d79

Browse files
authored
deps: replace derivative with educe (#3506)
* deps: replace derivative with educe * PR review
1 parent c53b874 commit 75b5d79

36 files changed

+247
-222
lines changed

Cargo.lock

+41-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ console-subscriber = "0.4.1"
4040
constcat = "0.5"
4141
deadpool = "0.12.1"
4242
deadpool-postgres = "0.14.0"
43-
derivative = "2.2.0"
4443
divviup-client = "0.4"
44+
educe = { version = "0.6.0", default-features = false, features = ["Debug"] }
4545
fixed = "1.27"
4646
futures = "0.3.31"
4747
git-version = "0.3.9"

aggregator/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ clap.workspace = true
4848
console-subscriber = { workspace = true, optional = true }
4949
deadpool = { workspace = true, features = ["rt_tokio_1"] }
5050
deadpool-postgres = { workspace = true }
51-
derivative.workspace = true
51+
educe.workspace = true
5252
fixed = { workspace = true, optional = true }
5353
futures = { workspace = true }
5454
hex = { workspace = true, features = ["serde"] }

aggregator/src/aggregator/aggregation_job_driver.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{
1616
use anyhow::{anyhow, Result};
1717
use backoff::backoff::Backoff;
1818
use bytes::Bytes;
19-
use derivative::Derivative;
19+
use educe::Educe;
2020
use futures::future::BoxFuture;
2121
use janus_aggregator_core::{
2222
datastore::{
@@ -59,8 +59,8 @@ use tracing::{debug, error, info, info_span, trace_span, warn, Span};
5959
#[cfg(test)]
6060
mod tests;
6161

62-
#[derive(Derivative)]
63-
#[derivative(Debug)]
62+
#[derive(Educe)]
63+
#[educe(Debug)]
6464
pub struct AggregationJobDriver<B> {
6565
// Configuration.
6666
batch_aggregation_shard_count: u64,
@@ -70,17 +70,17 @@ pub struct AggregationJobDriver<B> {
7070
http_client: reqwest::Client,
7171
backoff: B,
7272

73-
#[derivative(Debug = "ignore")]
73+
#[educe(Debug(ignore))]
7474
aggregation_success_counter: Counter<u64>,
75-
#[derivative(Debug = "ignore")]
75+
#[educe(Debug(ignore))]
7676
aggregate_step_failure_counter: Counter<u64>,
77-
#[derivative(Debug = "ignore")]
77+
#[educe(Debug(ignore))]
7878
aggregated_report_share_dimension_histogram: Histogram<u64>,
79-
#[derivative(Debug = "ignore")]
79+
#[educe(Debug(ignore))]
8080
job_cancel_counter: Counter<u64>,
81-
#[derivative(Debug = "ignore")]
81+
#[educe(Debug(ignore))]
8282
job_retry_counter: Counter<u64>,
83-
#[derivative(Debug = "ignore")]
83+
#[educe(Debug(ignore))]
8484
http_request_duration_histogram: Histogram<f64>,
8585
}
8686

aggregator/src/aggregator/collection_job_driver.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::aggregator::{
88
use anyhow::bail;
99
use backoff::backoff::Backoff;
1010
use bytes::Bytes;
11-
use derivative::Derivative;
11+
use educe::Educe;
1212
use futures::future::{try_join_all, BoxFuture};
1313
use janus_aggregator_core::{
1414
datastore::{
@@ -42,13 +42,13 @@ use tokio::try_join;
4242
use tracing::{error, info, warn};
4343

4444
/// Drives a collection job.
45-
#[derive(Derivative)]
46-
#[derivative(Debug)]
45+
#[derive(Educe)]
46+
#[educe(Debug)]
4747
pub struct CollectionJobDriver<B> {
4848
// Dependencies.
4949
http_client: reqwest::Client,
5050
backoff: B,
51-
#[derivative(Debug = "ignore")]
51+
#[educe(Debug(ignore))]
5252
metrics: CollectionJobDriverMetrics,
5353

5454
// Configuration.

aggregator/src/aggregator/key_rotator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use crate::aggregator::Config as AggregatorConfig; // used in doccomment.
33
use crate::cache::HpkeKeypairCache;
44
use anyhow::{anyhow, Error};
5-
use derivative::Derivative;
5+
use educe::Educe;
66
use futures::{future::try_join_all, FutureExt};
77
use janus_aggregator_core::datastore::{
88
models::{HpkeKeyState, HpkeKeypair},
@@ -153,14 +153,14 @@ fn duration_since<C: Clock>(clock: &C, time: &Time) -> Duration {
153153
}
154154

155155
/// In-memory representation of the `hpke_keys` table.
156-
#[derive(Derivative)]
157-
#[derivative(Debug)]
156+
#[derive(Educe)]
157+
#[educe(Debug)]
158158
struct HpkeKeyRotator<'a, C: Clock> {
159159
clock: C,
160160
config: &'a HpkeKeyRotatorConfig,
161161

162162
// Data structures for intermediate state.
163-
#[derivative(Debug = "ignore")]
163+
#[educe(Debug(ignore))]
164164
available_ids: Box<dyn Iterator<Item = HpkeConfigId> + Send + Sync>,
165165
keypairs: HashMap<HpkeConfigId, HpkeKeypair>,
166166
initially_empty: bool,

aggregator/src/binaries/aggregator.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::{
1313
};
1414
use anyhow::{anyhow, Context, Result};
1515
use clap::Parser;
16-
use derivative::Derivative;
16+
use educe::Educe;
1717
use janus_aggregator_api::{self, aggregator_api_handler};
1818
use janus_aggregator_core::datastore::Datastore;
1919
use janus_core::{auth_tokens::AuthenticationToken, time::RealClock, TokioRuntime};
@@ -239,9 +239,9 @@ impl BinaryOptions for Options {
239239
}
240240

241241
/// Options for serving the aggregator API.
242-
#[derive(Clone, Derivative, PartialEq, Eq, Serialize, Deserialize)]
242+
#[derive(Clone, Educe, PartialEq, Eq, Serialize, Deserialize)]
243243
#[serde(deny_unknown_fields)]
244-
#[derivative(Debug)]
244+
#[educe(Debug)]
245245
pub struct AggregatorApi {
246246
/// Address on which this server should listen for connections to the Janus aggregator API
247247
/// and serve its API endpoints, independently from the address on which the DAP API is
@@ -255,7 +255,7 @@ pub struct AggregatorApi {
255255
pub path_prefix: Option<String>,
256256
/// Resource location at which the DAP service managed by this aggregator api can be found
257257
/// on the public internet. Required.
258-
#[derivative(Debug(format_with = "std::fmt::Display::fmt"))]
258+
#[educe(Debug(method(std::fmt::Display::fmt)))]
259259
pub public_dap_url: Url,
260260
}
261261

aggregator/src/config.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::{metrics::MetricsConfiguration, trace::TraceConfiguration};
44
use backoff::{ExponentialBackoff, ExponentialBackoffBuilder};
5-
use derivative::Derivative;
5+
use educe::Educe;
66
use serde::{de::DeserializeOwned, Deserialize, Serialize};
77
use std::{
88
fmt::Debug,
@@ -77,12 +77,12 @@ pub trait BinaryConfig: Debug + DeserializeOwned {
7777
}
7878

7979
/// Configuration for a Janus server using a database.
80-
#[derive(Clone, Derivative, PartialEq, Eq, Serialize, Deserialize)]
81-
#[derivative(Debug)]
80+
#[derive(Clone, Educe, PartialEq, Eq, Serialize, Deserialize)]
81+
#[educe(Debug)]
8282
#[serde(deny_unknown_fields)]
8383
pub struct DbConfig {
8484
/// URL at which to connect to the database.
85-
#[derivative(Debug(format_with = "format_database_url"))]
85+
#[educe(Debug(method(format_database_url)))]
8686
pub url: Url,
8787

8888
/// Timeout in seconds to apply when creating, waiting for, or recycling

aggregator/src/diagnostic.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
//! Writing diagnostic files to disk.
22
33
use anyhow::Context;
4-
use derivative::Derivative;
4+
use educe::Educe;
55
use janus_messages::{AggregationJobId, ReportId, TaskId};
66
use serde::{Deserialize, Deserializer, Serialize, Serializer};
77
use std::{fs::File, path::Path, time::SystemTime};
88
use uuid::Uuid;
99

1010
/// Represents an illegal attempt to mutate an aggregation job.
11-
#[derive(Derivative, Clone, Serialize, Deserialize)]
12-
#[derivative(Debug)]
11+
#[derive(Educe, Clone, Serialize, Deserialize)]
12+
#[educe(Debug)]
1313
pub struct AggregationJobInitForbiddenMutationEvent {
1414
/// The ID of the task.
1515
#[serde(with = "serialize_task_id")]
@@ -21,7 +21,7 @@ pub struct AggregationJobInitForbiddenMutationEvent {
2121

2222
/// The SHA-256 of the request that created the aggregation job.
2323
#[serde(with = "serialize_hash_option")]
24-
#[derivative(Debug(format_with = "fmt_hash_option"))]
24+
#[educe(Debug(method(fmt_hash_option)))]
2525
pub original_request_hash: Option<[u8; 32]>,
2626

2727
/// The ordered report metadatas from the request that created the aggregation job.
@@ -36,7 +36,7 @@ pub struct AggregationJobInitForbiddenMutationEvent {
3636

3737
/// The SHA-256 of the request that attempted to mutate the aggregation job.
3838
#[serde(with = "serialize_hash_option")]
39-
#[derivative(Debug(format_with = "fmt_hash_option"))]
39+
#[educe(Debug(method(fmt_hash_option)))]
4040
pub mutating_request_hash: Option<[u8; 32]>,
4141

4242
/// The ordered report metadatas from the request that attempted to mutate the aggregation job.

0 commit comments

Comments
 (0)