1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct HealthCheckRequest {}
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct HealthCheckResponse {
/// A flag that indicates the the actor is healthy
#[serde(default)]
pub healthy: bool,
/// A message containing additional information about the actors health
#[serde(default, skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
}
/// Generate the wasmbus RPC subject for putting links on a NATS cluster
///
/// When messages are published on this subject, hosts set up and update (if necessary) link information,
/// which may include calling `receive_link_config_*()` functions on relevant providers.
#[must_use]
pub fn link_put_subject(lattice: &str, provider_key: &str) -> String {
format!("wasmbus.rpc.{lattice}.{provider_key}.linkdefs.put")
}
/// Generate the wasmbus RPC subject for deleting links on a NATS cluster
///
/// When messages are published on this subject, hosts remove link information,
/// which may include calling `delete_link()` on relevant providers.
#[must_use]
pub fn link_del_subject(lattice: &str, provider_key: &str) -> String {
format!("wasmbus.rpc.{lattice}.{provider_key}.linkdefs.del")
}
/// Generate the wasmbus RPC subject for retrieving health information for a given provider
///
/// When messages are published on this subject, hosts trigger health checks on providers (i.e. a [`HealthCheckRequest`])
/// and return relevant results (i.e. a [`HealthCheckResponse`]).
#[must_use]
pub fn health_subject(lattice: &str, provider_key: &str) -> String {
format!("wasmbus.rpc.{lattice}.{provider_key}.health")
}
/// Generate the wasmbus RPC subject for shutting down a given provider
///
/// When messages are published on this subject, hosts perform shutdown (cleanly if possible).
#[must_use]
pub fn shutdown_subject(lattice: &str, provider_key: &str, link_name: &str) -> String {
format!("wasmbus.rpc.{lattice}.{provider_key}.{link_name}.shutdown")
}