Skip to content

Commit

Permalink
Migrate the rest to the new config
Browse files Browse the repository at this point in the history
  • Loading branch information
dasJ committed Dec 30, 2024
1 parent a909293 commit f9cf292
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion ofborg/src/bin/build-faker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let arg = env::args().nth(1).expect("usage: build-faker <config>");
let cfg = config::load(arg.as_ref());

let conn = easylapin::from_config(&cfg.rabbitmq)?;
let conn = easylapin::from_config(&cfg.builder.unwrap().rabbitmq)?;
let mut chan = task::block_on(conn.create_channel())?;

let repo_msg = Repo {
Expand Down
14 changes: 11 additions & 3 deletions ofborg/src/bin/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,26 @@ use std::thread;

use async_std::task;
use hyper::server::{Request, Response, Server};
use tracing::info;
use tracing::{error, info};

use ofborg::easyamqp::{ChannelExt, ConsumerExt};
use ofborg::{config, easyamqp, easylapin, stats, tasks};

fn main() -> Result<(), Box<dyn Error>> {
ofborg::setup_log();

let arg = env::args().nth(1).expect("usage: stats <config>");
let arg = env::args()
.nth(1)
.unwrap_or_else(|| panic!("usage: {} <config>", std::env::args().next().unwrap()));
let cfg = config::load(arg.as_ref());

let conn = easylapin::from_config(&cfg.rabbitmq)?;
let Some(stats_cfg) = config::load(arg.as_ref()).stats else {
error!("No stats configuration found!");
panic!();
};

let conn = easylapin::from_config(&stats_cfg.rabbitmq)?;

let mut chan = task::block_on(conn.create_channel())?;

let events = stats::RabbitMq::from_lapin(&cfg.whoami(), task::block_on(conn.create_channel())?);
Expand Down
12 changes: 11 additions & 1 deletion ofborg/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ pub struct Config {
pub builder: Option<Builder>,
/// Configuration for the log message collector
pub log_message_collector: Option<LogMessageCollector>,
/// Configuration for the stats server
pub stats: Option<Stats>,
pub runner: RunnerConfig,
pub checkout: CheckoutConfig,
pub nix: NixConfig,
pub rabbitmq: RabbitMqConfig,
pub github_app: Option<GithubAppConfig>,
}

Expand Down Expand Up @@ -120,8 +121,17 @@ pub struct LogMessageCollector {
pub logs_path: String,
}

/// Configuration for the stats exporter
#[derive(Serialize, Deserialize, Debug)]
#[serde(deny_unknown_fields)]
pub struct Stats {
/// RabbitMQ broker to connect to
pub rabbitmq: RabbitMqConfig,
}

/// Configures the connection to a RabbitMQ instance
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(deny_unknown_fields)]
pub struct RabbitMqConfig {
/// Whether or not to use SSL
pub ssl: bool,
Expand Down

0 comments on commit f9cf292

Please sign in to comment.