pub struct JobContext {
pub job_id: Uuid,
pub job_type: String,
pub attempt: u32,
pub max_attempts: u32,
pub auth: AuthContext,
/* private fields */
}Expand description
Context available to job handlers.
Fields§
§job_id: UuidJob ID.
job_type: StringJob type/name.
attempt: u32Current attempt number (1-based).
max_attempts: u32Maximum attempts allowed.
auth: AuthContextAuthentication context (for queries/mutations).
Implementations§
Source§impl JobContext
impl JobContext
Sourcepub fn new(
job_id: Uuid,
job_type: String,
attempt: u32,
max_attempts: u32,
db_pool: Pool<Postgres>,
http_client: Client,
) -> JobContext
pub fn new( job_id: Uuid, job_type: String, attempt: u32, max_attempts: u32, db_pool: Pool<Postgres>, http_client: Client, ) -> JobContext
Create a new job context.
Sourcepub fn with_auth(self, auth: AuthContext) -> JobContext
pub fn with_auth(self, auth: AuthContext) -> JobContext
Set authentication context.
Sourcepub fn with_progress(self, tx: Sender<ProgressUpdate>) -> JobContext
pub fn with_progress(self, tx: Sender<ProgressUpdate>) -> JobContext
Set progress channel.
Sourcepub fn with_env_provider(self, provider: Arc<dyn EnvProvider>) -> JobContext
pub fn with_env_provider(self, provider: Arc<dyn EnvProvider>) -> JobContext
Set environment provider.
Sourcepub fn progress(
&self,
percentage: u8,
message: impl Into<String>,
) -> Result<(), ForgeError>
pub fn progress( &self, percentage: u8, message: impl Into<String>, ) -> Result<(), ForgeError>
Report job progress.
Sourcepub async fn heartbeat(&self) -> Result<(), ForgeError>
pub async fn heartbeat(&self) -> Result<(), ForgeError>
Send heartbeat to keep job alive (async).
Sourcepub fn is_last_attempt(&self) -> bool
pub fn is_last_attempt(&self) -> bool
Check if this is the last attempt.
Trait Implementations§
Source§impl EnvAccess for JobContext
impl EnvAccess for JobContext
Source§fn env_provider(&self) -> &dyn EnvProvider
fn env_provider(&self) -> &dyn EnvProvider
Get the environment provider.
Source§fn env_or(&self, key: &str, default: &str) -> String
fn env_or(&self, key: &str, default: &str) -> String
Get an environment variable with a default value. Read more
Source§fn env_require(&self, key: &str) -> Result<String, ForgeError>
fn env_require(&self, key: &str) -> Result<String, ForgeError>
Get a required environment variable. Read more
Source§fn env_parse<T>(&self, key: &str) -> Result<T, ForgeError>
fn env_parse<T>(&self, key: &str) -> Result<T, ForgeError>
Get an environment variable and parse it to the specified type. Read more
Source§fn env_parse_or<T>(&self, key: &str, default: T) -> Result<T, ForgeError>
fn env_parse_or<T>(&self, key: &str, default: T) -> Result<T, ForgeError>
Get an environment variable and parse it, with a default. Read more
Source§fn env_contains(&self, key: &str) -> bool
fn env_contains(&self, key: &str) -> bool
Check if an environment variable is set.
Auto Trait Implementations§
impl Freeze for JobContext
impl !RefUnwindSafe for JobContext
impl Send for JobContext
impl Sync for JobContext
impl Unpin for JobContext
impl !UnwindSafe for JobContext
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> 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