Skip to main content

serve

Function serve 

Source
pub(crate) async fn serve<R, W>(
    input: R,
    output: W,
    runner: Arc<dyn ToolRunner>,
    tools: Arc<dyn Fn() -> Value + Send + Sync>,
    tools_changed: Arc<Notify>,
    health: Arc<Health>,
    deadline_of: fn(&str, &Value) -> Duration,
)
where R: AsyncBufReadExt + Unpin, W: AsyncWrite + Unpin + Send + 'static,
Expand description

Reads requests from input until it closes, answering each on output. deadline_of says how long each call may run (call_deadline in production). initialize and tools/list are answered at once; tools/call runs through runner as a task. notifications/cancelled stops the call it names. Each tools_changed wake-up tells the client the tool list changed, so it asks for it again: a client lists the tools once, when it connects, and never again unless told.