pub struct CodecRegistry { /* private fields */ }Expand description
codec dispatch レジストリ。Arc 越しに S4Service / 複数タスクから共有する想定。
Implementations§
Source§impl CodecRegistry
impl CodecRegistry
Sourcepub fn new(default: CodecKind) -> Self
pub fn new(default: CodecKind) -> Self
default で指定した codec が PUT 時の codec として使われる
(dispatcher が別 kind を選んだ場合は、その kind が登録されていれば優先)。
Sourcepub fn register(&mut self, codec: Arc<dyn Codec>) -> &mut Self
pub fn register(&mut self, codec: Arc<dyn Codec>) -> &mut Self
codec を登録。同じ kind を 2 度登録すると後勝ち。
Sourcepub fn default_kind(&self) -> CodecKind
pub fn default_kind(&self) -> CodecKind
default kind
Sourcepub async fn compress(
&self,
input: Bytes,
kind: CodecKind,
) -> Result<(Bytes, ChunkManifest), CodecError>
pub async fn compress( &self, input: Bytes, kind: CodecKind, ) -> Result<(Bytes, ChunkManifest), CodecError>
指定 kind の codec で compress
Sourcepub async fn decompress(
&self,
input: Bytes,
manifest: &ChunkManifest,
) -> Result<Bytes, CodecError>
pub async fn decompress( &self, input: Bytes, manifest: &ChunkManifest, ) -> Result<Bytes, CodecError>
manifest が指す codec で decompress (本命の dispatch path)
Sourcepub async fn compress_with_telemetry(
&self,
input: Bytes,
kind: CodecKind,
) -> (Result<(Bytes, ChunkManifest), CodecError>, CompressTelemetry)
pub async fn compress_with_telemetry( &self, input: Bytes, kind: CodecKind, ) -> (Result<(Bytes, ChunkManifest), CodecError>, CompressTelemetry)
v0.8 #55: same as Self::compress but additionally returns a
CompressTelemetry describing the operation (codec name,
input/output size, GPU wall-clock seconds for GPU codecs, OOM
flag on failure). Lets s4-server stamp Prometheus metrics
(s4_gpu_compress_seconds, s4_gpu_throughput_bytes_per_sec,
s4_gpu_oom_total) without s4-codec itself depending on the
metrics crate (callback / return-value pattern, keeps the
codec dep tree slim).
On Ok, telemetry has the measured bytes_in / bytes_out and
gpu_seconds = Some(secs) for GPU kinds, None for CPU. On
Err, telemetry has bytes_in = input.len() as u64 and
bytes_out = 0, with oom = true iff the error string matches
the OOM heuristic (crate::looks_like_oom).
Sourcepub async fn decompress_with_telemetry(
&self,
input: Bytes,
manifest: &ChunkManifest,
) -> (Result<Bytes, CodecError>, CompressTelemetry)
pub async fn decompress_with_telemetry( &self, input: Bytes, manifest: &ChunkManifest, ) -> (Result<Bytes, CodecError>, CompressTelemetry)
v0.8 #55: telemetry-returning decompress. Mirrors
Self::compress_with_telemetry for the GET / decompress side
so operators can dashboard GPU decompress p99 separately from
the compress histogram.