Interface SchemaValidationContext
- All Known Implementing Classes:
RecordSchemaValidator
public interface SchemaValidationContext
Everything
SchemaIdValidationCore needs to validate a record: which Schema Registry to
ask, how to derive the subject, and what to validate.
This is deliberately an interface, not a record or a parameter object. Two callers depend on the values being read late, per record:
- In Confluent Cloud,
CloudRecordSchemaValidator.configChangedswaps the Schema Registry client and re-points the subject-name strategies at runtime when the endpoint config rotates. Getters see the new values with no rebuild. - Kora Edge holds one client per LKC and caches the rest of the config per
(lkc, topic). ResolvingschemaRegistry()through the per-LKC map on each call means a rotated SPIFFE credential replaces one entry, rather than stranding a stale client reference inside every per-topic entry that captured it.
An implementation is expected to be long-lived and to answer from fields, so validating a record allocates nothing. Please don't "simplify" this into an immutable value type.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether validation may answer from cache and returnValidationDecision.RETRY.default CachedSchemaLookupThe cache-only lookup backing the async path, or null whenschemaRegistry()cannot serve one.Schema Registry context to qualify subjects with, or null/default for none.org.slf4j.Loggerlogger()Logger to attribute validation failures to.org.apache.kafka.common.utils.TimeBasedSamplerRate limiter for per-record failure logging, so one bad producer cannot flood the log.metrics()Where validation metrics are recorded.io.confluent.kafka.schemaregistry.client.SchemaRegistryClientThe Schema Registry to validate against.io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategysubjectNameStrategy(boolean isKey) The subject-name strategy for the key or the value.booleanbooleanbooleanWhether to look for a schema guid in the record headers before falling back to the payload.
-
Method Details
-
schemaRegistry
io.confluent.kafka.schemaregistry.client.SchemaRegistryClient schemaRegistry()The Schema Registry to validate against. -
subjectNameStrategy
io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy subjectNameStrategy(boolean isKey) The subject-name strategy for the key or the value. -
contextName
String contextName()Schema Registry context to qualify subjects with, or null/default for none. -
validateKey
boolean validateKey() -
validateValue
boolean validateValue() -
validateWithGuid
boolean validateWithGuid()Whether to look for a schema guid in the record headers before falling back to the payload. -
asyncValidationEnabled
boolean asyncValidationEnabled()Whether validation may answer from cache and returnValidationDecision.RETRY. -
metrics
ValidationMetricsRecorder metrics()Where validation metrics are recorded. UseValidationMetricsRecorder.NOOPfor none. -
logger
org.slf4j.Logger logger()Logger to attribute validation failures to. -
loggingSampler
org.apache.kafka.common.utils.TimeBasedSampler loggingSampler()Rate limiter for per-record failure logging, so one bad producer cannot flood the log. -
cachedSchemaLookup
The cache-only lookup backing the async path, or null whenschemaRegistry()cannot serve one. A client opts in by implementingCachedSchemaLookup; a client that does not implement it falls back to the synchronous path rather than silently losing async/RETRY behavior.
-