Créer un nouveau Service
Structure d'un Service
crates/mon-service/
├── Cargo.toml
├── src/
│ ├── lib.rs # Point d'entrée
│ ├── admin_cell.rs # Gouvernance
│ ├── context.rs # Contexte
│ ├── errors.rs # Erreurs
│ └── data.rs # Accès données
Étapes de création
1. Créer le crate
[package]
name = "mon-service"
version = "0.1.0"
edition = "2021"
[dependencies]
kindmother-client = { path = "../kindmother-client" }
serde = { version = "1", features = ["derive"] }
tokio = { version = "1", features = ["full"] }
2. Définir l'admin cell
pub struct MonServiceAdminCell {
pub identification: MonServiceIdentification,
pub integrity: MonServiceIntegrity,
}
3. Implémenter l'accès aux données
pub struct MonServiceDb {
client: KindMotherClient,
}
impl MonServiceDb {
pub async fn open(db_path: PathBuf) -> Result<Self, Error> {
// Via KindMother uniquement !
}
}
4. Intégrer dans Central
Dans `apps/central/src/services/` :