Skip to content

Commit

Permalink
refactor(agent): extract exporter component/service
Browse files Browse the repository at this point in the history
  • Loading branch information
Reisen committed Jun 27, 2024
1 parent 96af23e commit 1724443
Show file tree
Hide file tree
Showing 10 changed files with 1,361 additions and 139 deletions.
40 changes: 13 additions & 27 deletions src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,48 +126,34 @@ impl Agent {
let mut jhs = vec![];

// Create the Application State.
let state = Arc::new(state::State::new(self.config.state.clone()).await);
let state = Arc::new(state::State::new(&self.config).await);

// Spawn the primary network Oracle.
{
// Publisher permissions updates between oracle and exporter
let (publisher_permissions_tx, publisher_permissions_rx) =
watch::channel(<_>::default());

jhs.push(tokio::spawn(services::oracle(
self.config.primary_network.clone(),
network::Network::Primary,
state.clone(),
publisher_permissions_tx.clone(),
)));
jhs.push(tokio::spawn(services::oracle(
self.config.primary_network.clone(),
network::Network::Primary,
state.clone(),
)));

// Spawn the primary network
jhs.extend(network::spawn_network(
self.config.primary_network.clone(),
network::Network::Primary,
state.clone(),
publisher_permissions_rx.clone(),
)?);
}
jhs.push(tokio::spawn(services::exporter(
self.config.primary_network.clone(),
network::Network::Primary,
state.clone(),
)));

// Spawn the secondary network Oracle, if needed.
if let Some(config) = &self.config.secondary_network {
let (publisher_permissions_tx, publisher_permissions_rx) =
watch::channel(<_>::default());

jhs.push(tokio::spawn(services::oracle(
config.clone(),
network::Network::Secondary,
state.clone(),
publisher_permissions_tx.clone(),
)));

jhs.extend(network::spawn_network(
jhs.push(tokio::spawn(services::exporter(
config.clone(),
network::Network::Secondary,
state.clone(),
publisher_permissions_rx,
)?);
)));
}

// Create the Notifier task for the Pythd RPC.
Expand Down
2 changes: 2 additions & 0 deletions src/agent/services.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
pub mod exporter;
pub mod keypairs;
pub mod notifier;
pub mod oracle;

pub use {
exporter::exporter,
keypairs::keypairs,
notifier::notifier,
oracle::oracle,
Expand Down
Loading

0 comments on commit 1724443

Please sign in to comment.