pub struct TurnRunner<S: SessionStore> { /* private fields */ }Expand description
Executes a turn against a pooled connection.
Implementations§
Source§impl<S: SessionStore + 'static> TurnRunner<S>
impl<S: SessionStore + 'static> TurnRunner<S>
Sourcepub fn new(
pool: Arc<ConnectionPool<S>>,
gate: Arc<QueryGate>,
classifier: EventClassifier,
store: Arc<S>,
cfg: Option<TurnConfig>,
) -> Self
pub fn new( pool: Arc<ConnectionPool<S>>, gate: Arc<QueryGate>, classifier: EventClassifier, store: Arc<S>, cfg: Option<TurnConfig>, ) -> Self
Create a runner. cfg defaults when None.
gate is shared (Arc) so callers can QueryGate::acquire before
spawning work and then call Self::execute_reserved (Go appkit parity).
Sourcepub fn gate(&self) -> &Arc<QueryGate> ⓘ
pub fn gate(&self) -> &Arc<QueryGate> ⓘ
Shared query gate (same instance used by Self::execute / Self::execute_reserved).
Sourcepub fn with_broadcaster(self, b: Arc<SseBroadcaster>) -> Self
pub fn with_broadcaster(self, b: Arc<SseBroadcaster>) -> Self
Attach an SSE broadcaster for delta / thinking / complete / error fan-out.
Sourcepub fn with_input_builder(
self,
f: Arc<dyn Fn(&str, &str, Option<&Value>, Option<&InputOpts>) -> Map<String, Value> + Send + Sync>,
) -> Self
pub fn with_input_builder( self, f: Arc<dyn Fn(&str, &str, Option<&Value>, Option<&InputOpts>) -> Map<String, Value> + Send + Sync>, ) -> Self
Override the loop_input payload builder.
Sourcepub fn with_on_complete(
self,
f: Arc<dyn Fn(&str, &str, &str, &str, i64) + Send + Sync>,
) -> Self
pub fn with_on_complete( self, f: Arc<dyn Fn(&str, &str, &str, &str, i64) + Send + Sync>, ) -> Self
Completion hook (app_key, loop_id, content, completion_event, elapsed_ms).
Sourcepub fn with_on_error(
self,
f: Arc<dyn Fn(&str, &str, &Error) + Send + Sync>,
) -> Self
pub fn with_on_error( self, f: Arc<dyn Fn(&str, &str, &Error) + Send + Sync>, ) -> Self
Error hook.
Sourcepub fn with_error_data(
self,
f: Arc<dyn Fn(&Error) -> Value + Send + Sync>,
) -> Self
pub fn with_error_data( self, f: Arc<dyn Fn(&Error) -> Value + Send + Sync>, ) -> Self
Formatter for SSE query_error payloads.
Sourcepub async fn execute(
&self,
session_id: &str,
message: &str,
user_id: &str,
workspace_id: &str,
attachments: Option<Value>,
opts: Option<InputOpts>,
) -> Result<String>
pub async fn execute( &self, session_id: &str, message: &str, user_id: &str, workspace_id: &str, attachments: Option<Value>, opts: Option<InputOpts>, ) -> Result<String>
Execute one turn; returns concatenated assistant text on success.
Sourcepub async fn execute_reserved(
&self,
session_id: &str,
message: &str,
user_id: &str,
workspace_id: &str,
attachments: Option<Value>,
opts: Option<InputOpts>,
) -> Result<String>
pub async fn execute_reserved( &self, session_id: &str, message: &str, user_id: &str, workspace_id: &str, attachments: Option<Value>, opts: Option<InputOpts>, ) -> Result<String>
Run a turn when the caller already reserved the gate via QueryGate::acquire.
Releases the gate on all exit paths (including validate_opts failure), matching
Go ExecuteReserved.