Skip to content

Commit 7432ed6

Browse files
committed
Make AppLauncher generic over ExecutionBackend instead of app
1 parent ef57bf7 commit 7432ed6

3 files changed

Lines changed: 7 additions & 16 deletions

File tree

crates/tower-cmd/src/run.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ use std::collections::HashMap;
55
use std::path::PathBuf;
66
use tower_api::models::Run;
77
use tower_package::{Package, PackageSpec};
8-
use tower_runtime::{
9-
execution::ExecutionHandle, local::LocalApp, AppLauncher, OutputReceiver, Status,
10-
};
8+
use tower_runtime::{execution::ExecutionHandle, AppLauncher, OutputReceiver, Status};
119
use tower_telemetry::{debug, Context};
1210

1311
use std::sync::Arc;
@@ -175,7 +173,7 @@ where
175173
// Create backend and launcher
176174
use tower_runtime::backends::local::LocalBackend;
177175
let backend = LocalBackend::new(config.cache_dir);
178-
let mut launcher: AppLauncher<LocalApp> = AppLauncher::default();
176+
let mut launcher: AppLauncher<LocalBackend> = AppLauncher::default();
179177

180178
launcher
181179
.launch(

crates/tower-runtime/src/lib.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ pub type OutputReceiver = UnboundedReceiver<Output>;
5151
pub type OutputSender = UnboundedSender<Output>;
5252

5353
pub trait App: Send + Sync {
54-
type Backend: ExecutionBackend;
55-
5654
// start will start the process
5755
fn start(opts: StartOptions) -> impl Future<Output = Result<Self, Error>> + Send
5856
where
@@ -65,23 +63,20 @@ pub trait App: Send + Sync {
6563
fn status(&self) -> impl Future<Output = Result<Status, Error>> + Send;
6664
}
6765

68-
pub struct AppLauncher<A: App> {
69-
pub handle: Option<<A::Backend as ExecutionBackend>::Handle>,
66+
pub struct AppLauncher<B: ExecutionBackend> {
67+
pub handle: Option<B::Handle>,
7068
}
7169

72-
impl<A: App> std::default::Default for AppLauncher<A> {
70+
impl<B: ExecutionBackend> Default for AppLauncher<B> {
7371
fn default() -> Self {
7472
Self { handle: None }
7573
}
7674
}
7775

78-
impl<A: App> AppLauncher<A>
79-
where
80-
A::Backend: ExecutionBackend,
81-
{
76+
impl<B: ExecutionBackend> AppLauncher<B> {
8277
pub async fn launch(
8378
&mut self,
84-
backend: A::Backend,
79+
backend: B,
8580
ctx: tower_telemetry::Context,
8681
package: Package,
8782
environment: String,

crates/tower-runtime/src/local.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,8 +324,6 @@ impl Drop for LocalApp {
324324
}
325325

326326
impl App for LocalApp {
327-
type Backend = crate::backends::local::LocalBackend;
328-
329327
async fn start(opts: StartOptions) -> Result<Self, Error> {
330328
let terminator = CancellationToken::new();
331329

0 commit comments

Comments
 (0)