pub struct Budget { /* private fields */ }Expand description
How many calls an invocation may still make: D1 queries, fetches, KV
and R2 operations, as the job counts them.
On the free plan a Worker invocation (a request, a queue batch, a cron
run) may run 50 D1 queries and make 50 subrequests; past that the call
fails. A job over many rows takes a budget, spends it per call, and
stops early with a cursor to continue from (run_steps). Ocre does not
count for you: take what each step is about to use.
§Examples
use ocre::jobs::Budget;
let budget = Budget::new(Budget::FREE_D1_QUERIES - 5); // 5 for the rest of the job
assert!(budget.take(40));
assert!(!budget.take(10), "not enough left: nothing taken");
assert_eq!(budget.left(), 5);Implementations§
Source§impl Budget
impl Budget
Sourcepub const FREE_D1_QUERIES: u32 = 50
pub const FREE_D1_QUERIES: u32 = 50
D1 queries per invocation on the free plan: 50.
Sourcepub const FREE_SUBREQUESTS: u32 = 50
pub const FREE_SUBREQUESTS: u32 = 50
Subrequests (fetch) per invocation on the free plan: 50.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Budget
impl RefUnwindSafe for Budget
impl Send for Budget
impl Sync for Budget
impl Unpin for Budget
impl UnsafeUnpin for Budget
impl UnwindSafe for Budget
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