Skip to content

Commit e75bcf6

Browse files
authored
fix(dynamo-run): Run without etcd/nats, HTTP port to 8000 (#4555)
Signed-off-by: Graham King <[email protected]>
1 parent f0ca16f commit e75bcf6

File tree

4 files changed

+43
-21
lines changed

4 files changed

+43
-21
lines changed

launch/dynamo-run/src/flags.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct Flags {
3131

3232
/// HTTP port. `in=http` only
3333
/// If tls_cert_path and tls_key_path are provided, this will be TLS/HTTPS.
34-
#[arg(long, default_value = "8080")]
34+
#[arg(long, default_value = "8000")]
3535
pub http_port: u16,
3636

3737
/// TLS certificate file

launch/dynamo-run/src/lib.rs

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,23 @@ pub async fn run(
7777
if let Input::Endpoint(path) = &in_opt {
7878
builder.endpoint_id(Some(path.parse().with_context(|| path.clone())?));
7979
}
80-
let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?;
81-
let request_plane: RequestPlaneMode = flags.request_plane.parse()?;
82-
let dst_config = DistributedConfig {
83-
store_backend: selected_store,
84-
// We only need NATS here to monitor it's metrics, so only if it's our request plane.
85-
nats_config: if request_plane.is_nats() {
86-
Some(nats::ClientOptions::default())
87-
} else {
88-
None
89-
},
90-
request_plane,
80+
let dst_config = if is_process_local(&in_opt, &out_opt) {
81+
// We are both the frontend and backend, no networking
82+
DistributedConfig::process_local()
83+
} else {
84+
// Normal case
85+
let selected_store: KeyValueStoreSelect = flags.store_kv.parse()?;
86+
let request_plane: RequestPlaneMode = flags.request_plane.parse()?;
87+
DistributedConfig {
88+
store_backend: selected_store,
89+
// We only need NATS here to monitor it's metrics, so only if it's our request plane.
90+
nats_config: if request_plane.is_nats() {
91+
Some(nats::ClientOptions::default())
92+
} else {
93+
None
94+
},
95+
request_plane,
96+
}
9197
};
9298
let distributed_runtime = DistributedRuntime::new(runtime.clone(), dst_config).await?;
9399
let local_model = builder.build().await?;
@@ -117,6 +123,18 @@ pub async fn run(
117123
Ok(())
118124
}
119125

126+
pub fn is_in_dynamic(in_opt: &Input) -> bool {
127+
matches!(in_opt, Input::Endpoint(_))
128+
}
129+
130+
pub fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
131+
matches!(out_opt, Some(Output::Auto))
132+
}
133+
134+
fn is_process_local(in_opt: &Input, out_opt: &Option<Output>) -> bool {
135+
!is_in_dynamic(in_opt) && !is_out_dynamic(out_opt)
136+
}
137+
120138
/// Create the engine matching `out_opt`
121139
/// Note validation happens in Flags::validate. In here assume everything is going to work.
122140
async fn engine_for(

launch/dynamo-run/src/main.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,9 @@ async fn wrapper(runtime: dynamo_runtime::Runtime) -> anyhow::Result<()> {
127127
.chain(env::args().skip(non_flag_params)),
128128
)?;
129129

130-
if is_in_dynamic(&in_opt) && is_out_dynamic(&out_opt) {
130+
if dynamo_run::is_in_dynamic(&in_opt) && dynamo_run::is_out_dynamic(&out_opt) {
131131
anyhow::bail!("Cannot use endpoint for both in and out");
132132
}
133133

134134
dynamo_run::run(runtime, in_opt, out_opt, flags).await
135135
}
136-
137-
fn is_in_dynamic(in_opt: &Input) -> bool {
138-
matches!(in_opt, Input::Endpoint(_))
139-
}
140-
141-
fn is_out_dynamic(out_opt: &Option<Output>) -> bool {
142-
matches!(out_opt, Some(Output::Auto))
143-
}

lib/runtime/src/distributed.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,18 @@ impl DistributedConfig {
447447
request_plane,
448448
}
449449
}
450+
451+
/// A DistributedConfig that isn't distributed, for when the frontend and backend are in the
452+
/// same process.
453+
pub fn process_local() -> DistributedConfig {
454+
DistributedConfig {
455+
store_backend: KeyValueStoreSelect::Memory,
456+
nats_config: None,
457+
// This won't be used in process local, so we likely need a "none" option to
458+
// communicate that and avoid opening the ports.
459+
request_plane: RequestPlaneMode::Tcp,
460+
}
461+
}
450462
}
451463

452464
/// Request plane transport mode configuration

0 commit comments

Comments
 (0)