pub struct AttemptsRepo { /* private fields */ }Expand description
PostgreSQL repository for durable job-attempt history.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Implementations§
Source§impl AttemptsRepo
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;
impl AttemptsRepo
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub fn new(pool: Pool<Postgres>) -> AttemptsRepo
pub fn new(pool: Pool<Postgres>) -> AttemptsRepo
Creates an attempt repository backed by pool.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn start_attempt(
&self,
job_id: Uuid,
worker_id: &str,
) -> Result<JobAttempt, Error>
pub async fn start_attempt( &self, job_id: Uuid, worker_id: &str, ) -> Result<JobAttempt, Error>
Insert attempt row as “running”, auto-increment attempt_no per job.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn start_attempt_for_dataset(
&self,
dataset_id: &str,
job_id: Uuid,
worker_id: &str,
) -> Result<JobAttempt, Error>
pub async fn start_attempt_for_dataset( &self, dataset_id: &str, job_id: Uuid, worker_id: &str, ) -> Result<JobAttempt, Error>
Insert attempt row as “running” when caller already knows dataset_id.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn start_attempts_batch(
&self,
dataset_ids: &[String],
job_ids: &[Uuid],
worker_id: &str,
) -> Result<Vec<(Uuid, Uuid, i32)>, Error>
pub async fn start_attempts_batch( &self, dataset_ids: &[String], job_ids: &[Uuid], worker_id: &str, ) -> Result<Vec<(Uuid, Uuid, i32)>, Error>
Insert many “running” attempts in one round-trip. Returns tuples of (job_id, attempt_id, attempt_no).
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn finish_succeeded(
&self,
attempt_id: Uuid,
latency_ms: i32,
) -> Result<(), Error>
pub async fn finish_succeeded( &self, attempt_id: Uuid, latency_ms: i32, ) -> Result<(), Error>
Marks an attempt succeeded and records its final latency.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn finish_succeeded_batch(
&self,
updates: &[(Uuid, i32)],
) -> Result<(), Error>
pub async fn finish_succeeded_batch( &self, updates: &[(Uuid, i32)], ) -> Result<(), Error>
Fast-path for successful batch execution: updates many attempts in one statement.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn finish_failed(
&self,
attempt_id: Uuid,
latency_ms: i32,
error_code: &str,
error_message: &str,
) -> Result<(), Error>
pub async fn finish_failed( &self, attempt_id: Uuid, latency_ms: i32, error_code: &str, error_message: &str, ) -> Result<(), Error>
Marks an attempt failed with its final latency and error details.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Sourcepub async fn list_attempts_for_job(
&self,
job_id: Uuid,
) -> Result<Vec<JobAttempt>, Error>
pub async fn list_attempts_for_job( &self, job_id: Uuid, ) -> Result<Vec<JobAttempt>, Error>
Lists a job’s attempts in ascending attempt-number order.
§Examples
use azums::AttemptsRepo;
use sqlx::postgres::PgPoolOptions;
let pool = PgPoolOptions::new()
.connect_lazy("postgres://postgres:postgres@localhost/azums")?;
let attempts = AttemptsRepo::new(pool);
let _ = attempts;Trait Implementations§
Source§impl Clone for AttemptsRepo
impl Clone for AttemptsRepo
Source§fn clone(&self) -> AttemptsRepo
fn clone(&self) -> AttemptsRepo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for AttemptsRepo
impl !UnwindSafe for AttemptsRepo
impl Freeze for AttemptsRepo
impl Send for AttemptsRepo
impl Sync for AttemptsRepo
impl Unpin for AttemptsRepo
impl UnsafeUnpin for AttemptsRepo
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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