Skip to content

Commit

Permalink
feat: destinations node interpretation for wasm components
Browse files Browse the repository at this point in the history
  • Loading branch information
SachaMorard committed Oct 10, 2024
1 parent 3782db2 commit dafdc25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/proxy/compute/data_collection/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ pub async fn send_data_collection(p: &Payload) -> anyhow::Result<()> {
// clone the payload to be able to move it to the async thread
let p = p.clone();
let payload = provider::Payload {
uuid: p.uuid,
uuid: p.uuid.clone(),
timestamp: p.timestamp.timestamp(),
timestamp_millis: p.timestamp.timestamp_millis(),
timestamp_micros: p.timestamp.timestamp_micros(),
Expand Down Expand Up @@ -281,6 +281,9 @@ pub async fn send_data_collection(p: &Payload) -> anyhow::Result<()> {
};

for cfg in &config::get().components.data_collection {
if !p.is_destination_enabled(cfg.name.as_str()) {
continue;
}
let component = WASM_COMPONENTS
.get()
.unwrap()
Expand Down
23 changes: 23 additions & 0 deletions src/proxy/compute/data_collection/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,3 +227,26 @@ pub struct Session {
pub first_seen: DateTime<Utc>,
pub last_seen: DateTime<Utc>,
}

impl Payload {
pub fn is_destination_enabled(&self, name: &str) -> &bool {
// if destinations is not set, return true
if self.destinations.is_none() {
return &true;
}

// get destinations.get("all")
let all = self
.destinations
.as_ref()
.unwrap()
.get("all")
.unwrap_or(&true);

// check if the destination is enabled
if self.destinations.as_ref().unwrap().contains_key(name) {
return self.destinations.as_ref().unwrap().get(name).unwrap();
}
all
}
}

0 comments on commit dafdc25

Please sign in to comment.