Skip to content

Commit 09eb015

Browse files
Return an Arc in the Metrics structs start method
1 parent deaa77a commit 09eb015

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

aggregation_mode/gateway/src/http.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use std::{
22
str::FromStr,
3+
sync::Arc,
34
time::{Instant, SystemTime, UNIX_EPOCH},
45
};
56

@@ -34,7 +35,7 @@ pub struct GatewayServer {
3435
db: Db,
3536
config: Config,
3637
network: Network,
37-
metrics: GatewayMetrics,
38+
metrics: Arc<GatewayMetrics>,
3839
}
3940

4041
impl GatewayServer {

aggregation_mode/gateway/src/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct GatewayMetrics {
99
}
1010

1111
impl GatewayMetrics {
12-
pub fn start(metrics_port: u16) -> Result<Self, prometheus::Error> {
12+
pub fn start(metrics_port: u16) -> Result<Arc<Self>, prometheus::Error> {
1313
let registry = Registry::new();
1414

1515
let time_elapsed_db_post = Histogram::with_opts(histogram_opts!(
@@ -40,7 +40,7 @@ impl GatewayMetrics {
4040
.await;
4141
});
4242

43-
Ok(Arc::try_unwrap(metrics).unwrap_or_else(|arc| (*arc).clone()))
43+
Ok(metrics)
4444
}
4545

4646
async fn metrics_handler(metrics: web::Data<Arc<GatewayMetrics>>) -> impl Responder {

aggregation_mode/payments_poller/src/metrics.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pub struct PaymentsPollerMetrics {
99
}
1010

1111
impl PaymentsPollerMetrics {
12-
pub fn start(metrics_port: u16) -> Result<Self, prometheus::Error> {
12+
pub fn start(metrics_port: u16) -> Result<Arc<Self>, prometheus::Error> {
1313
let registry = Registry::new();
1414

1515
let last_processed_block = Gauge::with_opts(opts!(
@@ -43,7 +43,7 @@ impl PaymentsPollerMetrics {
4343
.await;
4444
});
4545

46-
Ok(Arc::try_unwrap(metrics).unwrap_or_else(|arc| (*arc).clone()))
46+
Ok(metrics)
4747
}
4848

4949
async fn metrics_handler(metrics: web::Data<Arc<PaymentsPollerMetrics>>) -> impl Responder {

aggregation_mode/payments_poller/src/payments.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::str::FromStr;
1+
use std::{str::FromStr, sync::Arc};
22

33
use crate::{
44
config::Config,
@@ -22,7 +22,7 @@ pub struct PaymentsPoller {
2222
proof_aggregation_service: AggregationModePaymentServiceContract,
2323
rpc_provider: RpcProvider,
2424
config: Config,
25-
metrics: PaymentsPollerMetrics,
25+
metrics: Arc<PaymentsPollerMetrics>,
2626
}
2727

2828
impl PaymentsPoller {

0 commit comments

Comments
 (0)