Process Collector and Event Feed
I’ve been waiting for this lol this is was so fun cuz i was locked the hell in
okay so hear me out
so in agent i made a very basic process collector which has 2 maps and every 10 seconds it updates the currProcesses map and compares it with prevProcesses the resulting differences are the process created/terminated. basic stuff.
and then after that it creates an event struct and uses the event.Emit() function which just adds the event to a queue (go channel), and another function RunEventWorker() just has a loop which runs till events queue have events in them, and calls the api.SendEvent() function with the event, and that api function is very dynamic cuz the structure of event payload itself is very dynamic so all types of events can be sent from that small function
and the coolest part about this whole pipeline is that it follows best practice of code, each function does only one thing, the collector just collects and emits the event, the event function only adds event to queue, then event worker runs api function with those events, everything is so organised!!!
and the feed is semi-live, it just polls every 10 seconds.
i REALLY had fun coding this lmao i love go :3
next: probably more processes related events or logs
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.