gr::io

Trait HttpRunner

source
pub trait HttpRunner {
    type Response;

    // Required methods
    fn run<T: Serialize>(
        &self,
        cmd: &mut Request<'_, T>,
    ) -> Result<Self::Response>;
    fn api_max_pages<T: Serialize>(&self, cmd: &Request<'_, T>) -> u32;

    // Provided methods
    fn throttle(&self, milliseconds: Milliseconds) { ... }
    fn throttle_range(&self, min: Milliseconds, max: Milliseconds) { ... }
}
Expand description

A trait for the HTTP protocol. Implementors need to conform with the HTTP constraints and requirements. Implementors accept a Request that wraps headers, payloads and HTTP methods. Clients can potentially do HTTP calls against a remote server or mock the responses for testing purposes.

Required Associated Types§

Required Methods§

source

fn run<T: Serialize>(&self, cmd: &mut Request<'_, T>) -> Result<Self::Response>

source

fn api_max_pages<T: Serialize>(&self, cmd: &Request<'_, T>) -> u32

Return the number of API MAX PAGES allowed for the given Request.

Provided Methods§

source

fn throttle(&self, milliseconds: Milliseconds)

Milliseconds to wait before executing the next request

source

fn throttle_range(&self, min: Milliseconds, max: Milliseconds)

Random wait time between the given range before submitting the next HTTP request. The wait time is in milliseconds. The range is inclusive.

Object Safety§

This trait is not object safe.

Implementors§