huskies: merge 761
This commit is contained in:
@@ -15,6 +15,7 @@ pub mod crdt_sync;
|
||||
pub mod crdt_wire;
|
||||
mod db;
|
||||
pub mod gateway;
|
||||
mod gateway_relay;
|
||||
mod http;
|
||||
mod io;
|
||||
mod llm;
|
||||
@@ -699,6 +700,44 @@ async fn main() -> Result<(), std::io::Error> {
|
||||
let event_buffer = crate::http::events::EventBuffer::new();
|
||||
crate::http::events::subscribe_to_watcher(event_buffer.clone(), watcher_rx_for_events);
|
||||
|
||||
// ── Gateway relay task ───────────────────────────────────────────────────
|
||||
//
|
||||
// When `gateway_url` is configured (via project.toml or HUSKIES_GATEWAY_URL)
|
||||
// start a background task that pushes StatusEvents to the gateway's
|
||||
// /gateway/events/push WebSocket endpoint. The project name sent to the
|
||||
// gateway defaults to the project root directory name when `gateway_project`
|
||||
// is not explicitly set.
|
||||
{
|
||||
let relay_gateway_url = startup_root
|
||||
.as_ref()
|
||||
.and_then(|r| config::ProjectConfig::load(r).ok())
|
||||
.and_then(|c| c.gateway_url)
|
||||
.or_else(|| std::env::var("HUSKIES_GATEWAY_URL").ok())
|
||||
.unwrap_or_default();
|
||||
|
||||
if !relay_gateway_url.is_empty() {
|
||||
let relay_project_name = startup_root
|
||||
.as_ref()
|
||||
.and_then(|r| config::ProjectConfig::load(r).ok())
|
||||
.and_then(|c| c.gateway_project)
|
||||
.or_else(|| std::env::var("HUSKIES_GATEWAY_PROJECT").ok())
|
||||
.or_else(|| {
|
||||
startup_root
|
||||
.as_ref()
|
||||
.and_then(|r| r.file_name())
|
||||
.map(|n| n.to_string_lossy().into_owned())
|
||||
})
|
||||
.unwrap_or_else(|| "project".to_string());
|
||||
|
||||
gateway_relay::spawn_relay_task(
|
||||
relay_gateway_url,
|
||||
relay_project_name,
|
||||
Arc::clone(&services.status),
|
||||
reqwest::Client::new(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let app = build_routes(
|
||||
ctx,
|
||||
whatsapp_ctx.clone(),
|
||||
|
||||
Reference in New Issue
Block a user