Add BrokerPort: loopd asks brokerd for every tool call
Implemented-By: OpenCode session (model recorded in docs/implementer-log.md)
This commit is contained in:
@@ -6,12 +6,14 @@ use std::os::unix::net::UnixListener;
|
||||
use std::path::Path;
|
||||
use std::process::ExitCode;
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use loopd::broker_port::{BrokerPort, NoBroker, not_configured_line};
|
||||
use loopd::channel::{self, Context};
|
||||
use loopd::config::Config;
|
||||
use loopd::llama::Client;
|
||||
use loopd::selftest::{SelfTestError, run};
|
||||
use loopd::tools::{FakeTools, Registry};
|
||||
use loopd::tools::{Registry, ToolPort};
|
||||
|
||||
fn main() -> ExitCode {
|
||||
let args: Vec<String> = std::env::args().skip(1).collect();
|
||||
@@ -38,7 +40,7 @@ fn run_selftest_check(client: &Client) -> Result<(), SelfTestError> {
|
||||
Ok(())
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("selftest: FAILED: {e}");
|
||||
eprintln!("selftest: FAILED: {e}; see docs/runbook.md#loopd-selftest-failed");
|
||||
Err(e)
|
||||
}
|
||||
}
|
||||
@@ -104,12 +106,17 @@ fn run_serve(path: &str) -> ExitCode {
|
||||
}
|
||||
eprintln!("loopd: serving on {}", socket.display());
|
||||
|
||||
let ctx = Arc::new(Context::new(
|
||||
cfg,
|
||||
client,
|
||||
Box::new(FakeTools::new()),
|
||||
Registry::m3a(),
|
||||
));
|
||||
let port: Box<dyn ToolPort> = match &cfg.broker.socket {
|
||||
Some(socket) => Box::new(BrokerPort::new(
|
||||
socket.clone(),
|
||||
Duration::from_millis(cfg.broker.timeout_ms),
|
||||
)),
|
||||
None => {
|
||||
eprintln!("{}", not_configured_line());
|
||||
Box::new(NoBroker)
|
||||
}
|
||||
};
|
||||
let ctx = Arc::new(Context::new(cfg, client, port, Registry::m3a()));
|
||||
if let Err(e) = channel::serve(listener, ctx) {
|
||||
eprintln!("loopd: the channel server stopped: {e}");
|
||||
return ExitCode::from(1);
|
||||
|
||||
Reference in New Issue
Block a user