feat(code): wire gRPC server into Sol startup
spawns gRPC server alongside Matrix sync loop when [grpc] config is present. shares ToolRegistry, Store, MistralClient, and Matrix client with the gRPC CodeSession handler.
This commit is contained in:
@@ -65,6 +65,11 @@ impl Responder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Get a reference to the tool registry (for sharing with gRPC server).
|
||||||
|
pub fn tools(&self) -> Arc<ToolRegistry> {
|
||||||
|
self.tools.clone()
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn generate_response(
|
pub async fn generate_response(
|
||||||
&self,
|
&self,
|
||||||
context: &[ContextMessage],
|
context: &[ContextMessage],
|
||||||
|
|||||||
16
src/main.rs
16
src/main.rs
@@ -293,6 +293,22 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
error!("Reaction backfill failed (non-fatal): {e}");
|
error!("Reaction backfill failed (non-fatal): {e}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Start gRPC server if configured
|
||||||
|
if config.grpc.is_some() {
|
||||||
|
let grpc_state = std::sync::Arc::new(grpc::GrpcState {
|
||||||
|
config: config.clone(),
|
||||||
|
tools: state.responder.tools(),
|
||||||
|
store: store.clone(),
|
||||||
|
mistral: state.mistral.clone(),
|
||||||
|
matrix: matrix_client.clone(),
|
||||||
|
});
|
||||||
|
tokio::spawn(async move {
|
||||||
|
if let Err(e) = grpc::start_server(grpc_state).await {
|
||||||
|
error!("gRPC server error: {e}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Start sync loop in background
|
// Start sync loop in background
|
||||||
let sync_client = matrix_client.clone();
|
let sync_client = matrix_client.clone();
|
||||||
let sync_state = state.clone();
|
let sync_state = state.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user