From 69f2e2164e16ba7e93bad80c9889285e728bae49 Mon Sep 17 00:00:00 2001 From: Brandon Thomas Date: Sat, 8 May 2021 03:49:10 -0400 Subject: [PATCH] move clients to module --- build.rs | 2 +- src/clients/mod.rs | 2 ++ src/{ => clients}/redis_client.rs | 0 src/{ => clients}/redis_subscriber.rs | 0 src/handlers/coordinate_and_geocode_handler.rs | 8 ++++---- src/main.rs | 9 ++++----- 6 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 src/clients/mod.rs rename src/{ => clients}/redis_client.rs (100%) rename src/{ => clients}/redis_subscriber.rs (100%) diff --git a/build.rs b/build.rs index 189cfabd38..7822e529f0 100644 --- a/build.rs +++ b/build.rs @@ -5,11 +5,11 @@ use std::env; fn main() -> anyhow::Result<()> { // NB: Control prost output dir with env var + // Typically these land in `target/`, but I want to source control these. env::set_var("OUT_DIR", "src/proto_codegen"); prost_build::compile_protos( &[ - // TODO: This needs to respect glob "protos/storyteller-protos/protos/pubsub-events/pubsub-events.proto", "protos/storyteller-protos/protos/unreal/unreal.proto", ], diff --git a/src/clients/mod.rs b/src/clients/mod.rs new file mode 100644 index 0000000000..0fae7044b4 --- /dev/null +++ b/src/clients/mod.rs @@ -0,0 +1,2 @@ +pub mod redis_client; +pub mod redis_subscriber; diff --git a/src/redis_client.rs b/src/clients/redis_client.rs similarity index 100% rename from src/redis_client.rs rename to src/clients/redis_client.rs diff --git a/src/redis_subscriber.rs b/src/clients/redis_subscriber.rs similarity index 100% rename from src/redis_subscriber.rs rename to src/clients/redis_subscriber.rs diff --git a/src/handlers/coordinate_and_geocode_handler.rs b/src/handlers/coordinate_and_geocode_handler.rs index 24aaa1405c..67b2b4c5e5 100644 --- a/src/handlers/coordinate_and_geocode_handler.rs +++ b/src/handlers/coordinate_and_geocode_handler.rs @@ -1,15 +1,15 @@ +use crate::AnyhowResult; +use crate::clients::redis_client::RedisClient; use crate::dispatcher::TextCommandHandler; +use crate::inbound_proto_utils::{InboundEvent, InboundEventSource}; use crate::protos::protos; -use crate::redis_client::RedisClient; +use crate::text_chat_parsers::first_pass_command_parser::FirstPassParsedCommand; use futures::executor::block_on; use lazy_static::lazy_static; use log::{info, warn}; use prost::Message; use regex::Regex; use std::sync::{RwLock, Arc, Mutex}; -use crate::text_chat_parsers::first_pass_command_parser::FirstPassParsedCommand; -use crate::inbound_proto_utils::{InboundEvent, InboundEventSource}; -use crate::AnyhowResult; // TODO: maybe separate text command handling and data source concerns // like this? Though maybe it's too early to optimize this. diff --git a/src/main.rs b/src/main.rs index 950308f689..9425457f7b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,13 +3,12 @@ extern crate lazy_static; #[macro_use] extern crate serde_derive; +mod clients; mod dispatcher; mod handlers; mod inbound_proto_utils; mod outbound_proto_utils; mod protos; -mod redis_client; -mod redis_subscriber; mod secrets; mod text_chat_parsers; @@ -21,11 +20,11 @@ use redis::{AsyncCommands, RedisResult}; use std::thread; use std::time::Duration; -use crate::secrets::Secrets; -use crate::redis_client::RedisClient; -use crate::redis_subscriber::RedisSubscribeClient; +use crate::clients::redis_client::RedisClient; +use crate::clients::redis_subscriber::RedisSubscribeClient; use crate::dispatcher::Dispatcher; use crate::handlers::coordinate_and_geocode_handler::CoordinateAndGeocodeHandler; +use crate::secrets::Secrets; use std::sync::{Arc, Mutex}; pub type AnyhowResult = anyhow::Result;