pub struct RegionalState<T> { /* private fields */ }Expand description
One account’s state for a regional service, partitioned by region.
Regional AWS services (SQS, DynamoDB, Lambda, …) keep an independent set
of resources in every region: the same queue, table or function name can
exist in two regions at once, and a request only ever sees the resources of
the region it is sent to. Wrapping a service’s per-account state T in
RegionalState<T> (and the container in MultiRegionState) gives every
(account, region) pair its own T, created the first time a request
targets it.
Global services (IAM, Route 53, CloudFront, Organizations, the S3 bucket namespace) stay account-scoped and do not use this wrapper.
Implementations§
Source§impl<T> RegionalState<T>
impl<T> RegionalState<T>
Sourcepub fn new(account_id: &str, default_region: &str, endpoint: &str) -> Self
pub fn new(account_id: &str, default_region: &str, endpoint: &str) -> Self
An account with no regional state yet.
Sourcepub fn account_id(&self) -> &str
pub fn account_id(&self) -> &str
The account this state belongs to.
Sourcepub fn default_region(&self) -> &str
pub fn default_region(&self) -> &str
The server’s configured region.
Sourcepub fn region(&self, region: &str) -> Option<&T>
pub fn region(&self, region: &str) -> Option<&T>
The account’s state in region, None when nothing has touched it.
Sourcepub fn get_region_mut(&mut self, region: &str) -> Option<&mut T>
pub fn get_region_mut(&mut self, region: &str) -> Option<&mut T>
The account’s state in region without creating it.
Sourcepub fn regions(&self) -> impl Iterator<Item = (&str, &T)>
pub fn regions(&self) -> impl Iterator<Item = (&str, &T)>
Every region the account has state in.
Sourcepub fn regions_mut(&mut self) -> impl Iterator<Item = (&str, &mut T)>
pub fn regions_mut(&mut self) -> impl Iterator<Item = (&str, &mut T)>
Every region the account has state in (mutable).
Sourcepub fn insert_region(&mut self, region: &str, state: T) -> Option<T>
pub fn insert_region(&mut self, region: &str, state: T) -> Option<T>
Replace (or add) the state of one region.
Sourcepub fn map<U>(&self, f: impl FnMut(&T) -> U) -> RegionalState<U>
pub fn map<U>(&self, f: impl FnMut(&T) -> U) -> RegionalState<U>
Project every region’s state, keeping the account’s routing defaults.
Source§impl<T: AccountState> RegionalState<T>
impl<T: AccountState> RegionalState<T>
Sourcepub fn region_mut(&mut self, region: &str) -> &mut T
pub fn region_mut(&mut self, region: &str) -> &mut T
The account’s state in region, created empty on first use. A new
region inherits shared resources (see AccountState::inherit_from)
from a region the account already has.
Sourcepub fn region_or_default_mut(&mut self, region: Option<&str>) -> &mut T
pub fn region_or_default_mut(&mut self, region: Option<&str>) -> &mut T
The state for region given as an optional ARN region: None (an ARN
without a region, or a record without an ARN) lands in the server’s
default region. Used by snapshot migrations.
Source§impl<T: SplitByRegion> RegionalState<T>
impl<T: SplitByRegion> RegionalState<T>
Sourcepub fn from_legacy(
account_id: &str,
default_region: &str,
endpoint: &str,
legacy: T,
) -> Self
pub fn from_legacy( account_id: &str, default_region: &str, endpoint: &str, legacy: T, ) -> Self
Split one account’s legacy, account-wide state into regions.
Trait Implementations§
Source§impl<T: AccountState> AccountState for RegionalState<T>
impl<T: AccountState> AccountState for RegionalState<T>
Source§fn new_for_account(account_id: &str, region: &str, endpoint: &str) -> Self
fn new_for_account(account_id: &str, region: &str, endpoint: &str) -> Self
Source§fn inherit_from(&mut self, sibling: &Self)
fn inherit_from(&mut self, sibling: &Self)
MultiAccountState::get_or_create,
with a reference to an existing sibling state. Services can override
this to propagate shared resources (e.g. body caches) to the new state.