From 88300c45202a228d54c1e99dd3b295ef3fb9aabd Mon Sep 17 00:00:00 2001 From: Matthieu Date: Sat, 18 Sep 2021 00:17:22 +0400 Subject: work on the gateway --- common/rust/src/error.rs | 18 ++++++++++++++++++ common/rust/src/lib.rs | 3 ++- common/rust/src/payloads.rs | 8 +++++++- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 common/rust/src/error.rs (limited to 'common/rust/src') diff --git a/common/rust/src/error.rs b/common/rust/src/error.rs new file mode 100644 index 0000000..dcb7a54 --- /dev/null +++ b/common/rust/src/error.rs @@ -0,0 +1,18 @@ +use std::fmt; + +pub struct NovaError { + pub message: String, +} + +impl fmt::Display for NovaError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "An error occured wihind the nova system: {}", self.message) // user-facing output + } +} + +impl fmt::Debug for NovaError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{{ file: {}, line: {} }}", file!(), line!()) // programmer-facing output + } +} + diff --git a/common/rust/src/lib.rs b/common/rust/src/lib.rs index 24e16ec..943d7cc 100644 --- a/common/rust/src/lib.rs +++ b/common/rust/src/lib.rs @@ -3,4 +3,5 @@ pub mod config; pub mod monitoring; pub mod nats; -pub mod payloads; \ No newline at end of file +pub mod payloads; +pub mod error; \ No newline at end of file diff --git a/common/rust/src/payloads.rs b/common/rust/src/payloads.rs index 1957077..6eb35c8 100644 --- a/common/rust/src/payloads.rs +++ b/common/rust/src/payloads.rs @@ -4,6 +4,12 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(bound(deserialize = "T: Deserialize<'de> + std::default::Default + Clone"))] pub struct CachePayload { - pub tracing: (), + pub tracing: Tracing, pub data: T } + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct Tracing { + pub node_id: String, + pub span: Option +} \ No newline at end of file -- cgit v1.2.3