Skip to main content

Module hot_reload

Module hot_reload 

Source
Expand description

Hot-reload agent card handler.

HotReloadAgentCardHandler wraps an AgentCard behind an Arc<RwLock<_>> so the card can be replaced at runtime without restarting the server. The handler implements AgentCardProducer and can therefore be used with DynamicAgentCardHandler.

Three reload strategies are provided:

MethodPlatformMechanism
reload_from_fileallReads a JSON file on demand
spawn_poll_watcherallPolls file modification time at a configurable interval
spawn_signal_watcherunixReloads on SIGHUP

§Example

use std::path::Path;
use std::sync::Arc;
use a2a_protocol_types::agent_card::AgentCard;
use a2a_protocol_server::agent_card::hot_reload::HotReloadAgentCardHandler;

let handler = HotReloadAgentCardHandler::new(card);

// Periodic polling (cross-platform).
let handle = handler.spawn_poll_watcher(
    Path::new("/etc/a2a/agent.json"),
    std::time::Duration::from_secs(30),
);
// `handle` can be dropped or `.abort()`-ed to stop polling.

Structs§

HotReloadAgentCardHandler
An agent card handler that supports hot-reloading.