Skip to content

Commit 25dce73

Browse files
authored
chore: have multiple builders listen to channel for MeterBundleResponse (#70)
1 parent a21ee49 commit 25dce73

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TIPS_INGRESS_METRICS_ADDR=0.0.0.0:9002
1414
TIPS_INGRESS_BLOCK_TIME_MILLISECONDS=2000
1515
TIPS_INGRESS_METER_BUNDLE_TIMEOUT_MS=2000
1616
TIPS_INGRESS_MAX_BUFFERED_METER_BUNDLE_RESPONSES=100
17-
TIPS_INGRESS_BUILDER_RPC=http://localhost:2222
17+
TIPS_INGRESS_BUILDER_RPCS=http://localhost:2222
1818

1919
# Audit service configuration
2020
TIPS_AUDIT_KAFKA_PROPERTIES_FILE=/app/docker/audit-kafka-properties

crates/ingress-rpc/src/bin/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ async fn main() -> anyhow::Result<()> {
6464
let (audit_tx, audit_rx) = mpsc::unbounded_channel::<BundleEvent>();
6565
connect_audit_to_publisher(audit_rx, audit_publisher);
6666

67-
// TODO: when we have multiple builders we can make `builder_rx` mutable and do `.subscribe()` to have multiple consumers
68-
// of this channel.
69-
let (builder_tx, builder_rx) =
67+
let (builder_tx, _) =
7068
broadcast::channel::<MeterBundleResponse>(config.max_buffered_meter_bundle_responses);
71-
connect_ingress_to_builder(builder_rx, config.builder_rpc);
69+
config.builder_rpcs.iter().for_each(|builder_rpc| {
70+
let builder_rx = builder_tx.subscribe();
71+
connect_ingress_to_builder(builder_rx, builder_rpc.clone());
72+
});
7273

7374
let service = IngressService::new(
7475
provider,

crates/ingress-rpc/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ pub struct Config {
122122
)]
123123
pub meter_bundle_timeout_ms: u64,
124124

125-
/// URL of the builder RPC service for setting metering information
126-
#[arg(long, env = "TIPS_INGRESS_BUILDER_RPC")]
127-
pub builder_rpc: Url,
125+
/// URLs of the builder RPC service for setting metering information
126+
#[arg(long, env = "TIPS_INGRESS_BUILDER_RPCS")]
127+
pub builder_rpcs: Vec<Url>,
128128

129129
/// Maximum number of `MeterBundleResponse`s to buffer in memory
130130
#[arg(

0 commit comments

Comments
 (0)