Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: destinations node interpretation for wasm components #94

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
}