#[non_exhaustive]pub enum SchemaResolution {
AutoRegister,
LookupOnly,
UseLatestVersion,
}Expand description
How an encoder turns a subject into the identifier it frames with.
This is the single most consequential producer setting, and the one most often wrong in production: the default writes to the registry.
| Mode | Round-trip on a cold subject | Registry permission | Schema on the wire |
|---|---|---|---|
AutoRegister (default) | POST /subjects/{s}/versions | Subject:Write | the encoder’s own |
LookupOnly | POST /subjects/{s} | Subject:Read | the encoder’s own |
UseLatestVersion | GET /subjects/{s}/versions/latest | Subject:Read | the encoder’s own |
The last column is not a typo: no mode changes what is serialised. The
encoder always serialises with the schema it was built with. What changes is
which identifier the frame carries, and whether a mismatch is silently
papered over (AutoRegister creates a new version) or reported
(LookupOnly fails).
This mirrors the Confluent Java serdes’ auto.register.schemas and
use.latest.version properties, including their defaults.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
AutoRegister
Register the encoder’s schema under the subject and use the ID the
registry assigns. Default, matching auto.register.schemas=true.
Registration is idempotent: re-registering identical content returns the
existing ID rather than creating a version. The risk is the case where
the content is not identical — a field added in a local branch, a
namespace typo — where this silently creates a new production version
from a producer process. Prefer LookupOnly
wherever schemas are owned by CI or a migration step.
LookupOnly
Look the schema up without registering it, and fail if it is not there.
Needs only read access. The failure is a not-found error
(is_not_found is true,
is_retryable is false), so a producer
that has drifted from the registry stops at startup instead of writing
records nobody registered a schema for.
Requires the backend to implement
lookup_schema.
UseLatestVersion
Frame with the identifier of the subject’s latest registered version, whatever that currently is.
Matches use.latest.version=true. Use it when schemas are evolved
centrally and producers should follow rather than lead — for instance
when the registry adds a field with a default that consumers already
expect.
The payload is still serialised with the encoder’s own schema. Avro resolution on the consumer side makes that work for a compatible evolution and only for a compatible evolution: if the latest version is not backward-compatible with what this encoder writes, consumers get garbage. Keep the subject’s compatibility level enforcing that, which is the same contract the Java serde relies on.
Unlike the other two modes this is resolved once per subject and then
cached; call invalidate_subject on the encoder to pick up a newer
version without restarting.
Implementations§
Source§impl SchemaResolution
impl SchemaResolution
Sourcepub fn writes_to_registry(self) -> bool
pub fn writes_to_registry(self) -> bool
Whether this mode writes to the registry.
Trait Implementations§
Source§impl Clone for SchemaResolution
impl Clone for SchemaResolution
impl Copy for SchemaResolution
Source§impl Debug for SchemaResolution
impl Debug for SchemaResolution
Source§impl Default for SchemaResolution
impl Default for SchemaResolution
impl Eq for SchemaResolution
Source§impl Hash for SchemaResolution
impl Hash for SchemaResolution
Source§impl PartialEq for SchemaResolution
impl PartialEq for SchemaResolution
impl StructuralPartialEq for SchemaResolution
Auto Trait Implementations§
impl Forget for SchemaResolution
impl Freeze for SchemaResolution
impl RefUnwindSafe for SchemaResolution
impl Send for SchemaResolution
impl Sync for SchemaResolution
impl Unpin for SchemaResolution
impl UnsafeUnpin for SchemaResolution
impl UnwindSafe for SchemaResolution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more