pub struct DistributedEncoder { /* private fields */ }Expand description
Main distributed encoder interface.
Maintains an in-process job store so that submit_job, job_status, and
cancel_job operate on real state. In a production deployment the store
would be backed by the gRPC coordinator; this implementation provides a
fully functional local fallback that exercises the complete lifecycle.
Implementations§
Source§impl DistributedEncoder
impl DistributedEncoder
Sourcepub fn new(config: DistributedConfig) -> Self
pub fn new(config: DistributedConfig) -> Self
Create a new distributed encoder with the given configuration
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new distributed encoder with default configuration
Sourcepub fn config(&self) -> &DistributedConfig
pub fn config(&self) -> &DistributedConfig
Get the current configuration
Sourcepub async fn active_job_count(&self) -> usize
pub async fn active_job_count(&self) -> usize
Return the number of active (non-terminal) jobs.
Sourcepub async fn submit_job(&self, job: DistributedJob) -> Result<Uuid>
pub async fn submit_job(&self, job: DistributedJob) -> Result<Uuid>
Submit a job for distributed encoding.
Validates the job, checks concurrency limits, registers it in the internal store, and returns the job ID on success.
§Arguments
job- The encoding job to submit
§Returns
Returns the job ID on success
§Errors
Returns DistributedError::InvalidConfig if the job definition is
invalid, or DistributedError::ResourceExhausted if the maximum
concurrent job limit has been reached.
Sourcepub async fn job_status(&self, job_id: Uuid) -> Result<JobStatus>
pub async fn job_status(&self, job_id: Uuid) -> Result<JobStatus>
Query the status of a previously submitted job.
In addition to returning the stored status, this method performs
timeout checking: if a job has been active longer than the configured
job_timeout it is automatically marked as Failed.
§Errors
Returns DistributedError::Job if the job ID is not found.
Sourcepub async fn cancel_job(&self, job_id: Uuid) -> Result<()>
pub async fn cancel_job(&self, job_id: Uuid) -> Result<()>
Cancel a previously submitted job.
Only jobs that are not yet in a terminal state (Completed, Failed,
Cancelled) can be cancelled.
§Errors
Returns DistributedError::Job if the job ID is not found or the job
is already in a terminal state.
Sourcepub async fn advance_job(&self, job_id: Uuid) -> Result<JobStatus>
pub async fn advance_job(&self, job_id: Uuid) -> Result<JobStatus>
Advance a job to the next logical status (for internal/testing use).
Transitions: Pending -> Assigned -> InProgress -> Completed
§Errors
Returns error if the job is not found or is in a terminal state.
Sourcepub async fn fail_job(&self, job_id: Uuid) -> Result<()>
pub async fn fail_job(&self, job_id: Uuid) -> Result<()>
Mark a job as failed (for internal/testing use).
§Errors
Returns error if the job is not found or already in a terminal state.
Sourcepub async fn job_retries(&self, job_id: Uuid) -> Result<u32>
pub async fn job_retries(&self, job_id: Uuid) -> Result<u32>
Auto Trait Implementations§
impl Freeze for DistributedEncoder
impl !RefUnwindSafe for DistributedEncoder
impl Send for DistributedEncoder
impl Sync for DistributedEncoder
impl Unpin for DistributedEncoder
impl UnsafeUnpin for DistributedEncoder
impl !UnwindSafe for DistributedEncoder
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
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request