chore: scaffold moments workspace
Cargo workspace with five crates per architecture conventions:
- moments-entities: Source enum, Event, EventQuery, SourceSummary
- moments-core: EventReader / EventWriter ports
- moments-data: PgStore (sqlx postgres adapter) + 0001_init.sql
- moments-api: axum binary; /v1/{healthz,events,sources}
- moments-worker: skeleton; pollers land in step 2
Sources committed-to for ingestion: github, gitea, hg, bugzilla.
Workstation events explicitly retired (not deferred).
Build + clippy clean. sqlx queries use the runtime API for now;
will switch to compile-time-checked macros + .sqlx offline cache
once magrathea has the moments_{ro,rw} roles and database created.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
37
crates/moments-worker/src/main.rs
Normal file
37
crates/moments-worker/src/main.rs
Normal file
@@ -0,0 +1,37 @@
|
||||
use clap::Parser;
|
||||
use moments_data::PgStore;
|
||||
use tracing::info;
|
||||
|
||||
#[derive(Parser, Debug)]
|
||||
#[command(version, about = "moments ingestion worker")]
|
||||
struct Args {
|
||||
#[arg(long, env = "DATABASE_URL")]
|
||||
database_url: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> anyhow::Result<()> {
|
||||
init_tracing();
|
||||
let args = Args::parse();
|
||||
|
||||
let store = PgStore::connect(&args.database_url).await?;
|
||||
store.migrate().await?;
|
||||
|
||||
info!("worker started — pollers will land in step 2");
|
||||
|
||||
// Pollers (github, gitea, hg, bugzilla) land in subsequent steps.
|
||||
// For now this binary only verifies it can reach the database.
|
||||
let _ = store;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn init_tracing() {
|
||||
use tracing_subscriber::{EnvFilter, fmt};
|
||||
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
|
||||
let json = std::env::var("JOURNAL_STREAM").is_ok();
|
||||
if json {
|
||||
fmt().with_env_filter(filter).json().init();
|
||||
} else {
|
||||
fmt().with_env_filter(filter).init();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user