Skip to main content

SchemaResolution

Enum SchemaResolution 

Source
#[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.

ModeRound-trip on a cold subjectRegistry permissionSchema on the wire
AutoRegister (default)POST /subjects/{s}/versionsSubject:Writethe encoder’s own
LookupOnlyPOST /subjects/{s}Subject:Readthe encoder’s own
UseLatestVersionGET /subjects/{s}/versions/latestSubject:Readthe 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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

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

Source

pub fn writes_to_registry(self) -> bool

Whether this mode writes to the registry.

Trait Implementations§

Source§

impl Clone for SchemaResolution

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for SchemaResolution

Source§

impl Debug for SchemaResolution

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SchemaResolution

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for SchemaResolution

Source§

impl Hash for SchemaResolution

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SchemaResolution

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SchemaResolution

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsOut<T> for T
where T: Copy,

Source§

fn as_out(&mut self) -> Out<'_, T>

Returns an out reference to self.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more