Struct mz_persist_client::cache::PersistClientCache
source · pub struct PersistClientCache {
pub(crate) cfg: PersistConfig,
pub(crate) metrics: Arc<Metrics>,
blob_by_uri: Mutex<BTreeMap<String, (RttLatencyTask, Arc<dyn Blob + Send + Sync>)>>,
consensus_by_uri: Mutex<BTreeMap<String, (RttLatencyTask, Arc<dyn Consensus + Send + Sync>)>>,
cpu_heavy_runtime: Arc<CpuHeavyRuntime>,
}
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
§metrics: Arc<Metrics>
§blob_by_uri: Mutex<BTreeMap<String, (RttLatencyTask, Arc<dyn Blob + Send + Sync>)>>
§consensus_by_uri: Mutex<BTreeMap<String, (RttLatencyTask, Arc<dyn Consensus + Send + Sync>)>>
§cpu_heavy_runtime: Arc<CpuHeavyRuntime>
Implementations§
source§impl PersistClientCache
impl PersistClientCache
sourcepub fn new(cfg: PersistConfig, registry: &MetricsRegistry) -> Self
pub fn new(cfg: PersistConfig, registry: &MetricsRegistry) -> Self
Returns a new PersistClientCache.
sourcepub fn cfg(&self) -> &PersistConfig
pub fn cfg(&self) -> &PersistConfig
Returns the PersistConfig being used by this cache.
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: String
) -> Result<Arc<dyn Consensus + Send + Sync>, ExternalError>
async fn open_blob(
&self,
blob_uri: String
) -> Result<Arc<dyn Blob + Send + Sync>, ExternalError>
Trait Implementations§
Auto Trait Implementations§
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> 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>
Wrap the input message
T
in a tonic::Request
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>
See
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
See
RustType::into_proto
.