feat: add common queue
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Signed-off-by: kjuulh <contact@kjuulh.io>
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
use notmad::{Component, MadError};
|
||||
|
||||
use super::{agent_state::AgentState, config::AgentConfig, grpc_client::GrpcClient};
|
||||
use crate::agent::models::Commands;
|
||||
|
||||
use super::{
|
||||
agent_state::AgentState, config::AgentConfig, grpc_client::GrpcClient, queue::AgentQueue,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct EventHandler {
|
||||
config: AgentConfig,
|
||||
grpc: GrpcClient,
|
||||
queue: AgentQueue,
|
||||
}
|
||||
|
||||
impl EventHandler {
|
||||
@@ -15,6 +20,7 @@ impl EventHandler {
|
||||
Self {
|
||||
config: state.config.clone(),
|
||||
grpc: state.grpc.clone(),
|
||||
queue: state.queue.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,7 +52,11 @@ impl Component for EventHandler {
|
||||
#[async_trait::async_trait]
|
||||
impl super::grpc_client::ListenEventsExecutor for EventHandler {
|
||||
async fn execute(&self, event: crate::grpc::ListenEventsResponse) -> anyhow::Result<()> {
|
||||
tracing::info!(value = event.value, "received event");
|
||||
tracing::info!(value = event.id, "received event");
|
||||
|
||||
let event: Commands = serde_json::from_str(&event.value)?;
|
||||
|
||||
self.queue.publish(event).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Reference in New Issue
Block a user