pub struct Unlock;Expand description
The service’s own Unlock: set by
InboxSpec::own.
§Examples
The service’s own unlock releases what its own lock, own::Lock, took:
use ruststream_sqlx::dialect::{Column, KeyPart};
use ruststream_sqlx::spec::{Advisory, Payload, own};
use ruststream_sqlx::{InboxSpec, InboxTable, Unlock};
use sqlx::{PgConnection, Postgres};
#[derive(sqlx::FromRow)]
pub struct Rebalance {
id: i64,
payload: Vec<u8>,
}
impl InboxTable for Rebalance {
type Id = i64;
type Table = InboxSpec<(Advisory, Payload, own::Lock, own::Unlock)>;
const TABLE: Self::Table = InboxSpec::new("rebalances", Column::new("id").generated())
.advisory(&[KeyPart::Literal("portfolio-"), KeyPart::Column("portfolio")])
.payload(Column::new("payload"))
.own::<own::Lock>()
.own::<own::Unlock>();
fn id(&self) -> &i64 {
&self.id
}
}
// The trading desk locks a portfolio as `(7, hashtext(key))`, and the unlock releases that lock.
impl Unlock<Postgres> for Rebalance {
async fn unlock(conn: &mut PgConnection, key: &str) -> Result<bool, sqlx::Error> {
sqlx::query_scalar("SELECT pg_advisory_unlock(7, hashtext($1))")
.bind(key)
.fetch_one(conn)
.await
}
}Trait Implementations§
Source§impl Declaration for Unlock
impl Declaration for Unlock
Source§type RetryAfter = Unset
type RetryAfter = Unset
The time a retried row is due:
RetryAfter.Source§type ProcessedAt = Unset
type ProcessedAt = Unset
The time a row was processed:
ProcessedAt.Source§type Opening = Unset
type Opening = Unset
What the table’s transactions open at:
Opens; unset for the database’s
default.Source§type OwnClaim = Unset
type OwnClaim = Unset
The service’s own claim:
own::Claim.Source§type OwnFetch = Unset
type OwnFetch = Unset
The service’s own fetch:
own::Fetch.Source§type OwnRetry = Unset
type OwnRetry = Unset
The service’s own retry:
own::Retry.Source§type OwnRetryAfter = Unset
type OwnRetryAfter = Unset
The service’s own delayed retry:
own::RetryAfter.Source§type OwnDiscard = Unset
type OwnDiscard = Unset
The service’s own discard:
own::Discard.Source§type OwnDeadLetter = Unset
type OwnDeadLetter = Unset
The service’s own dead letter:
own::DeadLetter.Source§type OwnExtend = Unset
type OwnExtend = Unset
The service’s own lease extension:
own::Extend.impl OwnEvent for Unlock
Auto Trait Implementations§
impl Freeze for Unlock
impl RefUnwindSafe for Unlock
impl Send for Unlock
impl Sync for Unlock
impl Unpin for Unlock
impl UnsafeUnpin for Unlock
impl UnwindSafe for Unlock
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<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
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