nsmcp::ChatCompletionsBackend method streamDrain (public)

 <instance of nsmcp::ChatCompletionsBackend[i]> streamDrain key

Defined in /usr/local/ns/tcl/nsmcp/question-chat-completions.tcl

Drain currently buffered response bytes. Swap out buffered data under the shared mutex while retaining response metadata and total-byte counters.

Parameters:
key (required)
Retained stream or configuration key.
Returns:
The stream-state dictionary containing the drained data.

Testcases:
No testcase defined.
Source code:
ns_mutex lock ${:mutex}
try {
    set record [nsv_get ${:streamStore} $key]
    set next $record
    dict set next data {}
    nsv_set ${:streamStore} $key $next
    return $record
} finally {
    ns_mutex unlock ${:mutex}
}
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: