PostgresDb

Struct PostgresDb 

Source
pub struct PostgresDb<Config>
where Config: Config,
{ /* private fields */ }

Implementations§

Source§

impl<Config> PostgresDb<Config>
where Config: Config,

Source

pub async fn connect( db: Pool<Postgres>, cache_watermark: usize, ) -> Result<Arc<CacheDb<PostgresDb<Config>>>, Error>

Source

pub async fn update_users_who_can_read<C>( &self, requested_by: ObjectId, object_id: ObjectId, cb: &C, ) -> Result<ReadPermsChanges, Error>
where C: CanDoCallbacks,

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> Db for PostgresDb<Config>
where Config: Config,

Source§

async fn reencode_old_versions<T>(&self) -> usize
where T: Object,

Returns the number of errors that happened while re-encoding

Source§

async fn create<T>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Option<Updatedness>, _importance: Importance, ) -> Result<Option<Arc<T>>, Error>
where T: Object,

Returns the new latest snapshot if it actually changed Read more
Source§

async fn submit<T>( &self, object_id: ObjectId, event_id: EventId, event: Arc<<T as Object>::Event>, updatedness: Option<Updatedness>, _additional_importance: Importance, ) -> Result<Option<Arc<T>>, Error>
where T: Object,

Returns the new latest snapshot if it actually changed Read more
Source§

async fn get_latest<T>( &self, object_id: ObjectId, _importance: Importance, ) -> Result<Arc<T>, Error>
where T: Object,

Source§

async fn create_binary( &self, binary_id: BinPtr, data: Arc<[u8]>, ) -> Result<(), Error>

Source§

async fn get_binary( &self, binary_id: BinPtr, ) -> Result<Option<Arc<[u8]>>, Error>

Source§

async fn assert_invariants_generic(&self)

Source§

async fn assert_invariants_for<T>(&self)
where T: Object,

Source§

impl<Config> ServerSideDb for PostgresDb<Config>
where Config: Config,

Source§

fn get_users_who_can_read<'a, 'ret, T, C>( &'ret self, object_id: ObjectId, object: &'a T, cb: &'a C, ) -> Pin<Box<dyn Future<Output = Result<UsersWhoCanRead<<PostgresDb<Config> as ServerSideDb>::Lock<'ret>>, Error>> + 'a>>
where 'ret: 'a, T: Object, C: CanDoCallbacks,

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<(), Error>

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.

Source§

type Connection = PgConnection

Source§

type Transaction<'a> = Transaction<'a, Postgres>

Source§

type Lock<'a> = (Lock, <LockPool<ObjectId> as Lockable<ObjectId, ()>>::Guard<'a>)

Source§

async fn get_transaction(&self) -> Result<Transaction<'_, Postgres>, Error>

Source§

async fn get_latest_snapshot( &self, transaction: &mut PgConnection, user: User, object_id: ObjectId, ) -> Result<Arc<Value>, Error>

Source§

async fn get_all( &self, transaction: &mut PgConnection, user: User, object_id: ObjectId, only_updated_since: Option<Updatedness>, ) -> Result<ObjectData, Error>

Source§

async fn server_query( &self, user: User, type_id: TypeId, only_updated_since: Option<Updatedness>, query: Arc<Query>, ) -> Result<Vec<ObjectId>, Error>

Source§

async fn recreate_at<'a, T, C>( &'a self, object_id: ObjectId, event_id: EventId, updatedness: Updatedness, cb: &'a C, ) -> Result<Option<(EventId, Arc<T>)>, Error>
where T: Object, C: CanDoCallbacks,

This function assumes that the lock on object_id is already taken Read more
Source§

async fn create_and_return_rdep_changes<T>( &self, object_id: ObjectId, created_at: EventId, object: Arc<T>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>, Error>
where T: Object,

Source§

async fn submit_and_return_rdep_changes<T>( &self, object_id: ObjectId, event_id: EventId, event: Arc<<T as Object>::Event>, updatedness: Updatedness, ) -> Result<Option<(Arc<T>, Vec<ReadPermsChanges>)>, Error>
where T: Object,

Source§

async fn update_pending_rdeps(&self) -> Result<(), Error>

Source§

async fn login_session( &self, session: Session, ) -> Result<(SessionToken, SessionRef), Error>

Source§

async fn resume_session(&self, token: SessionToken) -> Result<Session, Error>

Source§

async fn mark_session_active( &self, token: SessionToken, at: SystemTime, ) -> Result<(), Error>

Source§

async fn rename_session<'a>( &'a self, token: SessionToken, new_name: &'a str, ) -> Result<(), Error>

Source§

async fn list_sessions(&self, user: User) -> Result<Vec<Session>, Error>

Source§

async fn disconnect_session( &self, user: User, session: SessionRef, ) -> Result<(), Error>

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
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<D> CanDoCallbacks for D
where D: Db,

Source§

async fn get<T>(&self, object_id: DbPtr<T>) -> Result<Arc<T>, Error>
where T: Object,

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<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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 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<V, T> VZip<V> for T
where 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> MaybeSendSync for T

Source§

impl<T> Send for T
where T: Send,

Source§

impl<T> Sync for T
where T: Sync,