Skip to main content

SchemaStore

Trait SchemaStore 

Source
pub trait SchemaStore:
    Send
    + Sync
    + 'static {
    // Required methods
    fn put_version(
        &self,
        version: SchemaVersion,
    ) -> impl Future<Output = SchemaVersion> + Send;
    fn get_version(
        &self,
        id: &SchemaVersionId,
    ) -> impl Future<Output = Option<SchemaVersion>> + Send;
    fn latest_version_for_method(
        &self,
        upstream_id: &str,
        method: &str,
    ) -> impl Future<Output = Option<SchemaVersion>> + Send;
    fn list_versions(
        &self,
        upstream_id: &str,
        method: &str,
    ) -> impl Future<Output = Vec<SchemaVersion>> + Send;

    // Provided method
    fn prune(
        &self,
        _upstream_id: &str,
        _method: &str,
        _keep: usize,
    ) -> impl Future<Output = ()> + Send { ... }
}
Expand description

Trait for schema version storage backends.

Implementations must be Send + Sync + 'static so a single store can back many concurrent SchemaManager readers.

Required Methods§

Source

fn put_version( &self, version: SchemaVersion, ) -> impl Future<Output = SchemaVersion> + Send

Insert a new version. Implementations handle retention / eviction. Returns the stored version (the caller may not have populated version correctly — implementations may assign it).

Source

fn get_version( &self, id: &SchemaVersionId, ) -> impl Future<Output = Option<SchemaVersion>> + Send

Fetch a specific version by id. None if never stored or evicted.

Source

fn latest_version_for_method( &self, upstream_id: &str, method: &str, ) -> impl Future<Output = Option<SchemaVersion>> + Send

Latest version for a given (upstream_id, method).

Source

fn list_versions( &self, upstream_id: &str, method: &str, ) -> impl Future<Output = Vec<SchemaVersion>> + Send

All versions for a given (upstream_id, method), newest first. Bounded by the store’s retention policy.

Provided Methods§

Source

fn prune( &self, _upstream_id: &str, _method: &str, _keep: usize, ) -> impl Future<Output = ()> + Send

Drop versions older than keep for (upstream_id, method). Idempotent. Default impl is a no-op for stores without explicit pruning.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§