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:
@@ -2,7 +2,14 @@ use std::{ops::Deref, sync::Arc};
|
||||
|
||||
use crate::api::Discovery;
|
||||
|
||||
use super::{config::AgentConfig, discovery_client::DiscoveryClient, grpc_client::GrpcClient};
|
||||
use super::{
|
||||
config::AgentConfig,
|
||||
discovery_client::DiscoveryClient,
|
||||
grpc_client::GrpcClient,
|
||||
handlers::scheduled_tasks::{self, ScheduledTasks},
|
||||
queue::AgentQueue,
|
||||
scheduler::Scheduler,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AgentState(Arc<State>);
|
||||
@@ -31,20 +38,23 @@ pub struct State {
|
||||
pub grpc: GrpcClient,
|
||||
pub config: AgentConfig,
|
||||
pub discovery: Discovery,
|
||||
pub queue: AgentQueue,
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub async fn new() -> anyhow::Result<Self> {
|
||||
let config = AgentConfig::new().await?;
|
||||
let discovery = DiscoveryClient::new(&config.discovery);
|
||||
let discovery = discovery.discover().await?;
|
||||
|
||||
let discovery = DiscoveryClient::new(&config.discovery).discover().await?;
|
||||
let grpc = GrpcClient::new(&discovery.process_host);
|
||||
let scheduled_tasks = ScheduledTasks::new();
|
||||
let scheduler = Scheduler::new(scheduled_tasks);
|
||||
let queue = AgentQueue::new(scheduler);
|
||||
|
||||
Ok(Self {
|
||||
grpc,
|
||||
config,
|
||||
discovery,
|
||||
queue,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user