pub struct Connection {
    stash: Stash,
}
Expand description

A Connection represent an open connection to the stash. It exposes optimized methods for executing a single operation against the stash. If the consumer needs to execute multiple operations atomically, then they should start a transaction via Connection::transaction.

The super::Catalog should never interact directly through the stash, instead it should always interact through a Connection.

Fields§

§stash: Stash

Implementations§

source§

impl Connection

source

pub async fn open( stash: Stash, now: NowFn, bootstrap_args: &BootstrapArgs, deploy_generation: Option<u64> ) -> Result<Connection, Error>

Opens a new Connection to the stash. Optionally initialize the stash if it has not been initialized and perform any migrations needed.

source

async fn open_inner( stash: Stash, now: NowFn, bootstrap_args: &BootstrapArgs, deploy_generation: Option<u64> ) -> Result<Connection, (Stash, Error)>

source

pub(crate) async fn set_connect_timeout(&mut self, connect_timeout: Duration)

source

pub(crate) fn is_read_only(&self) -> bool

source

async fn get_setting(&mut self, key: &str) -> Result<Option<String>, Error>

source

async fn set_setting(&mut self, key: &str, value: &str) -> Result<(), Error>

source

pub async fn get_catalog_content_version( &mut self ) -> Result<Option<String>, Error>

source

pub async fn set_catalog_content_version( &mut self, new_version: &str ) -> Result<(), Error>

source

pub async fn load_databases(&mut self) -> Result<Vec<Database>, Error>

source

pub async fn load_schemas(&mut self) -> Result<Vec<Schema>, Error>

source

pub async fn load_roles(&mut self) -> Result<Vec<Role>, Error>

source

pub async fn load_clusters(&mut self) -> Result<Vec<Cluster>, Error>

source

pub async fn load_cluster_replicas( &mut self ) -> Result<Vec<ClusterReplica>, Error>

source

pub async fn load_audit_log( &mut self ) -> Result<impl Iterator<Item = VersionedEvent>, Error>

source

pub async fn fetch_and_prune_storage_usage( &mut self, retention_period: Option<Duration>, boot_ts: Timestamp ) -> Result<Vec<VersionedStorageUsage>, Error>

Loads storage usage events and permanently deletes from the stash those that happened more than the retention period ago from boot_ts.

source

pub async fn load_system_gids( &mut self ) -> Result<BTreeMap<(String, CatalogItemType, String), (GlobalId, String)>, Error>

Load the persisted mapping of system object to global ID. Key is (schema-name, object-name).

source

pub async fn load_introspection_source_index_gids( &mut self, cluster_id: ClusterId ) -> Result<BTreeMap<String, GlobalId>, Error>

source

pub async fn load_default_privileges( &mut self ) -> Result<Vec<(DefaultPrivilegeObject, DefaultPrivilegeAclItem)>, Error>

Load the persisted default privileges.

source

pub async fn load_system_privileges(&mut self) -> Result<Vec<MzAclItem>, Error>

Load the persisted system privileges.

source

pub async fn load_system_configuration( &mut self ) -> Result<BTreeMap<String, String>, Error>

Load the persisted server configurations.

source

pub async fn load_comments( &mut self ) -> Result<Vec<(CommentObjectId, Option<usize>, String)>, Error>

Load all comments.

source

pub async fn set_system_object_mapping( &mut self, mappings: Vec<SystemObjectMapping> ) -> Result<(), Error>

Persist mapping from system objects to global IDs and fingerprints.

Panics if provided id is not a system id.

source

pub async fn set_introspection_source_index_gids( &mut self, mappings: Vec<(ClusterId, &str, GlobalId)> ) -> Result<(), Error>

Panics if provided id is not a system id

source

pub async fn set_replica_config( &mut self, replica_id: ReplicaId, cluster_id: ClusterId, name: String, config: ReplicaConfig, owner_id: RoleId ) -> Result<(), Error>

Set the configuration of a replica. This accepts only one item, as we currently use this only for the default cluster

source

pub async fn allocate_system_ids( &mut self, amount: u64 ) -> Result<Vec<GlobalId>, Error>

source

pub async fn allocate_user_id(&mut self) -> Result<GlobalId, Error>

source

pub async fn allocate_system_cluster_id(&mut self) -> Result<ClusterId, Error>

source

pub async fn allocate_user_cluster_id(&mut self) -> Result<ClusterId, Error>

source

pub async fn allocate_user_replica_id(&mut self) -> Result<ReplicaId, Error>

source

pub async fn get_next_system_replica_id(&mut self) -> Result<u64, Error>

Get the next system replica id without allocating it.

source

pub async fn get_next_user_replica_id(&mut self) -> Result<u64, Error>

Get the next user replica id without allocating it.

source

async fn get_next_id(&mut self, id_type: &str) -> Result<u64, Error>

source

async fn allocate_id( &mut self, id_type: &str, amount: u64 ) -> Result<Vec<u64>, Error>

source

pub async fn try_get_persisted_timestamp( &mut self, timeline: &Timeline ) -> Result<Option<Timestamp>, Error>

Gets a global timestamp for a timeline that has been persisted to disk.

Returns None if no persisted timestamp for the specified timeline exists.

source

pub async fn get_all_persisted_timestamps( &mut self ) -> Result<BTreeMap<Timeline, Timestamp>, Error>

Get all global timestamps that has been persisted to disk.

source

pub async fn persist_timestamp( &mut self, timeline: &Timeline, timestamp: Timestamp ) -> Result<(), Error>

Persist new global timestamp for a timeline to disk.

source

pub async fn persist_deploy_generation( &mut self, deploy_generation: u64 ) -> Result<(), Error>

source

pub async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>

Creates a new Transaction.

source

pub async fn confirm_leadership(&mut self) -> Result<(), Error>

Confirms that this Connection is connected as the stash leader.

Trait Implementations§

source§

impl Debug for Connection

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
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 Twhere 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> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Pointable for T

source§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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<V, T> VZip<V> for Twhere V: MultiLane<T>,

source§

fn vzip(self) -> V

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
source§

impl<T> DebuggableStorage for Twhere T: Any + Send + Sync + Debug,