#[non_exhaustive]pub struct SourceCtx {
pub issuer: AckIssuer,
pub meter: Option<Meter>,
pub stage_metrics: Option<Arc<SourceMetrics>>,
pub per_partition_detail: bool,
}Expand description
Everything a source receives at Source::open.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.issuer: AckIssuerIssuer for batch acknowledgement handles. Sources clone it into
every lane they construct; each lane issues one AckRef per poll
batch (issue(partition, last_offset)).
meter: Option<Meter>A Meter scoped spate_<component_type>_source_* for the source’s own
metric families (e.g. consumer lag, broker statistics), pre-labelled
with the standard pipeline/component/component_type. None unless
the source declared a Source::component_type that is a usable,
non-reserved namespace — a reserved default ("source") opts out
silently, a malformed value is logged and also yields None. Resolve
handles from it once here in open; never on the poll path.
stage_metrics: Option<Arc<SourceMetrics>>The framework’s own source-stage handles (spate_source_*), shared with
the controller. A source that can observe its own consumer lag
publishes it here — SourceMetrics::set_partition_lag and
SourceMetrics::retain_partitions have no other caller, because the
framework cannot compute lag without the client’s view of the log end,
nor tell which partitions the client still owns. None only when the
source is driven outside a pipeline (tests, or a direct open call),
in which case lag simply goes unpublished.
Everything else on these handles — records, bytes, poll duration, rebalances, active lanes — is recorded by the runtime itself; a source must not touch those.
per_partition_detail: boolWhether cardinality-sensitive per-partition series are enabled
(metrics.per_partition_detail). Gates a connector’s own per-partition
families: when false, register and emit only aggregate
(per-component or per-broker) series. It does not gate
spate_source_lag_records — consumer lag has no aggregate series to fall
back to, so it always publishes per partition.
Implementations§
Source§impl SourceCtx
impl SourceCtx
Sourcepub fn new(issuer: AckIssuer) -> Self
pub fn new(issuer: AckIssuer) -> Self
Context wrapping the checkpointer’s issuer. The custom-metrics
meter is None; the runtime attaches one via
with_meter.
Sourcepub fn with_meter(self, meter: Option<Meter>) -> Self
pub fn with_meter(self, meter: Option<Meter>) -> Self
Attach the source’s custom-metrics scope. Called by the runtime, which
builds it from the source’s component_type.
Sourcepub fn with_stage_metrics(self, metrics: Option<Arc<SourceMetrics>>) -> Self
pub fn with_stage_metrics(self, metrics: Option<Arc<SourceMetrics>>) -> Self
Share the framework’s source-stage handles so the source can publish the one series only it can measure: consumer lag. Called by the runtime with the same instance the controller records against.
Sourcepub fn with_partition_detail(self, enabled: bool) -> Self
pub fn with_partition_detail(self, enabled: bool) -> Self
Enable cardinality-sensitive per-partition series. Called by the
runtime from metrics.per_partition_detail.