Skip to content

Commit

Permalink
refactor: make our shuttle service name generic
Browse files Browse the repository at this point in the history
  • Loading branch information
c-git committed Jan 8, 2025
1 parent 286bb5a commit cef9c08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions crates/chat-app-server/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Context as _;

Check warning on line 1 in crates/chat-app-server/src/main.rs

View workflow job for this annotation

GitHub Actions / Rustfmt

Diff in /home/runner/work/crates/crates/crates/chat-app-server/src/main.rs
use chat_app_server::startup::CustomConfiguration;
use chat_app_server::startup::ShuttleService;
use chat_app_server::startup::AppService;
use wykies_server::initialize_tracing;
use wykies_server::{ApiServerBuilder, ApiServerInitBundle};

Expand All @@ -13,7 +13,7 @@ async fn main(
)]
db_pool: sqlx::PgPool,
#[shuttle_runtime::Secrets] secrets: shuttle_runtime::SecretStore,
) -> Result<ShuttleService, shuttle_runtime::Error> {
) -> Result<AppService, shuttle_runtime::Error> {
initialize_tracing("chat_app_server", "info", std::io::stdout);

sqlx::migrate!("./migrations_pg")
Expand All @@ -30,7 +30,7 @@ async fn main(
.expect("failed to initialize API Server");

tracing::info!("Setup Completed");
Ok(ShuttleService(api_server_builder))
Ok(AppService(api_server_builder))
}

#[cfg(feature = "standalone")]
Expand Down Expand Up @@ -58,7 +58,7 @@ async fn main() -> anyhow::Result<()> {
)
.context("failed to get socket address")?;

ShuttleService(api_server_builder)
AppService(api_server_builder)
.bind(addr)
.await
.context("service runtime error")
Expand Down
4 changes: 2 additions & 2 deletions crates/chat-app-server/src/startup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ pub async fn start_servers(
(result, cancellation_tacker, port)
}

pub struct ShuttleService(pub ApiServerBuilder<CustomConfiguration>);
pub struct AppService(pub ApiServerBuilder<CustomConfiguration>);

#[async_trait]
impl shuttle_runtime::Service for ShuttleService {
impl shuttle_runtime::Service for AppService {
async fn bind(self, addr: std::net::SocketAddr) -> Result<(), shuttle_runtime::Error> {
let (mut join_set, cancellation_tracker, _) = start_servers(self.0, addr).await;
let join_outcome = join_set.join_next().await.context("no tasks in join set")?;
Expand Down

0 comments on commit cef9c08

Please sign in to comment.