Skip to content

Commit 1076db6

Browse files
feat(rustchecks): add byte-based event platform event submission to AgentCheck and Aggregator
1 parent 0cbb4f2 commit 1076db6

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

pkg/collector/sharedlibrary/rustchecks/core/src/agent_check.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,4 +247,14 @@ impl AgentCheck {
247247
event_track_type,
248248
)
249249
}
250+
251+
// TODO(dsec-156): make event_platform_event delegate to this.
252+
pub fn event_platform_event_bytes(
253+
&self,
254+
raw_event: &[u8],
255+
event_track_type: &str,
256+
) -> Result<()> {
257+
self.aggregator
258+
.submit_event_platform_event_bytes(&self.check_id, raw_event, event_track_type)
259+
}
250260
}

pkg/collector/sharedlibrary/rustchecks/core/src/aggregator.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,26 @@ impl Aggregator {
286286

287287
Ok(())
288288
}
289+
290+
// TODO(dsec-157): refactor so submit_event_platform_event depends on
291+
// submit_event_platform_event_bytes.
292+
pub fn submit_event_platform_event_bytes(
293+
&self,
294+
check_id: &str,
295+
raw_event: &[u8],
296+
event_type: &str,
297+
) -> Result<()> {
298+
// create C strings guards to automatically free the underlying C strings
299+
let cstr_check_id = CStringGuard::new(check_id)?;
300+
let cstr_event_type = CStringGuard::new(event_type)?;
301+
302+
(self.cb_submit_event_platform_event)(
303+
cstr_check_id.as_ptr(),
304+
raw_event.as_ptr() as *mut c_char,
305+
raw_event.len() as c_int,
306+
cstr_event_type.as_ptr(),
307+
);
308+
309+
Ok(())
310+
}
289311
}

0 commit comments

Comments
 (0)