pub struct EntityBatchLoader { /* private fields */ }Expand description
Entity batch loader that integrates with EntityCache.
Collects entity requests, checks the cache first, and issues batch calls to the underlying subgraph for cache misses.
Implementations§
Source§impl EntityBatchLoader
impl EntityBatchLoader
Sourcepub fn new(
cache: Arc<EntityCache>,
resolver: impl Fn(EntityBatch) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>>> + Send>> + Send + Sync + 'static,
max_batch_size: usize,
default_ttl: Duration,
) -> Self
pub fn new( cache: Arc<EntityCache>, resolver: impl Fn(EntityBatch) -> Pin<Box<dyn Future<Output = Result<Vec<(String, String)>>> + Send>> + Send + Sync + 'static, max_batch_size: usize, default_ttl: Duration, ) -> Self
Create a new batch loader.
Sourcepub async fn load_many(
&self,
type_name: &str,
key_jsons: Vec<String>,
tenant_id: Option<&str>,
) -> Result<HashMap<String, String>>
pub async fn load_many( &self, type_name: &str, key_jsons: Vec<String>, tenant_id: Option<&str>, ) -> Result<HashMap<String, String>>
Resolve a list of entity keys for a given type, using the cache.
Returns a map from key JSON to resolved data JSON.
Sourcepub async fn load_one(
&self,
type_name: &str,
key_json: &str,
tenant_id: Option<&str>,
) -> Result<Option<String>>
pub async fn load_one( &self, type_name: &str, key_json: &str, tenant_id: Option<&str>, ) -> Result<Option<String>>
Load a single entity.
Sourcepub fn cache(&self) -> &Arc<EntityCache> ⓘ
pub fn cache(&self) -> &Arc<EntityCache> ⓘ
Return a reference to the underlying entity cache.
Sourcepub fn invalidate_type(&self, type_name: &str) -> usize
pub fn invalidate_type(&self, type_name: &str) -> usize
Invalidate all cached entities of a given type.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for EntityBatchLoader
impl !UnwindSafe for EntityBatchLoader
impl Freeze for EntityBatchLoader
impl Send for EntityBatchLoader
impl Sync for EntityBatchLoader
impl Unpin for EntityBatchLoader
impl UnsafeUnpin for EntityBatchLoader
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more