Files
harmony/examples/notes/src/main.rs
Jean-Gabriel Gill-Couture eea006535b refactor: drop harmony_app landfill
Scores own deploy. harmony_app is identity, images, context, and
HarmonyApp→Scores. Authoring DX lives in dx. Compose/chart/Application
model and the Helm render test are gone.
2026-09-08 22:10:34 -04:00

69 lines
1.9 KiB
Rust

mod app;
mod backend;
mod cluster;
mod frontend;
mod localdev;
mod postgres;
use async_trait::async_trait;
use harmony::topology::K8sAnywhereTopology;
use harmony_app::dx::container;
use harmony_app::{
AppContext, AppError, AppIdentity, Context, ContextCatalog, ContextSpec, HarmonyApp,
ImageRefs, LocalContext,
};
use harmony_macros::context_name;
struct NotesApp;
#[async_trait]
impl HarmonyApp<K8sAnywhereTopology> for NotesApp {
fn identity(&self, ctx: &AppContext) -> AppIdentity {
AppIdentity {
name: "notes".into(),
namespace: ctx.namespace().to_string(),
}
}
async fn scores(
&self,
ctx: &AppContext,
_images: &ImageRefs,
) -> Result<Vec<Box<dyn harmony::score::Score<K8sAnywhereTopology>>>, AppError> {
let notes = app::notes();
match ctx.name() {
"localdev" => {
let _ = localdev::bind(&notes);
Ok(localdev::scores(&notes, ctx.namespace()))
}
"cluster" => {
let _: app::Bound<container, container, container> = cluster::bind(&notes);
Ok(cluster::scores(&notes, ctx.namespace()))
}
other => Err(AppError::InvalidComposition(format!(
"unknown context '{other}'"
))),
}
}
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
harmony_cli::app::app_main(
NotesApp,
ContextCatalog::new([
Context {
name: context_name!("localdev"),
namespace: "notes".parse()?,
spec: ContextSpec::Local(LocalContext::ManagedK3d),
},
Context {
name: context_name!("cluster"),
namespace: "notes".parse()?,
spec: ContextSpec::Local(LocalContext::ManagedK3d),
},
])?,
)
.await
}