generated from Patagia/template-nix
This commit is contained in:
parent
a5e3170d37
commit
c06a3b31b2
12 changed files with 1019 additions and 26 deletions
967
Cargo.lock
generated
967
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -2,11 +2,13 @@
|
|||
resolver = "2"
|
||||
members = [
|
||||
"agent",
|
||||
"client",
|
||||
"controller",
|
||||
"xtask",
|
||||
]
|
||||
default-members = [
|
||||
"agent",
|
||||
"client",
|
||||
"controller",
|
||||
"xtask",
|
||||
]
|
||||
|
@ -36,9 +38,11 @@ opentelemetry-otlp = { version = "0.27.0", features = ["grpc-tonic", "trace"] }
|
|||
opentelemetry_sdk = { version = "0.27.1", features = ["metrics", "rt-tokio"] }
|
||||
opentelemetry-semantic-conventions = "0.27.0"
|
||||
opentelemetry-stdout = "0.27.0"
|
||||
progenitor = "0.8.0"
|
||||
reqwest = { version = "0.12.9", features = ["json", "stream", "rustls-tls"] }
|
||||
schemars = "0.8.21"
|
||||
semver = "1.0.23"
|
||||
serde = "1.0.215"
|
||||
serde = { version = "1.0.215", features = ["derive"] }
|
||||
slog = "2.7.0"
|
||||
slog-async = "2.8.0"
|
||||
tokio = { version = "1.41.1", features = ["full"] }
|
||||
|
@ -53,3 +57,4 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
|||
"env-filter",
|
||||
"fmt",
|
||||
] }
|
||||
uuid = { version = "1", features = [ "serde", "v4" ] }
|
||||
|
|
|
@ -7,6 +7,7 @@ license = "MPL-2.0"
|
|||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
patagia-client = { path = "../client" }
|
||||
tokio.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-chrome.workspace = true
|
||||
|
|
|
@ -19,6 +19,10 @@ async fn main() -> Result<()> {
|
|||
|
||||
tracing::info!("Patagia Agent");
|
||||
|
||||
let client = patagia_client::Client::new("http://localhost:9474");
|
||||
let result = client.version().await?;
|
||||
tracing::info!("Result: {:?}", result);
|
||||
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
Ok(())
|
||||
}
|
||||
|
|
2
api.json
2
api.json
|
@ -8,7 +8,7 @@
|
|||
"/version": {
|
||||
"get": {
|
||||
"summary": "Fetch version info.",
|
||||
"operationId": "api_version",
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
|
|
13
client/Cargo.toml
Normal file
13
client/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "patagia-client"
|
||||
version = "0.0.1"
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
chrono = { version = "0.4.0", default-features = false, features = ["serde"] }
|
||||
progenitor.workspace = true
|
||||
reqwest.workspace = true
|
||||
schemars.workspace = true
|
||||
serde.workspace = true
|
4
client/src/lib.rs
Normal file
4
client/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
use progenitor::generate_api;
|
||||
|
||||
|
||||
generate_api!(spec = "../api.json", derives = [schemars::JsonSchema]);
|
|
@ -28,7 +28,7 @@ tracing-opentelemetry.workspace = true
|
|||
tracing-slog.workspace = true
|
||||
tracing-subscriber.workspace = true
|
||||
tracing.workspace = true
|
||||
|
||||
[[bin]]
|
||||
name = "patagia-controller"
|
||||
doc = false
|
||||
#
|
||||
# [[bin]]
|
||||
# name = "patagia-controller"
|
||||
# doc = false
|
||||
|
|
|
@ -10,6 +10,6 @@ type ControllerApiDescription = ApiDescription<Arc<ControllerContext>>;
|
|||
|
||||
pub fn api() -> Result<ControllerApiDescription> {
|
||||
let mut api = ControllerApiDescription::new();
|
||||
api.register(version::api_version)?;
|
||||
api.register(version::version)?;
|
||||
Ok(api)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ struct VersionInfo {
|
|||
),
|
||||
err(Debug),
|
||||
)]
|
||||
pub async fn api_version(
|
||||
pub(crate) async fn version(
|
||||
rqctx: RequestContext<Arc<ControllerContext>>,
|
||||
) -> Result<HttpResponseOk<VersionInfo>, HttpError> {
|
||||
let ver = VersionInfo {
|
||||
|
|
27
flake.nix
27
flake.nix
|
@ -49,6 +49,7 @@
|
|||
nativeBuildInputs = with pkgs; [
|
||||
clang_18
|
||||
mold
|
||||
pkg-config
|
||||
];
|
||||
|
||||
sourceAndFixtures = path: type: (craneLib.filterCargoSources path type);
|
||||
|
@ -72,6 +73,9 @@
|
|||
inherit src stdenv nativeBuildInputs;
|
||||
strictDeps = true;
|
||||
LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
|
||||
buildInputs = with pkgs; [
|
||||
openssl
|
||||
];
|
||||
};
|
||||
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
@ -91,6 +95,7 @@
|
|||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
(craneLib.fileset.commonCargoSources ./agent)
|
||||
(craneLib.fileset.commonCargoSources ./client)
|
||||
(craneLib.fileset.commonCargoSources ./controller)
|
||||
(craneLib.fileset.commonCargoSources ./xtask)
|
||||
(craneLib.fileset.commonCargoSources crate)
|
||||
|
@ -142,7 +147,7 @@
|
|||
}
|
||||
);
|
||||
|
||||
fmt = craneLib.cargoFmt (commonArgs // { inherit src; });
|
||||
# fmt = craneLib.cargoFmt (commonArgs // { inherit src; });
|
||||
|
||||
audit = craneLib.cargoAudit (commonArgs // { inherit src advisory-db; });
|
||||
|
||||
|
@ -156,11 +161,16 @@
|
|||
);
|
||||
|
||||
openapi =
|
||||
pkgs.runCommand "openapi" (commonArgs // {
|
||||
src = fileSetForCrate ./xtask;
|
||||
}) ''
|
||||
${self.packages.${system}.xtask}/bin/xtask open-api | ${pkgs.diffutils}/bin/diff -u $src/api.json - | tee $out
|
||||
'';
|
||||
pkgs.runCommand "openapi"
|
||||
(
|
||||
commonArgs
|
||||
// {
|
||||
src = fileSetForCrate ./xtask;
|
||||
}
|
||||
)
|
||||
''
|
||||
${self.packages.${system}.xtask}/bin/xtask open-api | ${pkgs.diffutils}/bin/diff -u $src/api.json - | tee $out
|
||||
'';
|
||||
};
|
||||
|
||||
# For `nix fmt`
|
||||
|
@ -182,10 +192,11 @@
|
|||
rust-dev-toolchain
|
||||
watchexec
|
||||
];
|
||||
RUST_BACKTRACE = 1;
|
||||
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; # Required for rust-analyzer
|
||||
shellHook = ''
|
||||
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer
|
||||
echo
|
||||
echo "✨ Welcome to the Patagia development environment! ✨"
|
||||
echo "✨🛠️ Welcome to the Patagia development environment 🛠️✨"
|
||||
echo "Run 'just' to see available commands."
|
||||
echo
|
||||
'';
|
||||
|
|
8
justfile
8
justfile
|
@ -12,6 +12,14 @@ run-controller $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
|
|||
dev-controller:
|
||||
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-controller
|
||||
|
||||
# Run agent
|
||||
run-agent $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
|
||||
cargo run --package patagia-agent
|
||||
|
||||
# Run agent local development
|
||||
dev-agent:
|
||||
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-agent
|
||||
|
||||
# Lint all source code
|
||||
lint:
|
||||
cargo clippy
|
||||
|
|
Loading…
Reference in a new issue