Struct mz_persist_client::cache::PersistClientCache
source · 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
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.
const PROMETHEUS_SCRAPE_INTERVAL: Duration = _
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
.