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:
| Method | Platform | Mechanism |
|---|---|---|
reload_from_file | all | Reads a JSON file on demand |
spawn_poll_watcher | all | Polls file modification time at a configurable interval |
spawn_signal_watcher | unix | Reloads 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§
- HotReload
Agent Card Handler - An agent card handler that supports hot-reloading.