#[non_exhaustive]pub struct Message {Show 17 fields
pub message: String,
pub title: Option<String>,
pub severity: Option<Severity>,
pub priority: Option<Priority>,
pub category: Option<Category>,
pub source: Option<String>,
pub environment: Option<String>,
pub channel: Option<String>,
pub group_key: Option<String>,
pub event_type: Option<EventType>,
pub occurred_at: Option<SystemTime>,
pub url: Option<String>,
pub image_url: Option<String>,
pub actions: Vec<Action>,
pub metadata: BTreeMap<String, MetadataValue>,
pub ttl_seconds: Option<u32>,
pub source_sequence: Option<u64>,
}Expand description
One event for POST /v1/messages. Only the message text is required; unset fields are
omitted so the server defaults apply (severity info, priority normal, source api,
environment default, channel general, event type event, TTL 3600 s). Empty strings
count as unset.
use honk_me::{Category, Message, Priority, Severity};
let msg = Message::new("db-1 /var is at 91%")
.title("Disk 91% full")
.severity(Severity::LOUD)
.priority(Priority::High)
.category(Category::Infrastructure)
.group_key("disk/db-1/var")
.metadata("host", "db-1")
.metadata("used_percent", 91);
assert_eq!(msg.severity, Some(Severity::Warning));Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.message: StringThe text: plain, 1–8192 bytes of UTF-8. Line breaks and tabs are allowed.
title: Option<String>One line, at most 160 characters. Defaults to the first line of the message.
severity: Option<Severity>Default info (light).
priority: Option<Priority>Default normal.
category: Option<Category>The category.
source: Option<String>At most 64 characters. Defaults to the client’s default, then api.
environment: Option<String>At most 32 characters. Defaults to the client’s default, then default.
channel: Option<String>At most 64 characters. Defaults to the client’s default, then general.
group_key: Option<String>At most 128 characters. Messages with the same key (per environment, source and
channel) form one group: the first one pushes, repeats update it calmly. Use one key per
customer request (requests/<id>), a shared key only for repeats of the same problem.
event_type: Option<EventType>Default event.
occurred_at: Option<SystemTime>When it happened at the source (informational).
url: Option<String>An https link shown as “Open link” (no credentials, at most 2048 bytes).
image_url: Option<String>An https image the server fetches after ingestion (no credentials or fragment, at most 2048 bytes).
actions: Vec<Action>Up to 3 buttons, in display order (the first is the primary). Empty: none.
metadata: BTreeMap<String, MetadataValue>At most 16 keys matching [A-Za-z0-9_.-]{1,64}.
ttl_seconds: Option<u32>The push lifetime, 60–86400 seconds. Default 3600.
source_sequence: Option<u64>A monotonic counter per source stream (0 … 2^53-1), so a delayed recovery can never close a newer problem. Needs a group key.
Implementations§
Source§impl Message
impl Message
Sourcepub fn severity(self, severity: Severity) -> Self
pub fn severity(self, severity: Severity) -> Self
Sets the severity (a horn alias like Severity::LOUD or a canonical value).
Sourcepub fn environment(self, environment: impl Into<String>) -> Self
pub fn environment(self, environment: impl Into<String>) -> Self
Sets the environment.
Sourcepub fn group_key(self, group_key: impl Into<String>) -> Self
pub fn group_key(self, group_key: impl Into<String>) -> Self
Sets the group key, e.g. requests/4812.
Sourcepub fn event_type(self, event_type: EventType) -> Self
pub fn event_type(self, event_type: EventType) -> Self
Sets the event type.
Sourcepub fn occurred_at(self, occurred_at: SystemTime) -> Self
pub fn occurred_at(self, occurred_at: SystemTime) -> Self
Sets when the event happened at the source.
Sourcepub fn image_url(self, image_url: impl Into<String>) -> Self
pub fn image_url(self, image_url: impl Into<String>) -> Self
Sets an https image the server fetches after ingestion.
Sourcepub fn action(self, title: impl Into<String>, url: impl Into<String>) -> Self
pub fn action(self, title: impl Into<String>, url: impl Into<String>) -> Self
Adds a button (at most 3, in display order), e.g. .action("Call", "tel:+15550134").
Sourcepub fn metadata(
self,
key: impl Into<String>,
value: impl Into<MetadataValue>,
) -> Self
pub fn metadata( self, key: impl Into<String>, value: impl Into<MetadataValue>, ) -> Self
Adds one metadata entry (a string, number or boolean).
Sourcepub fn ttl_seconds(self, ttl_seconds: u32) -> Self
pub fn ttl_seconds(self, ttl_seconds: u32) -> Self
Sets the push lifetime in seconds (60–86400).
Sourcepub fn source_sequence(self, source_sequence: u64) -> Self
pub fn source_sequence(self, source_sequence: u64) -> Self
Sets the monotonic source sequence (needs a group key).