pub struct PostgresDb<Config: Config> { /* private fields */ }
Implementations§
Source§impl<Config: Config> PostgresDb<Config>
impl<Config: Config> PostgresDb<Config>
pub async fn connect( db: PgPool, cache_watermark: usize, ) -> Result<Arc<CacheDb<PostgresDb<Config>>>>
Sourcepub async fn update_users_who_can_read<C: CanDoCallbacks>(
&self,
requested_by: ObjectId,
object_id: ObjectId,
cb: &C,
) -> Result<ReadPermsChanges>
pub async fn update_users_who_can_read<C: CanDoCallbacks>( &self, requested_by: ObjectId, object_id: ObjectId, cb: &C, ) -> Result<ReadPermsChanges>
Update the list of users who can read object
_lock
is a lock that makes sure object
is not being modified while this executes.
Trait Implementations§
Source§impl<Config: Config> Db for PostgresDb<Config>
impl<Config: Config> Db for PostgresDb<Config>
Source§async fn reencode_old_versions<T: Object>(&self) -> usize
async fn reencode_old_versions<T: Object>(&self) -> usize
Returns the number of errors that happened while re-encoding
Source§async fn create<T: Object>(
&self,
object_id: ObjectId,
created_at: EventId,
object: Arc<T>,
updatedness: Option<Updatedness>,
_importance: Importance,
) -> Result<Option<Arc<T>>>
async fn create<T: Object>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Option<Updatedness>, _importance: Importance, ) -> Result<Option<Arc<T>>>
Returns the new latest snapshot if it actually changed Read more
Source§async fn submit<T: Object>(
&self,
object_id: ObjectId,
event_id: EventId,
event: Arc<T::Event>,
updatedness: Option<Updatedness>,
_additional_importance: Importance,
) -> Result<Option<Arc<T>>>
async fn submit<T: Object>( &self, object_id: ObjectId, event_id: EventId, event: Arc<T::Event>, updatedness: Option<Updatedness>, _additional_importance: Importance, ) -> Result<Option<Arc<T>>>
Returns the new latest snapshot if it actually changed Read more
async fn get_latest<T: Object>( &self, object_id: ObjectId, _importance: Importance, ) -> Result<Arc<T>>
async fn create_binary(&self, binary_id: BinPtr, data: Arc<[u8]>) -> Result<()>
async fn get_binary(&self, binary_id: BinPtr) -> Result<Option<Arc<[u8]>>>
async fn assert_invariants_generic(&self)
async fn assert_invariants_for<T: Object>(&self)
Source§impl<Config: Config> ServerSideDb for PostgresDb<Config>
impl<Config: Config> ServerSideDb for PostgresDb<Config>
Source§fn get_users_who_can_read<'a, 'ret: 'a, T: Object, C: CanDoCallbacks>(
&'ret self,
object_id: ObjectId,
object: &'a T,
cb: &'a C,
) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<Self::Lock<'ret>>>> + 'a>>
fn get_users_who_can_read<'a, 'ret: 'a, T: Object, C: CanDoCallbacks>( &'ret self, object_id: ObjectId, object: &'a T, cb: &'a C, ) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<Self::Lock<'ret>>>> + 'a>>
This function assumes that the lock on object_id
is already taken.
Source§async fn server_vacuum(
&self,
no_new_changes_before: Option<EventId>,
updatedness: Updatedness,
kill_sessions_older_than: Option<SystemTime>,
notify_recreation: impl FnMut(Update, HashSet<User>),
) -> Result<()>
async fn server_vacuum( &self, no_new_changes_before: Option<EventId>, updatedness: Updatedness, kill_sessions_older_than: Option<SystemTime>, notify_recreation: impl FnMut(Update, HashSet<User>), ) -> Result<()>
Cleans up and optimizes up the database
After running this, the database will reject any new change that would happen before
no_new_changes_before
if it is set.
type Connection = PgConnection
type Transaction<'a> = Transaction<'a, Postgres>
type Lock<'a> = (Lock, <LockPool<ObjectId> as Lockable<ObjectId, ()>>::Guard<'a>)
async fn get_transaction(&self) -> Result<Transaction<'_, Postgres>>
async fn get_latest_snapshot( &self, transaction: &mut PgConnection, user: User, object_id: ObjectId, ) -> Result<Arc<Value>>
async fn get_all( &self, transaction: &mut PgConnection, user: User, object_id: ObjectId, only_updated_since: Option<Updatedness>, ) -> Result<ObjectData>
async fn server_query( &self, user: User, type_id: TypeId, only_updated_since: Option<Updatedness>, query: Arc<Query>, ) -> Result<Vec<ObjectId>>
Source§async fn recreate_at<'a, T: Object, C: CanDoCallbacks>(
&'a self,
object_id: ObjectId,
event_id: EventId,
updatedness: Updatedness,
cb: &'a C,
) -> Result<Option<(EventId, Arc<T>)>>
async fn recreate_at<'a, T: Object, C: CanDoCallbacks>( &'a self, object_id: ObjectId, event_id: EventId, updatedness: Updatedness, cb: &'a C, ) -> Result<Option<(EventId, Arc<T>)>>
This function assumes that the lock on
object_id
is already taken Read moreasync fn create_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>
async fn submit_and_return_rdep_changes<T: Object>( &self, object_id: ObjectId, event_id: EventId, event: Arc<T::Event>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>>
async fn update_pending_rdeps(&self) -> Result<()>
async fn login_session( &self, session: Session, ) -> Result<(SessionToken, SessionRef)>
async fn resume_session(&self, token: SessionToken) -> Result<Session>
async fn mark_session_active( &self, token: SessionToken, at: SystemTime, ) -> Result<()>
async fn rename_session<'a>( &'a self, token: SessionToken, new_name: &'a str, ) -> Result<()>
async fn list_sessions(&self, user: User) -> Result<Vec<Session>>
async fn disconnect_session( &self, user: User, session: SessionRef, ) -> Result<()>
Auto Trait Implementations§
impl<Config> !Freeze for PostgresDb<Config>
impl<Config> !RefUnwindSafe for PostgresDb<Config>
impl<Config> Send for PostgresDb<Config>
impl<Config> Sync for PostgresDb<Config>
impl<Config> Unpin for PostgresDb<Config>where
Config: Unpin,
impl<Config> !UnwindSafe for PostgresDb<Config>
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
Mutably borrows from an owned value. Read more
Source§impl<D> CanDoCallbacks for Dwhere
D: Db,
impl<D> CanDoCallbacks for Dwhere
D: Db,
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>
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 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>
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