Skip to main content

JobsBuilder

Struct JobsBuilder 

Source
pub struct JobsBuilder<'a> { /* private fields */ }
Expand description

Select a set of Job instances to return from the LAVA server.

This is the way to construct a Jobs object, which can stream the actual data. It allows customisation of which jobs to return, and in what order.

Example:

use futures::stream::TryStreamExt;
use lava_api::{Lava, job::State, job::Ordering};

let lava = Lava::new(&service_uri, lava_token).expect("failed to make lava");

let mut lj = lava
    .jobs()
    .state(State::Submitted)
    .ordering(Ordering::StartTime, true)
    .query();

while let Some(job) = lj
    .try_next()
    .await
    .expect("failed to get job")
{
    println!("Got job {:?}", job);
}

Implementations§

Source§

impl<'a> JobsBuilder<'a>

Source

pub fn new(lava: &'a Lava) -> Self

Create a new JobsBuilder

The default query is:

  • order by Ordering::Id
  • no filtering
  • default result pagination
Source

pub fn state(self, state: State) -> Self

Return jobs in this state.

Source

pub fn state_not(self, state: State) -> Self

Exclude jobs in this state.

Source

pub fn limit(self, limit: u32) -> Self

Set the number of jobs retrieved at a time while the query is running. The query will be processed transparently as a sequence of requests that return all matching responses. This setting governs the size of each of the (otherwise transparent) requests, so this number is really a page size.

Note that you will see artifacts on queries that are split into many requests, especially when responses are slow. This makes setting the limit much smaller than the response size unattractive when accurate data is required. However, the server will need to return records in chunks of this size, regardless of how many are consumed from the response stream, which makes setting the limit much higher than the response size wasteful. In practice, it is probably best to set this limit to the expected response size for most use cases.

Artifacts occur when paging occurs, because paging is entirely client side. Each page contains a section of the query begining with the job at some multiple of the limit count into the result set. However the result set is evolving while the paging is occurring, and this is not currently compensated for, which leads to jobs being returned multiple times at the boundaries between pages - or even omitted depending on the query. In general, query sets that can shrink are not safe to use with paging, because results can be lost rather than duplicated.

Source

pub fn health(self, health: Health) -> Self

Return jobs with this health.

Source

pub fn health_not(self, health: Health) -> Self

Exclude jobs with this health.

Source

pub fn id(self, id: i64) -> Self

Return only jobs whose id is id.

Source

pub fn id_after(self, id: i64) -> Self

Return only jobs whose id is strictly greater than id.

Source

pub fn started_after(self, when: DateTime<Utc>) -> Self

Return only jobs whose start time is strictly after the given instant.

Source

pub fn submitted_after(self, when: DateTime<Utc>) -> Self

Return only jobs whose submission time is strictly after the given instant.

Source

pub fn ended_after(self, when: DateTime<Utc>) -> Self

Return only jobs which ended strictly after the given instant.

Source

pub fn ordering(self, ordering: Ordering, ascending: bool) -> Self

Order returned jobs by the given key.

Source

pub fn query(self) -> Jobs<'a>

Begin querying for jobs, returning a Jobs instance

Trait Implementations§

Source§

impl<'a> Clone for JobsBuilder<'a>

Source§

fn clone(&self) -> JobsBuilder<'a>

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<'a> Debug for JobsBuilder<'a>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for JobsBuilder<'a>

§

impl<'a> !RefUnwindSafe for JobsBuilder<'a>

§

impl<'a> Send for JobsBuilder<'a>

§

impl<'a> Sync for JobsBuilder<'a>

§

impl<'a> Unpin for JobsBuilder<'a>

§

impl<'a> UnsafeUnpin for JobsBuilder<'a>

§

impl<'a> !UnwindSafe for JobsBuilder<'a>

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