pub enum PGConnection {
Pool(Pool<Postgres>, Cache<VersionId, Resource>),
Transaction(Arc<Mutex<Transaction<'static, Postgres>>>, Cache<VersionId, Resource>, PendingRows),
}Expand description
Connection types supported by the repository traits.
Variants§
Pool(Pool<Postgres>, Cache<VersionId, Resource>)
Transaction(Arc<Mutex<Transaction<'static, Postgres>>>, Cache<VersionId, Resource>, PendingRows)
Implementations§
Trait Implementations§
Source§impl AsyncJobProvider for PGConnection
impl AsyncJobProvider for PGConnection
Source§async fn create_job(
&self,
tenant: &TenantId,
project: &ProjectId,
job: CreateAsyncJob,
) -> Result<AsyncJob, OperationOutcomeError>
async fn create_job( &self, tenant: &TenantId, project: &ProjectId, job: CreateAsyncJob, ) -> Result<AsyncJob, OperationOutcomeError>
Queues a job. Its id is generated here and is what the status URL
carries.
Source§async fn read_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> Result<Option<AsyncJob>, OperationOutcomeError>
async fn read_job( &self, tenant: &TenantId, project: &ProjectId, id: &str, ) -> Result<Option<AsyncJob>, OperationOutcomeError>
A job of this project, whatever its state, until it expires.
Source§async fn count_live_jobs(
&self,
tenant: &TenantId,
project: &ProjectId,
) -> Result<i64, OperationOutcomeError>
async fn count_live_jobs( &self, tenant: &TenantId, project: &ProjectId, ) -> Result<i64, OperationOutcomeError>
Jobs of this project that are queued or running. Kick-offs cap this.
Source§async fn cancel_job(
&self,
tenant: &TenantId,
project: &ProjectId,
id: &str,
) -> Result<Option<AsyncJob>, OperationOutcomeError>
async fn cancel_job( &self, tenant: &TenantId, project: &ProjectId, id: &str, ) -> Result<Option<AsyncJob>, OperationOutcomeError>
Cancels a job of this project. A queued job never runs; a running one
finds out at its next lease renewal; a finished one gives up its
result. Returns the job as it was before, or
None if there is no
such job or it was already cancelled.Source§async fn claim_job(
&self,
kinds: &[&str],
lease: &JobLease,
) -> Result<Option<AsyncJob>, OperationOutcomeError>
async fn claim_job( &self, kinds: &[&str], lease: &JobLease, ) -> Result<Option<AsyncJob>, OperationOutcomeError>
Takes the oldest claimable job of one of
kinds for lease.worker:
queued, or in progress with a lapsed lease, and with attempts left.
Claiming is one statement, so two workers never take the same job.Source§async fn renew_lease(
&self,
id: &str,
lease: &JobLease,
progress: Option<&str>,
) -> Result<LeaseRenewal, OperationOutcomeError>
async fn renew_lease( &self, id: &str, lease: &JobLease, progress: Option<&str>, ) -> Result<LeaseRenewal, OperationOutcomeError>
Extends the lease on a job this worker holds and records
progress
if given. Lost means stop: the job was cancelled or taken over.Source§async fn finish_job(
&self,
id: &str,
worker: &str,
result: JobResult,
retention: Duration,
) -> Result<bool, OperationOutcomeError>
async fn finish_job( &self, id: &str, worker: &str, result: JobResult, retention: Duration, ) -> Result<bool, OperationOutcomeError>
Records the result of a job this worker holds and releases the lease.
Returns false if the job was no longer this worker’s to finish (it
was cancelled or taken over meanwhile), in which case the result is
dropped.
Source§impl Clone for PGConnection
impl Clone for PGConnection
Source§impl Debug for PGConnection
impl Debug for PGConnection
Source§impl FHIRRepository for PGConnection
impl FHIRRepository for PGConnection
async fn create( &self, tenant: &TenantId, project: &ProjectId, author: &UserTokenClaims, fhir_version: &SupportedFHIRVersions, resource: Resource, ) -> Result<Resource, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, project: &ProjectId, author: &UserTokenClaims, fhir_version: &SupportedFHIRVersions, resource: Resource, id: &str, ) -> Result<Resource, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, project: &ProjectId, author: &UserTokenClaims, fhir_version: &SupportedFHIRVersions, resource: Resource, id: &str, ) -> Result<Resource, OperationOutcomeError>
async fn read_by_version_ids( &self, tenant_id: &TenantId, project_id: &ProjectId, version_ids: &[&VersionId], cache_policy: CachePolicy, ) -> Result<Vec<Resource>, OperationOutcomeError>
async fn read_latest( &self, tenant_id: &TenantId, project_id: &ProjectId, resource_type: &ResourceType, resource_id: &ResourceId, ) -> Result<Option<Resource>, OperationOutcomeError>
Source§async fn read_latest_many(
&self,
tenant_id: &TenantId,
project_id: &ProjectId,
keys: &[(ResourceType, ResourceId)],
) -> Result<Vec<Resource>, OperationOutcomeError>
async fn read_latest_many( &self, tenant_id: &TenantId, project_id: &ProjectId, keys: &[(ResourceType, ResourceId)], ) -> Result<Vec<Resource>, OperationOutcomeError>
Self::read_latest for many keys in one round trip: the current
version of each (type, id) that exists and is not deleted, in no
particular order. A key that does not resolve is left out.async fn history( &self, tenant_id: &TenantId, project_id: &ProjectId, request: &HistoryRequest, ) -> Result<Vec<ResourceHistoryValue>, OperationOutcomeError>
fn in_transaction(&self) -> bool
async fn transaction( &self, is_updating_sequence: bool, ) -> Result<Self, OperationOutcomeError>
async fn commit(self) -> Result<(), OperationOutcomeError>
async fn rollback(self) -> Result<(), OperationOutcomeError>
Source§impl FailedIndexingProvider for PGConnection
impl FailedIndexingProvider for PGConnection
Source§async fn record_failures(
&self,
failures: &[FailedIndexRecord],
) -> Result<(), OperationOutcomeError>
async fn record_failures( &self, failures: &[FailedIndexRecord], ) -> Result<(), OperationOutcomeError>
Durably records resources that failed search indexing so they can be
skipped (instead of retried forever) and inspected later. No-op on an
empty list.
Source§impl Login for PGConnection
impl Login for PGConnection
async fn login( &self, tenant: &TenantId, method: &LoginMethod, ) -> Result<LoginResult, OperationOutcomeError>
Source§impl Migrate for PGConnection
impl Migrate for PGConnection
Source§impl<Key: AsRef<str> + Send + Sync> ProjectModelAdmin<CreateAuthorizationCode, AuthorizationCode, AuthorizationCodeSearchClaims, AuthorizationCode, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> ProjectModelAdmin<CreateAuthorizationCode, AuthorizationCode, AuthorizationCodeSearchClaims, AuthorizationCode, Key> for PGConnection
async fn create( &self, tenant: &TenantId, project: &ProjectId, authorization_code: CreateAuthorizationCode, ) -> Result<AuthorizationCode, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, project: &ProjectId, code: &Key, ) -> Result<Option<AuthorizationCode>, OperationOutcomeError>
fn update( &self, _tenant: &TenantId, _project: &ProjectId, _model: AuthorizationCode, ) -> impl Future<Output = Result<AuthorizationCode, OperationOutcomeError>>
async fn delete( &self, tenant: &TenantId, project: &ProjectId, code: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, project: &ProjectId, clauses: &AuthorizationCodeSearchClaims, ) -> Result<Vec<AuthorizationCode>, OperationOutcomeError>
Source§impl<Key: AsRef<str> + Send + Sync> ProjectModelAdmin<CreateMembership, Membership, MembershipSearchClaims, Membership, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> ProjectModelAdmin<CreateMembership, Membership, MembershipSearchClaims, Membership, Key> for PGConnection
async fn create( &self, tenant: &TenantId, project: &ProjectId, new_membership: CreateMembership, ) -> Result<Membership, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, project: &ProjectId, id: &Key, ) -> Result<Option<Membership>, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, project: &ProjectId, model: Membership, ) -> Result<Membership, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, project: &ProjectId, id: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, project: &ProjectId, clauses: &MembershipSearchClaims, ) -> Result<Vec<Membership>, OperationOutcomeError>
Source§impl ProjectModelAdmin<CreateScope, Scope, ScopeSearchClaims, UpdateScope, ScopeKey> for PGConnection
impl ProjectModelAdmin<CreateScope, Scope, ScopeSearchClaims, UpdateScope, ScopeKey> for PGConnection
async fn create( &self, tenant: &TenantId, project: &ProjectId, new_scope: CreateScope, ) -> Result<Scope, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, project: &ProjectId, key: &ScopeKey, ) -> Result<Option<Scope>, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, project: &ProjectId, model: UpdateScope, ) -> Result<Scope, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, project: &ProjectId, key: &ScopeKey, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, project: &ProjectId, clauses: &ScopeSearchClaims, ) -> Result<Vec<Scope>, OperationOutcomeError>
Source§impl RateLimit for PGConnection
impl RateLimit for PGConnection
Source§fn check<'a>(
&'a self,
rate_key: &'a str,
max: i32,
points: i32,
window_in_seconds: i32,
) -> Pin<Box<dyn Future<Output = Result<i32, RateLimitError>> + Send + 'a>>
fn check<'a>( &'a self, rate_key: &'a str, max: i32, points: i32, window_in_seconds: i32, ) -> Pin<Box<dyn Future<Output = Result<i32, RateLimitError>> + Send + 'a>>
Returns the current points after the operation. Note use of box and pin so can satisfy dynamic dispatch requirements.
Source§fn check_uncached<'a>(
&'a self,
rate_key: &'a str,
max: i32,
points: i32,
window_in_seconds: i32,
) -> Pin<Box<dyn Future<Output = Result<i32, RateLimitError>> + Send + 'a>>
fn check_uncached<'a>( &'a self, rate_key: &'a str, max: i32, points: i32, window_in_seconds: i32, ) -> Pin<Box<dyn Future<Output = Result<i32, RateLimitError>> + Send + 'a>>
Goes straight to Postgres, skipping [MEMORY]. check_rate_limit takes
a per-key advisory transaction lock, so concurrent callers are counted
one at a time with no lost increments. The in-memory cache is what makes
[RateLimit::check] fast but imprecise under a burst; this trades that
for an exact count on every call.
impl Repository for PGConnection
Source§impl ResourceSequential for PGConnection
impl ResourceSequential for PGConnection
Source§async fn max_safe_sequence(&self) -> Result<i64, OperationOutcomeError>
async fn max_safe_sequence(&self) -> Result<i64, OperationOutcomeError>
The highest
resources.sequence a consumer may read up to without
skipping a row that is still being written: every row at or below it
that will ever commit is visible to any snapshot taken after this call
returns.Source§async fn get_sequence(
&self,
tenant_id: &TenantId,
project_id: &ProjectId,
sequence_id: u64,
safe_sequence: i64,
count: Option<u64>,
) -> Result<Vec<ResourcePollingValue>, OperationOutcomeError>
async fn get_sequence( &self, tenant_id: &TenantId, project_id: &ProjectId, sequence_id: u64, safe_sequence: i64, count: Option<u64>, ) -> Result<Vec<ResourcePollingValue>, OperationOutcomeError>
The project’s rows with
sequence_id < sequence <= safe_sequence, in
sequence order. safe_sequence must come from a
max_safe_sequence call that returned
before this query’s snapshot was taken.Source§impl SystemAdmin<User, UserSearchClauses> for PGConnection
impl SystemAdmin<User, UserSearchClauses> for PGConnection
Source§impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateAuthorizationCode, AuthorizationCode, AuthorizationCodeSearchClaims, AuthorizationCode, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateAuthorizationCode, AuthorizationCode, AuthorizationCodeSearchClaims, AuthorizationCode, Key> for PGConnection
async fn create( &self, tenant: &TenantId, authorization_code: CreateAuthorizationCode, ) -> Result<AuthorizationCode, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, code: &Key, ) -> Result<Option<AuthorizationCode>, OperationOutcomeError>
fn update( &self, _tenant: &TenantId, _model: AuthorizationCode, ) -> impl Future<Output = Result<AuthorizationCode, OperationOutcomeError>>
async fn delete( &self, tenant: &TenantId, code: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, clauses: &AuthorizationCodeSearchClaims, ) -> Result<Vec<AuthorizationCode>, OperationOutcomeError>
Source§impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateProject, Project, ProjectSearchClaims, Project, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateProject, Project, ProjectSearchClaims, Project, Key> for PGConnection
async fn create( &self, tenant: &TenantId, new_project: CreateProject, ) -> Result<Project, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, id: &Key, ) -> Result<Option<Project>, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, model: Project, ) -> Result<Project, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, id: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, claims: &ProjectSearchClaims, ) -> Result<Vec<Project>, OperationOutcomeError>
Source§impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateTenant, Tenant, TenantSearchClaims, Tenant, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateTenant, Tenant, TenantSearchClaims, Tenant, Key> for PGConnection
async fn create( &self, _tenant: &TenantId, new_tenant: CreateTenant, ) -> Result<Tenant, OperationOutcomeError>
async fn read( &self, _tenant: &TenantId, id: &Key, ) -> Result<Option<Tenant>, OperationOutcomeError>
async fn update( &self, _tenant: &TenantId, model: Tenant, ) -> Result<Tenant, OperationOutcomeError>
async fn delete( &self, _tenant: &TenantId, id: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, _tenant: &TenantId, claims: &TenantSearchClaims, ) -> Result<Vec<Tenant>, OperationOutcomeError>
Source§impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateUser, User, UserSearchClauses, UpdateUser, Key> for PGConnection
impl<Key: AsRef<str> + Send + Sync> TenantModelAdmin<CreateUser, User, UserSearchClauses, UpdateUser, Key> for PGConnection
async fn create( &self, tenant: &TenantId, new_user: CreateUser, ) -> Result<User, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, id: &Key, ) -> Result<Option<User>, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, user: UpdateUser, ) -> Result<User, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, id: &Key, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, clauses: &UserSearchClauses, ) -> Result<Vec<User>, OperationOutcomeError>
Source§impl TenantModelAdmin<UserMFACredentialCreate, UserMFACredential, UserMFASearchClaims, UserMFACredentialUpdate, MFAKey> for PGConnection
impl TenantModelAdmin<UserMFACredentialCreate, UserMFACredential, UserMFASearchClaims, UserMFACredentialUpdate, MFAKey> for PGConnection
async fn create( &self, tenant: &TenantId, new_user_mfa_credential: UserMFACredentialCreate, ) -> Result<UserMFACredential, OperationOutcomeError>
async fn read( &self, tenant: &TenantId, id: &MFAKey, ) -> Result<Option<UserMFACredential>, OperationOutcomeError>
async fn update( &self, tenant: &TenantId, model: UserMFACredentialUpdate, ) -> Result<UserMFACredential, OperationOutcomeError>
async fn delete( &self, tenant: &TenantId, id: &MFAKey, ) -> Result<(), OperationOutcomeError>
async fn search( &self, tenant: &TenantId, claims: &UserMFASearchClaims, ) -> Result<Vec<UserMFACredential>, OperationOutcomeError>
Auto Trait Implementations§
impl !RefUnwindSafe for PGConnection
impl !UnwindSafe for PGConnection
impl Freeze for PGConnection
impl Send for PGConnection
impl Sync for PGConnection
impl Unpin for PGConnection
impl UnsafeUnpin for PGConnection
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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