generated from Patagia/template-nix
Compare commits
1 commit
375bc34dac
...
0d822dfa44
Author | SHA1 | Date | |
---|---|---|---|
0d822dfa44 |
5 changed files with 10 additions and 19 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
@ -2868,9 +2868,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.135"
|
||||
version = "1.0.138"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b0d7ba2887406110130a978386c4e1befb98c674b4fba677954e4db976630d9"
|
||||
checksum = "d434192e7da787e94a6ea7e9670b26a036d0ca41e0b7efb2676dd32bae872949"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
|
|
|
@ -46,7 +46,5 @@ slog = "2.7.0"
|
|||
slog-async = "2.8.0"
|
||||
tokio = { version = "1.43.0", features = ["full"] }
|
||||
tracing = "0.1.41"
|
||||
tracing-core = "0.1.33"
|
||||
tracing-chrome = "0.7.2"
|
||||
tracing-slog = { git = "https://github.com/oxidecomputer/tracing-slog", default-features = false }
|
||||
uuid = { version = "1", features = [ "serde", "v4" ] }
|
||||
|
|
|
@ -3,7 +3,6 @@ use anyhow::{anyhow, Result};
|
|||
use clap::Parser;
|
||||
use dropshot::{ConfigDropshot, ServerBuilder};
|
||||
use slog::Drain;
|
||||
// use sqlx::PgPool;
|
||||
use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
|
@ -60,13 +59,8 @@ async fn main() -> Result<()> {
|
|||
slog::Logger::root(async_drain, slog::o!())
|
||||
};
|
||||
|
||||
// let database_url = args.database_url.unwrap();
|
||||
// dont connect to database pass null
|
||||
// let pg = PgPool::connect(&database_url).await?;
|
||||
|
||||
// sqlx::migrate!().run(&pg).await?;
|
||||
|
||||
let ctx = ControllerContext::new();
|
||||
let dbus = zbus::Connection::system().await.unwrap();
|
||||
let ctx = ControllerContext::new(dbus);
|
||||
|
||||
let api = api::api()?;
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
// use sqlx::postgres::PgPool;
|
||||
use zbus::Connection;
|
||||
|
||||
pub struct ControllerContext {
|
||||
// pub pg_pool: PgPool,
|
||||
pub dbus: Connection,
|
||||
}
|
||||
|
||||
impl ControllerContext {
|
||||
pub fn new() -> ControllerContext {
|
||||
ControllerContext {}
|
||||
pub fn new(dbus: Connection) -> ControllerContext {
|
||||
ControllerContext { dbus }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,12 +22,11 @@ struct MachineInfo {
|
|||
pub async fn describe(
|
||||
rqctx: RequestContext<Arc<ControllerContext>>,
|
||||
) -> Result<HttpResponseOk<MachineInfo>, HttpError> {
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let manager = zbus_systemd::hostname1::HostnamedProxy::new(&conn)
|
||||
let hostnamed = zbus_systemd::hostname1::HostnamedProxy::new(&rqctx.context().dbus)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let machine_id = manager
|
||||
let machine_id = hostnamed
|
||||
.machine_id()
|
||||
.await
|
||||
.unwrap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue