Request

Struct Request 

Source
pub struct Request<T: RequestState> {
    pub state: T,
    pub data: RequestData,
}
Expand description

A request to be processed by the fusillade system.

Uses the typestate pattern to ensure type-safe state transitions. The generic parameter T represents the current state of the request.

§Example

let pending_request = Request {
    state: Pending {},
    data: request_data,
};
// Can only call operations valid for Pending state

Fields§

§state: T

The current state of the request.

§data: RequestData

The user-supplied request data.

Implementations§

Source§

impl Request<Pending>

Source

pub async fn claim<S: Storage + ?Sized>( self, daemon_id: DaemonId, storage: &S, ) -> Result<Request<Claimed>>

Source

pub async fn cancel<S: Storage + ?Sized>( self, storage: &S, ) -> Result<Request<Canceled>>

Source§

impl Request<Claimed>

Source

pub async fn unclaim<S: Storage + ?Sized>( self, storage: &S, ) -> Result<Request<Pending>>

Source

pub async fn cancel<S: Storage + ?Sized>( self, storage: &S, ) -> Result<Request<Canceled>>

Source

pub async fn process<H: HttpClient + 'static, S: Storage>( self, http_client: H, timeout_ms: u64, storage: &S, ) -> Result<Request<Processing>>

Source§

impl Request<Failed>

Source

pub fn can_retry( self, retry_attempt: u32, config: RetryConfig, ) -> Result<Request<Pending>, Box<Self>>

Attempt to retry this failed request.

If retries are available, transitions the request back to Pending with:

  • Incremented retry_attempt
  • Calculated not_before timestamp for exponential backoff

If no retries remain, returns None and the request stays Failed.

The retry logic considers:

  • max_retries: Hard cap on total retry attempts
  • stop_before_deadline_ms: Deadline-aware retry (stops before batch expiration)
Source§

impl Request<Processing>

Source

pub async fn complete<S, F, Fut>( self, storage: &S, should_retry: F, cancellation: Fut, ) -> Result<RequestCompletionResult>
where S: Storage + ?Sized, F: Fn(&HttpResponse) -> bool, Fut: Future<Output = CancellationReason>,

Wait for the HTTP request to complete.

This method awaits the result from the spawned HTTP task and transitions the request to one of three terminal states: Completed, Failed, or Canceled.

The should_retry predicate determines whether a response should be considered a failure (and thus eligible for retry) or a success.

The cancellation future allows external cancellation of the request. It should resolve to a CancellationReason:

  • CancellationReason::User: User-initiated cancellation (persists Canceled state)
  • CancellationReason::Shutdown: Daemon shutdown (aborts HTTP but doesn’t persist)
  • CancellationReason::Superseded: Request superseded by racing pair (aborts HTTP but doesn’t persist)

Returns:

  • RequestCompletionResult::Completed if the HTTP request succeeded
  • RequestCompletionResult::Failed if the HTTP request failed or should be retried
  • RequestCompletionResult::Canceled if the request was canceled by user
  • Err(FusilladeError::Shutdown) if the daemon is shutting down or request was superseded
Source

pub async fn cancel<S: Storage + ?Sized>( self, storage: &S, ) -> Result<Request<Canceled>>

Trait Implementations§

Source§

impl<T: Clone + RequestState> Clone for Request<T>

Source§

fn clone(&self) -> Request<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug + RequestState> Debug for Request<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Request<Canceled>> for AnyRequest

Source§

fn from(r: Request<Canceled>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Claimed>> for AnyRequest

Source§

fn from(r: Request<Claimed>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Completed>> for AnyRequest

Source§

fn from(r: Request<Completed>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Failed>> for AnyRequest

Source§

fn from(r: Request<Failed>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Pending>> for AnyRequest

Source§

fn from(r: Request<Pending>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Processing>> for AnyRequest

Source§

fn from(r: Request<Processing>) -> Self

Converts to this type from the input type.
Source§

impl From<Request<Superseded>> for AnyRequest

Source§

fn from(r: Request<Superseded>) -> Self

Converts to this type from the input type.
Source§

impl<T> Serialize for Request<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Request<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Request<T>
where T: RefUnwindSafe,

§

impl<T> Send for Request<T>

§

impl<T> Sync for Request<T>

§

impl<T> Unpin for Request<T>
where T: Unpin,

§

impl<T> UnwindSafe for Request<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more