feat: Engine-Adaptervertrag, llama.cpp-Adapter und Attrappe (M2.2)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
36
crates/nexus-adapter/src/engine.rs
Normal file
36
crates/nexus-adapter/src/engine.rs
Normal file
@ -0,0 +1,36 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use crate::types::EngineInfo;
|
||||
use crate::types::{
|
||||
DiscoveredArtifact, Endpoint, Health, InstanceHandle, ProfileSpec, Result, Usage,
|
||||
};
|
||||
|
||||
/// Vertrag zwischen Gateway und Engine (Spezifikation, Abschnitt 4).
|
||||
///
|
||||
/// Alle Methoden sind wiederholbar aufrufbar. `stop` ist idempotent: Eine
|
||||
/// bereits beendete oder unbekannte Instanz ist kein Fehler.
|
||||
#[async_trait]
|
||||
pub trait Engine: Send + Sync {
|
||||
/// Art, Modus und Fähigkeiten der Engine.
|
||||
fn describe(&self) -> EngineInfo;
|
||||
|
||||
/// Sucht Modelle und Quantisierungen. Verändert nichts.
|
||||
async fn discover(&self) -> Result<Vec<DiscoveredArtifact>>;
|
||||
|
||||
/// Startet eine Instanz und kehrt erst zurück, wenn sie bereit ist oder
|
||||
/// der Start gescheitert ist.
|
||||
async fn start(&self, profile: &ProfileSpec) -> Result<InstanceHandle>;
|
||||
|
||||
/// Beendet die Instanz: zuerst höflich, nach `grace` mit Gewalt.
|
||||
async fn stop(&self, instance: &InstanceHandle, grace: Duration) -> Result<()>;
|
||||
|
||||
async fn health(&self, instance: &InstanceHandle) -> Health;
|
||||
|
||||
/// Adresse, unter der die Instanz erreichbar ist.
|
||||
fn endpoint(&self, instance: &InstanceHandle) -> Endpoint;
|
||||
|
||||
/// Misst den echten Ressourcenverbrauch.
|
||||
async fn measure(&self, instance: &InstanceHandle) -> Usage;
|
||||
}
|
||||
Reference in New Issue
Block a user