Skip to content

Commit

Permalink
deps: replace derivative with educe (#3506)
Browse files Browse the repository at this point in the history
* deps: replace derivative with educe

* PR review
  • Loading branch information
inahga authored Nov 22, 2024
1 parent c53b874 commit 75b5d79
Show file tree
Hide file tree
Showing 36 changed files with 247 additions and 222 deletions.
51 changes: 41 additions & 10 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ console-subscriber = "0.4.1"
constcat = "0.5"
deadpool = "0.12.1"
deadpool-postgres = "0.14.0"
derivative = "2.2.0"
divviup-client = "0.4"
educe = { version = "0.6.0", default-features = false, features = ["Debug"] }
fixed = "1.27"
futures = "0.3.31"
git-version = "0.3.9"
Expand Down
2 changes: 1 addition & 1 deletion aggregator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ clap.workspace = true
console-subscriber = { workspace = true, optional = true }
deadpool = { workspace = true, features = ["rt_tokio_1"] }
deadpool-postgres = { workspace = true }
derivative.workspace = true
educe.workspace = true
fixed = { workspace = true, optional = true }
futures = { workspace = true }
hex = { workspace = true, features = ["serde"] }
Expand Down
18 changes: 9 additions & 9 deletions aggregator/src/aggregator/aggregation_job_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
use anyhow::{anyhow, Result};
use backoff::backoff::Backoff;
use bytes::Bytes;
use derivative::Derivative;
use educe::Educe;
use futures::future::BoxFuture;
use janus_aggregator_core::{
datastore::{
Expand Down Expand Up @@ -59,8 +59,8 @@ use tracing::{debug, error, info, info_span, trace_span, warn, Span};
#[cfg(test)]
mod tests;

#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Educe)]
#[educe(Debug)]
pub struct AggregationJobDriver<B> {
// Configuration.
batch_aggregation_shard_count: u64,
Expand All @@ -70,17 +70,17 @@ pub struct AggregationJobDriver<B> {
http_client: reqwest::Client,
backoff: B,

#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
aggregation_success_counter: Counter<u64>,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
aggregate_step_failure_counter: Counter<u64>,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
aggregated_report_share_dimension_histogram: Histogram<u64>,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
job_cancel_counter: Counter<u64>,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
job_retry_counter: Counter<u64>,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
http_request_duration_histogram: Histogram<f64>,
}

Expand Down
8 changes: 4 additions & 4 deletions aggregator/src/aggregator/collection_job_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::aggregator::{
use anyhow::bail;
use backoff::backoff::Backoff;
use bytes::Bytes;
use derivative::Derivative;
use educe::Educe;
use futures::future::{try_join_all, BoxFuture};
use janus_aggregator_core::{
datastore::{
Expand Down Expand Up @@ -42,13 +42,13 @@ use tokio::try_join;
use tracing::{error, info, warn};

/// Drives a collection job.
#[derive(Derivative)]
#[derivative(Debug)]
#[derive(Educe)]
#[educe(Debug)]
pub struct CollectionJobDriver<B> {
// Dependencies.
http_client: reqwest::Client,
backoff: B,
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
metrics: CollectionJobDriverMetrics,

// Configuration.
Expand Down
8 changes: 4 additions & 4 deletions aggregator/src/aggregator/key_rotator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::aggregator::Config as AggregatorConfig; // used in doccomment.
use crate::cache::HpkeKeypairCache;
use anyhow::{anyhow, Error};
use derivative::Derivative;
use educe::Educe;
use futures::{future::try_join_all, FutureExt};
use janus_aggregator_core::datastore::{
models::{HpkeKeyState, HpkeKeypair},
Expand Down Expand Up @@ -153,14 +153,14 @@ fn duration_since<C: Clock>(clock: &C, time: &Time) -> Duration {
}

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

// Data structures for intermediate state.
#[derivative(Debug = "ignore")]
#[educe(Debug(ignore))]
available_ids: Box<dyn Iterator<Item = HpkeConfigId> + Send + Sync>,
keypairs: HashMap<HpkeConfigId, HpkeKeypair>,
initially_empty: bool,
Expand Down
8 changes: 4 additions & 4 deletions aggregator/src/binaries/aggregator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::{
};
use anyhow::{anyhow, Context, Result};
use clap::Parser;
use derivative::Derivative;
use educe::Educe;
use janus_aggregator_api::{self, aggregator_api_handler};
use janus_aggregator_core::datastore::Datastore;
use janus_core::{auth_tokens::AuthenticationToken, time::RealClock, TokioRuntime};
Expand Down Expand Up @@ -239,9 +239,9 @@ impl BinaryOptions for Options {
}

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

Expand Down
8 changes: 4 additions & 4 deletions aggregator/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use crate::{metrics::MetricsConfiguration, trace::TraceConfiguration};
use backoff::{ExponentialBackoff, ExponentialBackoffBuilder};
use derivative::Derivative;
use educe::Educe;
use serde::{de::DeserializeOwned, Deserialize, Serialize};
use std::{
fmt::Debug,
Expand Down Expand Up @@ -77,12 +77,12 @@ pub trait BinaryConfig: Debug + DeserializeOwned {
}

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

/// Timeout in seconds to apply when creating, waiting for, or recycling
Expand Down
10 changes: 5 additions & 5 deletions aggregator/src/diagnostic.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
//! Writing diagnostic files to disk.
use anyhow::Context;
use derivative::Derivative;
use educe::Educe;
use janus_messages::{AggregationJobId, ReportId, TaskId};
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use std::{fs::File, path::Path, time::SystemTime};
use uuid::Uuid;

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

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

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

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

/// The ordered report metadatas from the request that attempted to mutate the aggregation job.
Expand Down
Loading

0 comments on commit 75b5d79

Please sign in to comment.