-
Notifications
You must be signed in to change notification settings - Fork 19
refactor(agent): extract oracle component/service #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
669cb91
refactor(agent): move notifier into services
Reisen 9db2592
refactor(agent): move keypairs into services
Reisen 216ab59
refactor(agent): extract config module
Reisen 96af23e
refactor(agent): extract oracle component/service
Reisen 1724443
refactor(agent): extract exporter component/service
Reisen 8b6b376
chore: bump version
ali-behjati File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to mark the deprecated ones.