Struct mz_adapter::catalog::storage::Connection
source · 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
impl Connection
sourcepub async fn open(
stash: Stash,
now: NowFn,
bootstrap_args: &BootstrapArgs,
deploy_generation: Option<u64>
) -> Result<Connection, Error>
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.
async fn open_inner( stash: Stash, now: NowFn, bootstrap_args: &BootstrapArgs, deploy_generation: Option<u64> ) -> Result<Connection, (Stash, Error)>
pub(crate) async fn set_connect_timeout(&mut self, connect_timeout: Duration)
pub(crate) fn is_read_only(&self) -> bool
async fn get_setting(&mut self, key: &str) -> Result<Option<String>, Error>
async fn set_setting(&mut self, key: &str, value: &str) -> Result<(), Error>
pub async fn get_catalog_content_version( &mut self ) -> Result<Option<String>, Error>
pub async fn set_catalog_content_version( &mut self, new_version: &str ) -> Result<(), Error>
pub async fn load_databases(&mut self) -> Result<Vec<Database>, Error>
pub async fn load_schemas(&mut self) -> Result<Vec<Schema>, Error>
pub async fn load_roles(&mut self) -> Result<Vec<Role>, Error>
pub async fn load_clusters(&mut self) -> Result<Vec<Cluster>, Error>
pub async fn load_cluster_replicas( &mut self ) -> Result<Vec<ClusterReplica>, Error>
pub async fn load_audit_log( &mut self ) -> Result<impl Iterator<Item = VersionedEvent>, Error>
sourcepub async fn fetch_and_prune_storage_usage(
&mut self,
retention_period: Option<Duration>,
boot_ts: Timestamp
) -> Result<Vec<VersionedStorageUsage>, Error>
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.
sourcepub async fn load_system_gids(
&mut self
) -> Result<BTreeMap<(String, CatalogItemType, String), (GlobalId, String)>, Error>
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).
pub async fn load_introspection_source_index_gids( &mut self, cluster_id: ClusterId ) -> Result<BTreeMap<String, GlobalId>, Error>
sourcepub async fn load_default_privileges(
&mut self
) -> Result<Vec<(DefaultPrivilegeObject, DefaultPrivilegeAclItem)>, Error>
pub async fn load_default_privileges( &mut self ) -> Result<Vec<(DefaultPrivilegeObject, DefaultPrivilegeAclItem)>, Error>
Load the persisted default privileges.
sourcepub async fn load_system_privileges(&mut self) -> Result<Vec<MzAclItem>, Error>
pub async fn load_system_privileges(&mut self) -> Result<Vec<MzAclItem>, Error>
Load the persisted system privileges.
sourcepub async fn load_system_configuration(
&mut self
) -> Result<BTreeMap<String, String>, Error>
pub async fn load_system_configuration( &mut self ) -> Result<BTreeMap<String, String>, Error>
Load the persisted server configurations.
sourcepub async fn load_comments(
&mut self
) -> Result<Vec<(CommentObjectId, Option<usize>, String)>, Error>
pub async fn load_comments( &mut self ) -> Result<Vec<(CommentObjectId, Option<usize>, String)>, Error>
Load all comments.
sourcepub async fn set_system_object_mapping(
&mut self,
mappings: Vec<SystemObjectMapping>
) -> Result<(), Error>
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.
sourcepub async fn set_introspection_source_index_gids(
&mut self,
mappings: Vec<(ClusterId, &str, GlobalId)>
) -> Result<(), Error>
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
sourcepub async fn set_replica_config(
&mut self,
replica_id: ReplicaId,
cluster_id: ClusterId,
name: String,
config: ReplicaConfig,
owner_id: RoleId
) -> Result<(), Error>
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
pub async fn allocate_system_ids( &mut self, amount: u64 ) -> Result<Vec<GlobalId>, Error>
pub async fn allocate_user_id(&mut self) -> Result<GlobalId, Error>
pub async fn allocate_system_cluster_id(&mut self) -> Result<ClusterId, Error>
pub async fn allocate_user_cluster_id(&mut self) -> Result<ClusterId, Error>
pub async fn allocate_user_replica_id(&mut self) -> Result<ReplicaId, Error>
sourcepub async fn get_next_system_replica_id(&mut self) -> Result<u64, Error>
pub async fn get_next_system_replica_id(&mut self) -> Result<u64, Error>
Get the next system replica id without allocating it.
sourcepub async fn get_next_user_replica_id(&mut self) -> Result<u64, Error>
pub async fn get_next_user_replica_id(&mut self) -> Result<u64, Error>
Get the next user replica id without allocating it.
async fn get_next_id(&mut self, id_type: &str) -> Result<u64, Error>
async fn allocate_id( &mut self, id_type: &str, amount: u64 ) -> Result<Vec<u64>, Error>
sourcepub async fn try_get_persisted_timestamp(
&mut self,
timeline: &Timeline
) -> Result<Option<Timestamp>, Error>
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.
sourcepub async fn get_all_persisted_timestamps(
&mut self
) -> Result<BTreeMap<Timeline, Timestamp>, Error>
pub async fn get_all_persisted_timestamps( &mut self ) -> Result<BTreeMap<Timeline, Timestamp>, Error>
Get all global timestamps that has been persisted to disk.
sourcepub async fn persist_timestamp(
&mut self,
timeline: &Timeline,
timestamp: Timestamp
) -> Result<(), Error>
pub async fn persist_timestamp( &mut self, timeline: &Timeline, timestamp: Timestamp ) -> Result<(), Error>
Persist new global timestamp for a timeline to disk.
pub async fn persist_deploy_generation( &mut self, deploy_generation: u64 ) -> Result<(), Error>
sourcepub async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>
pub async fn transaction<'a>(&'a mut self) -> Result<Transaction<'a>, Error>
Creates a new Transaction
.
sourcepub async fn confirm_leadership(&mut self) -> Result<(), Error>
pub async fn confirm_leadership(&mut self) -> Result<(), Error>
Confirms that this Connection
is connected as the stash leader.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl !UnwindSafe for Connection
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
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.