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.configChanged swaps 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). Resolving schemaRegistry() 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 Type
    Method
    Description
    boolean
    Whether validation may answer from cache and return ValidationDecision.RETRY.
    The cache-only lookup backing the async path, or null when schemaRegistry() cannot serve one.
    Schema Registry context to qualify subjects with, or null/default for none.
    org.slf4j.Logger
    Logger to attribute validation failures to.
    org.apache.kafka.common.utils.TimeBasedSampler
    Rate limiter for per-record failure logging, so one bad producer cannot flood the log.
    Where validation metrics are recorded.
    io.confluent.kafka.schemaregistry.client.SchemaRegistryClient
    The Schema Registry to validate against.
    io.confluent.kafka.serializers.subject.strategy.SubjectNameStrategy
    subjectNameStrategy(boolean isKey)
    The subject-name strategy for the key or the value.
    boolean
     
    boolean
     
    boolean
    Whether 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 return ValidationDecision.RETRY.
    • metrics

      Where validation metrics are recorded. Use ValidationMetricsRecorder.NOOP for 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

      default CachedSchemaLookup cachedSchemaLookup()
      The cache-only lookup backing the async path, or null when schemaRegistry() cannot serve one. A client opts in by implementing CachedSchemaLookup; a client that does not implement it falls back to the synchronous path rather than silently losing async/RETRY behavior.