pub struct ViewRegistry { /* private fields */ }Expand description
A shared Arc<ViewFactory> (base + N DDL-defined SqlBatchViews) rebuilt from
lakehouse_view_set_definitions on a timer. See the module doc comment.
Implementations§
Source§impl ViewRegistry
impl ViewRegistry
pub fn new( base: Arc<ViewFactory>, store: Arc<dyn ViewDefinitionStore>, runtime: Arc<RuntimeEnv>, lake: Arc<DataLakeConnection>, session_configurator: Arc<dyn SessionConfigurator>, ) -> ViewRegistry
Sourcepub fn current(&self) -> Arc<ViewFactory> ⓘ
pub fn current(&self) -> Arc<ViewFactory> ⓘ
The current snapshot: the base factory before the first successful reload(), or the base
plus every definition that built and validated on the last successful build afterward.
Sourcepub fn failed_view_sets(&self) -> Vec<String>
pub fn failed_view_sets(&self) -> Vec<String>
Names skipped by the last build, for introspection/tests.
Sourcepub async fn build_from_rows(
&self,
rows: &[ViewDefinitionRow],
purpose: BuildPurpose,
) -> Result<(Arc<ViewFactory>, Vec<BuildFailure>), Error>
pub async fn build_from_rows( &self, rows: &[ViewDefinitionRow], purpose: BuildPurpose, ) -> Result<(Arc<ViewFactory>, Vec<BuildFailure>), Error>
Thin wrapper over build_factory supplying this registry’s base/runtime/lake/
session_configurator.
Sourcepub async fn check_dependents_survive(
&self,
pre_rows: &[ViewDefinitionRow],
post_rows: &[ViewDefinitionRow],
) -> Result<(), Error>
pub async fn check_dependents_survive( &self, pre_rows: &[ViewDefinitionRow], post_rows: &[ViewDefinitionRow], ) -> Result<(), Error>
The dependent-protection refusal: builds a factory from pre_rows and one from
post_rows, then refuses with a named error if any definition present in post_rows –
including the row just written – both fails to build against post_rows and was not
already in the pre-mutation failed set. Exact rather than textual: it uses the real
planner, so it catches a removed column as readily as a removed view set.
Both builds are BuildPurpose::Probes: a skip is what this check is looking for, so it
belongs in the refusal the caller returns – with the planner’s own reason, the only place
the admin can now read it – not in the service log as a registry failure.
Sourcepub async fn reload(&self) -> Result<(), Error>
pub async fn reload(&self) -> Result<(), Error>
Refreshes current() from lakehouse_view_set_definitions.
- Acquires
reload_mutexand holds it through every step below. store.list()-> rows ordered by(update_group, view_set_name).- Hashes the
(view_set_name, updated_at)tuples; if unchanged fromloaded_digestand the previous build’s failed set was empty, returns – oneSELECT, no planning. A digest match after a failed build does not short-circuit, so a row that failed for a transient reason is retried every tick. build_factory(...).- A row that fails to build or validate is skipped, not fatal (see
build_factory). - Swaps
current, updatesloaded_digestandfailed_view_sets.
Sourcepub fn spawn_refresh_task(
self: Arc<ViewRegistry>,
shutdown: impl Future<Output = ()> + Send + 'static,
)
pub fn spawn_refresh_task( self: Arc<ViewRegistry>, shutdown: impl Future<Output = ()> + Send + 'static, )
Spawns the background task that calls Self::reload once immediately and then on every
MICROMEGAS_VIEW_DEFINITION_REFRESH_SECONDS tick, until shutdown resolves. A failed
reload() is warn!-logged here and discarded – the previous snapshot is kept (the same
fail-open treatment QueryDenyList::spawn_refresh_task gives a failed periodic refresh).
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ViewRegistry
impl !RefUnwindSafe for ViewRegistry
impl !UnwindSafe for ViewRegistry
impl Send for ViewRegistry
impl Sync for ViewRegistry
impl Unpin for ViewRegistry
impl UnsafeUnpin for ViewRegistry
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
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> ⓘ
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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].