diff --git a/.github/workflows/check-lint-test.yaml b/.github/workflows/check-lint-test.yaml index cf2393a..896fb87 100644 --- a/.github/workflows/check-lint-test.yaml +++ b/.github/workflows/check-lint-test.yaml @@ -26,7 +26,6 @@ jobs: name: Test Suite runs-on: ubuntu-latest - # Source: https://docs.github.com/en/actions/using-containerized-services/creating-postgresql-service-containers services: redis: image: redis diff --git a/src/lib.rs b/src/lib.rs index a9ef65b..857d6c9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,14 +1,20 @@ mod block_submission_key; mod block_submissions; -pub mod consumer; +mod consumer; pub mod env; -pub mod health; +mod health; pub mod log; -pub mod server; -pub mod storage; +mod server; +mod storage; pub use block_submission_key::BlockSubmissionKey; pub use block_submissions::BlockSubmission; +pub use consumer::run_consume_submissions_thread; +pub use health::RedisConsumerHealth; +pub use health::RedisHealth; +pub use server::run_server_thread; +pub use server::AppState; +pub use storage::run_store_submissions_thread; pub type JsonValue = serde_json::value::Value; diff --git a/src/main.rs b/src/main.rs index f51abce..622bf6e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,10 @@ use std::sync::Arc; use anyhow::{Context, Result}; -use block_submission_service::{consumer, env::ENV_CONFIG, health, log, server, storage}; +use block_submission_service::{ + env::ENV_CONFIG, log, run_consume_submissions_thread, run_server_thread, + run_store_submissions_thread, RedisConsumerHealth, RedisHealth, +}; use fred::{pool::RedisPool, types::RedisConfig}; use futures::{channel::mpsc::channel, try_join}; use tokio::sync::Notify; @@ -40,12 +43,12 @@ async fn main() -> Result<()> { .await .context("failed to connect to redis")?; - let redis_health = health::RedisHealth::new(redis_pool.clone()); - let redis_consumer_health = health::RedisConsumerHealth::new(); + let redis_health = RedisHealth::new(redis_pool.clone()); + let redis_consumer_health = RedisConsumerHealth::new(); let (submissions_tx, submissions_rx) = channel(SUBMISSIONS_BUFFER_SIZE); - let cache_submissions_thread = consumer::run_consume_submissions_thread( + let cache_submissions_thread = run_consume_submissions_thread( redis_pool.clone(), redis_consumer_health.clone(), shutdown_notify.clone(), @@ -53,10 +56,9 @@ async fn main() -> Result<()> { ); let store_submissions_thread = - storage::run_store_submissions_thread(redis_pool, submissions_rx, shutdown_notify.clone()); + run_store_submissions_thread(redis_pool, submissions_rx, shutdown_notify.clone()); - let server_thread = - server::run_server_thread(redis_health, redis_consumer_health, shutdown_notify); + let server_thread = run_server_thread(redis_health, redis_consumer_health, shutdown_notify); try_join!( cache_submissions_thread, diff --git a/tests/mod.rs b/tests/mod.rs index 32ca95b..7d88c4c 100644 --- a/tests/mod.rs +++ b/tests/mod.rs @@ -2,7 +2,8 @@ use std::{sync::Arc, time::Duration}; use anyhow::{Context, Result}; use block_submission_service::{ - consumer, env::ENV_CONFIG, health, storage, BlockSubmission, JsonValue, STREAM_NAME, + env::ENV_CONFIG, run_consume_submissions_thread, run_store_submissions_thread, BlockSubmission, + JsonValue, RedisConsumerHealth, STREAM_NAME, }; use fred::{ pool::RedisPool, @@ -22,22 +23,18 @@ async fn store_block_submission() -> Result<()> { .wait_for_connect() .await .context("failed to connect to redis")?; - let redis_consumer_health = health::RedisConsumerHealth::new(); + let redis_consumer_health = RedisConsumerHealth::new(); let (submissions_tx, submissions_rx) = channel(4); - consumer::run_consume_submissions_thread( + run_consume_submissions_thread( redis_pool.clone(), redis_consumer_health.clone(), shutdown_notify.clone(), submissions_tx.clone(), ); - storage::run_store_submissions_thread( - redis_pool.clone(), - submissions_rx, - shutdown_notify.clone(), - ); + run_store_submissions_thread(redis_pool.clone(), submissions_rx, shutdown_notify.clone()); let block_submission = { let file = std::fs::File::open("tests/fixtures/0xffe314e3f12d726cf9f4a4babfcbfc836ef53d3144469f886423a833c853e3ef.json.gz.decompressed")?;