Skip to content

Commit

Permalink
chore: clean up eventd and service check types
Browse files Browse the repository at this point in the history
  • Loading branch information
tobz committed Jul 22, 2024
1 parent 8612664 commit 84e7620
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 79 deletions.
15 changes: 0 additions & 15 deletions lib/saluki-event/src/eventd/alert.rs

This file was deleted.

72 changes: 49 additions & 23 deletions lib/saluki-event/src/eventd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,33 @@
//! Event types
mod priority;
pub use self::priority::*;
//! Events.
mod alert;
pub use self::alert::*;
// TODO: Switch usages of `String` to `MetaString` since we should generally be able to intern these strings as they
// originate in in the DogStatsD codec, where interning is already taking place.

/// Alert type.
#[derive(Clone, Copy, Debug)]
pub enum AlertType {
/// Indicates an informational event.
Info,

/// Indicates an error event.
Error,

/// Indicates a warning event.
Warning,

/// Indicates a successful event.
Success,
}

/// Event priority.
#[derive(Clone, Copy, Debug)]
pub enum Priority {
/// The event has normal priority.
Normal,

/// The event has low priority.
Low,
}

/// EventD is an object that can be posted to the DataDog event stream.
#[derive(Clone, Debug)]
Expand All @@ -13,55 +37,57 @@ pub struct EventD {
timestamp: u64,
host: String,
aggregation_key: String,
priority: EventPriority,
priority: Priority,
source_type_name: String,
alert_type: EventAlertType,
alert_type: AlertType,
tags: Vec<String>,
}

impl EventD {
/// Gets a reference to the title.
/// Gets the title of the event.
pub fn title(&self) -> &str {
&self.title
}

/// Gets a reference to the text.
/// Gets the text of the event.
pub fn text(&self) -> &str {
&self.text
}

/// Gets a reference to the host.
/// Gets the host where the event originated from.
pub fn host(&self) -> &str {
&self.host
}

/// Gets a reference to the aggregation key.
/// Gets the aggregation key of the event.
pub fn aggregation_key(&self) -> &str {
&self.aggregation_key
}

/// Gets a reference to the priority.
pub fn priority(&self) -> &EventPriority {
&self.priority
/// Gets the priority of the event.
pub fn priority(&self) -> Priority {
self.priority
}

/// Gets a reference to the source type name.
/// Gets the source type name of the event.
pub fn source_type_name(&self) -> &str {
&self.source_type_name
}

/// Gets a reference to the alert type
pub fn alert_type(&self) -> &EventAlertType {
&self.alert_type
/// Gets the alert type of the event.
pub fn alert_type(&self) -> AlertType {
self.alert_type
}

/// Gets a reference to the timestamp.
pub fn timestamp(&self) -> &u64 {
&self.timestamp
/// Gets the timestamp of the event.
///
/// This is a Unix timestamp, or the number of seconds since the Unix epoch.
pub fn timestamp(&self) -> u64 {
self.timestamp
}

/// Gets a reference to the tags.
pub fn tags(&self) -> &Vec<String> {
/// Gets the tags associated with the event.
pub fn tags(&self) -> &[String] {
&self.tags
}
}
9 changes: 0 additions & 9 deletions lib/saluki-event/src/eventd/priority.rs

This file was deleted.

56 changes: 39 additions & 17 deletions lib/saluki-event/src/service_check/mod.rs
Original file line number Diff line number Diff line change
@@ -1,46 +1,68 @@
//! Service Check type
mod status;
pub use self::status::*;
//! Service checks.
/// ServiceCheck
// TODO: Switch usages of `String` to `MetaString` since we should generally be able to intern these strings as they
// originate in in the DogStatsD codec, where interning is already taking place.

/// Service status.
#[derive(Clone, Copy, Debug)]
pub enum CheckStatus {
/// The service is operating normally.
Ok,

/// The service is in a warning state.
Warn,

/// The service is in a critical state.
Critical,

/// The service is in an unknown state.
Unknown,
}

/// A service check.
///
/// Service checks represent the status of a service at a particular point in time. Checks are simplistic, with a basic
/// message, status enum (OK vs warning vs critical, etc), timestamp, and tags.
#[derive(Clone, Debug)]
pub struct ServiceCheck {
name: String,
status: ServiceCheckStatus,
status: CheckStatus,
timestamp: u64,
host: String,
message: String,
tags: Vec<String>,
}

impl ServiceCheck {
/// Gets a reference to the service check name
pub fn name(&self) -> &String {
/// Gets the name of the check.
pub fn name(&self) -> &str {
&self.name
}

/// Gets a reference to the status
pub fn status(&self) -> &ServiceCheckStatus {
&self.status
/// Gets the status of the check.
pub fn status(&self) -> CheckStatus {
self.status
}

/// Gets a reference to the timestamp
/// Gets the timestamp of the check.
///
/// This is a Unix timestamp, or the number of seconds since the Unix epoch.
pub fn timestamp(&self) -> u64 {
self.timestamp
}

/// Gets a reference to the host name
pub fn host(&self) -> &String {
/// Gets the host where the check originated from.
pub fn host(&self) -> &str {
&self.host
}

/// Gets a reference to the message
pub fn message(&self) -> &String {
/// Gets the message associated with the check.
pub fn message(&self) -> &str {
&self.message
}

/// Gets a reference to the tags
pub fn tags(&self) -> &Vec<String> {
/// Gets the tags associated with the check.
pub fn tags(&self) -> &[String] {
&self.tags
}
}
15 changes: 0 additions & 15 deletions lib/saluki-event/src/service_check/status.rs

This file was deleted.

0 comments on commit 84e7620

Please sign in to comment.