pub struct RotationRequest {
pub to_version: i32,
pub batch_size: u32,
pub after_id: Option<Uuid>,
}Expand description
One batch of a key rotation.
Rotation is driven batch by batch by the caller rather than in one long call, so that a rotation can be watched, interrupted, and resumed.
§Examples
use ironflow_store::entities::RotationRequest;
// Start from the beginning of the stock.
let first = RotationRequest::new(2);
assert!(first.after_id.is_none());
// Continue after the last secret seen.
let next = first.clone().after(uuid::Uuid::now_v7());
assert!(next.after_id.is_some());Fields§
§to_version: i32Key version every secret in the batch is re-encrypted with.
batch_size: u32How many secrets to process, clamped to
[1, MAX_ROTATION_BATCH_SIZE].
after_id: Option<Uuid>Resume after this secret ID. None starts from the beginning.
The cursor is what keeps the rotation moving forward when a secret cannot be decrypted: a failed row is never served again.
Implementations§
Source§impl RotationRequest
impl RotationRequest
Sourcepub fn new(to_version: i32) -> Self
pub fn new(to_version: i32) -> Self
A request for the first batch, with the default batch size.
§Examples
use ironflow_store::entities::{RotationRequest, DEFAULT_ROTATION_BATCH_SIZE};
let req = RotationRequest::new(2);
assert_eq!(req.to_version, 2);
assert_eq!(req.batch_size, DEFAULT_ROTATION_BATCH_SIZE);Sourcepub fn with_batch_size(self, batch_size: u32) -> Self
pub fn with_batch_size(self, batch_size: u32) -> Self
Set the batch size.
§Examples
use ironflow_store::entities::RotationRequest;
let req = RotationRequest::new(2).with_batch_size(10);
assert_eq!(req.batch_size, 10);Sourcepub fn after(self, id: Uuid) -> Self
pub fn after(self, id: Uuid) -> Self
Resume after a given secret ID.
§Examples
use ironflow_store::entities::RotationRequest;
use uuid::Uuid;
let id = Uuid::now_v7();
let req = RotationRequest::new(2).after(id);
assert_eq!(req.after_id, Some(id));Sourcepub fn effective_batch_size(&self) -> u32
pub fn effective_batch_size(&self) -> u32
The batch size clamped to the allowed range.
§Examples
use ironflow_store::entities::{RotationRequest, MAX_ROTATION_BATCH_SIZE};
assert_eq!(RotationRequest::new(2).with_batch_size(0).effective_batch_size(), 1);
assert_eq!(
RotationRequest::new(2).with_batch_size(99_999).effective_batch_size(),
MAX_ROTATION_BATCH_SIZE
);Trait Implementations§
Source§impl Clone for RotationRequest
impl Clone for RotationRequest
Source§fn clone(&self) -> RotationRequest
fn clone(&self) -> RotationRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RotationRequest
impl RefUnwindSafe for RotationRequest
impl Send for RotationRequest
impl Sync for RotationRequest
impl Unpin for RotationRequest
impl UnsafeUnpin for RotationRequest
impl UnwindSafe for RotationRequest
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