-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(agent): extract oracle component/service (#128)
* refactor(agent): move notifier into services * refactor(agent): move keypairs into services * refactor(agent): extract config module * refactor(agent): extract oracle component/service * refactor(agent): extract exporter component/service * chore: bump version --------- Co-authored-by: Ali Behjati <[email protected]>
- Loading branch information
1 parent
fee170f
commit 05ef724
Showing
20 changed files
with
2,552 additions
and
1,359 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "pyth-agent" | ||
version = "2.8.0" | ||
version = "2.9.0" | ||
edition = "2021" | ||
|
||
[[bin]] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use { | ||
super::{ | ||
metrics, | ||
pyth, | ||
services, | ||
solana::network, | ||
state, | ||
}, | ||
anyhow::Result, | ||
config as config_rs, | ||
config_rs::{ | ||
Environment, | ||
File, | ||
}, | ||
serde::Deserialize, | ||
std::path::Path, | ||
}; | ||
|
||
/// Configuration for all components of the Agent | ||
#[derive(Deserialize, Debug)] | ||
pub struct Config { | ||
#[serde(default)] | ||
pub channel_capacities: ChannelCapacities, | ||
pub primary_network: network::Config, | ||
pub secondary_network: Option<network::Config>, | ||
#[serde(default)] | ||
#[serde(rename = "pythd_adapter")] | ||
pub state: state::Config, | ||
#[serde(default)] | ||
pub pythd_api_server: pyth::rpc::Config, | ||
#[serde(default)] | ||
pub metrics_server: metrics::Config, | ||
#[serde(default)] | ||
pub remote_keypair_loader: services::keypairs::Config, | ||
} | ||
|
||
impl Config { | ||
pub fn new(config_file: impl AsRef<Path>) -> Result<Self> { | ||
// Build a new configuration object, allowing the default values to be | ||
// overridden by those in the config_file or "AGENT_"-prefixed environment | ||
// variables. | ||
config_rs::Config::builder() | ||
.add_source(File::from(config_file.as_ref())) | ||
.add_source(Environment::with_prefix("agent")) | ||
.build()? | ||
.try_deserialize() | ||
.map_err(|e| e.into()) | ||
} | ||
} | ||
|
||
/// Capacities of the channels top-level components use to communicate | ||
#[derive(Deserialize, Debug)] | ||
pub struct ChannelCapacities { | ||
/// Capacity of the channel used to broadcast shutdown events to all components | ||
pub shutdown: usize, | ||
/// Capacity of the channel used to send updates from the primary Oracle to the Global Store | ||
pub primary_oracle_updates: usize, | ||
/// Capacity of the channel used to send updates from the secondary Oracle to the Global Store | ||
pub secondary_oracle_updates: usize, | ||
/// Capacity of the channel the Pythd API Adapter uses to send lookup requests to the Global Store | ||
pub global_store_lookup: usize, | ||
/// Capacity of the channel the Pythd API Adapter uses to communicate with the Local Store | ||
pub local_store_lookup: usize, | ||
/// Capacity of the channel on which the Local Store receives messages | ||
pub local_store: usize, | ||
/// Capacity of the channel on which the Pythd API Adapter receives messages | ||
pub pythd_adapter: usize, | ||
/// Capacity of the slog logging channel. Adjust this value if you see complaints about channel capacity from slog | ||
pub logger_buffer: usize, | ||
} | ||
|
||
impl Default for ChannelCapacities { | ||
fn default() -> Self { | ||
Self { | ||
shutdown: 10000, | ||
primary_oracle_updates: 10000, | ||
secondary_oracle_updates: 10000, | ||
global_store_lookup: 10000, | ||
local_store_lookup: 10000, | ||
local_store: 10000, | ||
pythd_adapter: 10000, | ||
logger_buffer: 10000, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pub mod exporter; | ||
pub mod keypairs; | ||
pub mod notifier; | ||
pub mod oracle; | ||
|
||
pub use { | ||
exporter::exporter, | ||
keypairs::keypairs, | ||
notifier::notifier, | ||
oracle::oracle, | ||
}; |
Oops, something went wrong.