pub struct PersistClientCache {
pub cfg: PersistConfig,
pub(crate) metrics: Arc<Metrics>,
blob_by_uri: Mutex<BTreeMap<SensitiveUrl, (RttLatencyTask, Arc<dyn Blob>)>>,
consensus_by_uri: Mutex<BTreeMap<SensitiveUrl, (RttLatencyTask, Arc<dyn Consensus>)>>,
isolated_runtime: Arc<IsolatedRuntime>,
pub(crate) state_cache: Arc<StateCache>,
pubsub_sender: Arc<dyn PubSubSender>,
_pubsub_receiver_task: JoinHandle<()>,
}
Expand description
A cache of PersistClients indexed by PersistLocations.
There should be at most one of these per process. All production PersistClients should be created through this cache.
This is because, in production, persist is heavily limited by the number of server-side Postgres/Aurora connections. This cache allows PersistClients to share, for example, these Postgres connections.
Fields§
§cfg: PersistConfig
The tunable knobs for persist.
metrics: Arc<Metrics>
§blob_by_uri: Mutex<BTreeMap<SensitiveUrl, (RttLatencyTask, Arc<dyn Blob>)>>
§consensus_by_uri: Mutex<BTreeMap<SensitiveUrl, (RttLatencyTask, Arc<dyn Consensus>)>>
§isolated_runtime: Arc<IsolatedRuntime>
§state_cache: Arc<StateCache>
§pubsub_sender: Arc<dyn PubSubSender>
§_pubsub_receiver_task: JoinHandle<()>
Implementations§
Source§impl PersistClientCache
impl PersistClientCache
const PROMETHEUS_SCRAPE_INTERVAL: Duration = _
Sourcepub fn new<F>(cfg: PersistConfig, registry: &MetricsRegistry, pubsub: F) -> Self
pub fn new<F>(cfg: PersistConfig, registry: &MetricsRegistry, pubsub: F) -> Self
Returns a new PersistClientCache.
Sourcepub fn new_no_metrics() -> Self
pub fn new_no_metrics() -> Self
A test helper that returns a PersistClientCache disconnected from metrics.
Sourcepub fn cfg(&self) -> &PersistConfig
pub fn cfg(&self) -> &PersistConfig
Returns the PersistConfig being used by this cache.
Sourcepub fn shard_metrics(&self, shard_id: &ShardId, name: &str) -> Arc<ShardMetrics>
pub fn shard_metrics(&self, shard_id: &ShardId, name: &str) -> Arc<ShardMetrics>
Returns ShardMetrics
for the given shard.
Sourcepub fn clear_state_cache(&mut self)
pub fn clear_state_cache(&mut self)
Clears the state cache, allowing for tests with disconnected states.
Only exposed for testing.
Sourcepub async fn open(
&self,
location: PersistLocation,
) -> Result<PersistClient, ExternalError>
pub async fn open( &self, location: PersistLocation, ) -> Result<PersistClient, ExternalError>
Returns a new PersistClient for interfacing with persist shards made durable to the given PersistLocation.
The same location
may be used concurrently from multiple processes.
async fn open_consensus( &self, consensus_uri: SensitiveUrl, ) -> Result<Arc<dyn Consensus>, ExternalError>
async fn open_blob( &self, blob_uri: SensitiveUrl, ) -> Result<Arc<dyn Blob>, ExternalError>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for PersistClientCache
impl !RefUnwindSafe for PersistClientCache
impl Send for PersistClientCache
impl Sync for PersistClientCache
impl Unpin for PersistClientCache
impl !UnwindSafe for PersistClientCache
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
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
Source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.Source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.Source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
Source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.