C · Batches

Batches

#include <ucall/types.h>#include <ucall/server.h> 1.0.0-rc.1 · 60202332

Batch callbacks receive a counted array of retained request handles, followed by the registered context. The array is borrowed only during the callback; copy its handles into application-owned storage to defer work without copying request bytes. Every loop deposits into one queue per batch endpoint, so batches mix requests from all loops, and partial batches flush at their configured deadline.

The batch endpoint’s polling owner can also manage the engines the batch feeds, with no thread of its own per engine. Each USearch, UStore and UForm executor runs one call at a time, and a deferred call on a caller-exclusive executor finishes on that executor’s threads, so the owner submits one deferred call per executor and replies from the status words:

ucall_server_take_batch(&take);                     // its callback copies the request handles out
search.completion = usearch_completion_deferred_k;  // every query of the batch, in one call
usearch_dense_search(&search);
read.completion = ustore_completion_deferred_k;     // every document of the batch, in one call
ustore_docs_read(&read);
while (usearch_outcome_status(search.outcome) == usearch_status_deferred_k ||
       ustore_outcome_status(read.outcome) == ustore_status_deferred_k)
    ucall_server_take_calls(&calls);                // keep serving the plain endpoints meanwhile
reply_to_each(requests, &search, &read);            // ucall_server_reply_content per request

API

Types

ucall_body_delivery_tWhen an endpoint's callback runs: once the body is buffered, or at headers time with the body pulled through ucall_server_request_body_chunk().
types.h:170 ↗
enum ucall_body_delivery_t

Values

ucall_body_delivery_buffered_k0The callback runs once the whole body is buffered, within max_request_bytes.
ucall_body_delivery_streamed_k1The callback runs at headers time and pulls the body in chunks.
ucall_received_http_batch_callback_tCallback type for handling batched requests on the server side.
server.h:551 ↗
typedef void(*) ucall_received_http_batch_callback_t(ucall_received_http_request_t const *requests, size_t count, void *context);

Notes

The array is valid only during the callback. Each request stays valid until a reply consumes it or the server is freed, independently of the array and the other requests.

Functions

ucall_server_take_batchInvokes one batch endpoint's callback if a batch is due, with requests from every event loop, on the calling thread.
server.h:404 ↗
void ucall_server_take_batch(ucall_server_take_batch_t *arguments);

UCall creates no thread; a bounded wait sleeps until a deposit, the partial batch's deadline, or the timeout, without polling any event loop.

Parameters

serverucall_server_tInitialized server that registered endpoint.
outcomeucall_outcome_t *Outcome of this round.
endpointucall_http_batch_endpoint_tEndpoint from ucall_server_add_http_batch_endpoint(); each has one polling owner.
timeout_microsecondssize_tMaximum wait for a due batch; zero performs one nonblocking round.

Statuses

ucall_server_take_batchesInvokes one batch endpoint's due callbacks on the calling thread, sleeping in between, until ucall_server_stop().
server.h:428 ↗
void ucall_server_take_batches(ucall_server_take_batches_t *arguments);

Requests still queued then are released without a callback.

Parameters

serverucall_server_tInitialized server that registered endpoint.
outcomeucall_outcome_t *Final outcome after polling stops.
endpointucall_http_batch_endpoint_tEndpoint from ucall_server_add_http_batch_endpoint(); each has one polling owner.

Statuses