Update how RPCs are handled

The processor now takes three vars and joins them itself. message-queue uses a
single argument, with defaults, as it's a service we control.
This commit is contained in:
Luke Parker
2023-07-21 14:00:03 -04:00
parent 641077a089
commit 624fb2781d
6 changed files with 29 additions and 7 deletions

View File

@@ -26,8 +26,17 @@ pub struct MessageQueue {
}
impl MessageQueue {
pub fn new(service: Service) -> MessageQueue {
let url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified");
pub fn from_env(service: Service) -> MessageQueue {
// Allow MESSAGE_QUEUE_RPC to either be a full URL or just a hostname
// While we could stitch together multiple env variables, our control over this service makes
// this fine
let mut url = env::var("MESSAGE_QUEUE_RPC").expect("message-queue RPC wasn't specified");
if !url.contains(':') {
url += ":2287";
}
if !url.starts_with("http://") {
url = "http://".to_string() + &url;
}
let priv_key: Zeroizing<<Ristretto as Ciphersuite>::F> = {
let key_str =

View File

@@ -110,7 +110,7 @@ fn ack_message(service: Service, id: u64, sig: SchnorrSignature<Ristretto>) {
#[tokio::main]
async fn main() {
if std::env::var("RUST_LOG").is_err() {
std::env::set_var("RUST_LOG", "info");
std::env::set_var("RUST_LOG", serai_env::var("RUST_LOG").unwrap_or_else(|| "info".to_string()));
}
env_logger::init();