Skip to main content

Crate osproxy_sink

Crate osproxy_sink 

Source
Expand description

Write sink.

Where writes go, isolated from how routing is decided (docs/decisions/008). The Sink trait is the seam: OpenSearchSink writes directly to a cluster, and the future queue-based redundancy mode is a QueueSink drop-in behind the same trait. Epoch stamping is carried on every WriteOp at this boundary (docs/06 §2).

M1 ships the Sink trait, the WriteBatch/WriteAck vocabulary, an in-memory MemorySink for tests and dry-run, and the OpenSearchSink that writes directly to a cluster over a pooled HTTP connection. M2 adds the Reader seam for get-by-id reads (kept separate because a read is always direct-to-cluster, a redundancy QueueSink can absorb writes but cannot answer a read); both MemorySink and OpenSearchSink implement it.

Structs§

CountOutcome
The outcome of a count: the upstream status and the matched document count.
CursorOp
A raw cursor passthrough op (docs/03 §6): forward method path with body to the specific cluster the cursor is pinned to, scroll/PIT continue, clear, or close. Unlike the typed ops, the destination is already resolved (the engine recovered it from the cursor’s signed envelope), so this carries the cluster directly rather than a partition.
CursorOutcome
The outcome of a cursor passthrough: the upstream status and raw body, forwarded back to the client verbatim.
ForwardOp
A verbatim forward whose request body is a stream, not buffered bytes (ADR-014 stage 2): the same destination shape as CursorOp but the body is supplied separately as a ByteBody so it can be piped from the downstream connection straight to the upstream without ever being collected. Used by the tenant-agnostic passthrough path.
MemorySink
A non-persistent Sink/Reader that records batches, stores indexed documents, and acknowledges success.
OpResult
The outcome of a single operation in a batch, positionally aligned with the batch’s operations (so a _bulk response can be re-interleaved in M3).
OpenSearchSink
A Sink that writes directly to OpenSearch clusters over pooled HTTP.
PoolStats
A snapshot of one cluster pool’s connection-reuse counters.
ReadOp
A read-by-id operation against a resolved Target.
ReadOutcome
The outcome of a read: whether the document was found, and its raw upstream body (the document as stored, before the read-path field strip).
SearchOp
A search operation against a resolved Target.
SearchOutcome
The outcome of a search: the upstream status and raw response body (the hits, before the read-path field strip).
StreamingForward
The outcome of a streaming verbatim forward (ADR-014): the upstream status and its response body as a live ByteBody stream, piped back to the client without ever being collected. Unlike CursorOutcome, the body is not materialized here, so this carries no derives (the stream is one-shot).
StreamingSearch
The outcome of a streaming search (ADR-014, final stage): the upstream status and its response body as a live ByteBody, piped back through the engine’s hit transform without ever being collected. Like StreamingForward, the body is one-shot, so this carries no derives.
WriteAck
The acknowledgement for a whole batch: one OpResult per operation, in the batch’s original order.
WriteBatch
A batch of operations destined for one target.
WriteOp
A single write operation against a resolved Target.

Enums§

DocOp
A document-level operation: the already-transformed body plus the constructed id/routing (the tenancy rewrite has already run, docs/04).
SinkError
A failure applying a write at the sink.

Traits§

Reader
Where reads come from.
Sink
Where writes go.

Functions§

buffered
Wraps fully-buffered bytes as a ByteBody. The buffered body is infallible; match never {} discharges its Infallible error into BodyError.
stream_body
Adapts any streaming body into a ByteBody, e.g. the downstream hyper::body::Incoming for a verbatim forward or a streamed _bulk, so its bytes flow through the proxy without buffering (ADR-014).

Type Aliases§

BodyError
The error type the upstream body may surface. A buffered body never errors (Infallible); a streamed verbatim-forward body surfaces the downstream read error here. Boxed so both fit one client type.
ByteBody
A boxed byte-stream body, used both for the request sent to an upstream cluster and as the carrier for a downstream body streamed through the proxy (a verbatim forward, or a _bulk batch the engine frames). Boxed (unsync, the pooled client needs only Send, not Sync) so one type covers buffered bytes, a stream, or a head + stream-tail without changing the pooled client’s type, and so a downstream hyper::body::Incoming (which is Send but not Sync) can be piped straight through (ADR-014).