Skip to main content

WebIngestionService

Struct WebIngestionService 

Source
pub struct WebIngestionService { /* private fields */ }

Implementations§

Source§

impl WebIngestionService

Source

pub fn new( lake: DataLakeConnection, default_audience: WriteAudience, ) -> WebIngestionService

Source

pub fn default_audience(&self) -> &WriteAudience

The deployment’s resolved default audience – see the default_audience field’s doc comment. Exposed so the HTTP edge (resolve_write_audience) and the five OTLP IdentityContext construction sites can reach it without re-resolving the environment.

Source

pub async fn check_ready(&self) -> bool

Source

pub async fn from_env( default_audience: WriteAudience, ) -> Result<Arc<WebIngestionService>, Error>

Reads MICROMEGAS_SQL_CONNECTION_STRING and MICROMEGAS_OBJECT_STORE_URI, connects to the data lake, runs ingestion migrations, and returns a ready-to-use service.

default_audience – the deployment’s resolved default audience – is threaded straight into Self::new. micromegas-ingestion depends on neither micromegas-auth nor micromegas-analytics, so it cannot resolve this itself; the caller resolves it (typically via micromegas_auth::policy::default_audience_from_env) and passes it in.

Source

pub fn insert_block( &self, body: Bytes, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Source

pub fn insert_block_typed( &self, block: Block, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Inserts a block whose payload is already typed (no envelope round-trip on the caller side).

The caller hands us a fully-built Block; we CBOR-encode the payload envelope once, write it to object storage, and INSERT the row. Used by the OTLP adapter where constructing the CBOR Block envelope just so insert_block could decode it would be wasted work.

Stamps the row with audience: the block’s own column, not derived from the process_id/stream_id it claims. A credential bound to audience A that knows another audience’s process_id/stream_id can still append a row naming those ids, but the row is labelled A, so blocks_view’s mismatch predicate excludes it from every reader’s view rather than surfacing it mislabelled to either audience.

Source

pub fn insert_stream( &self, body: Bytes, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Registers a stream whose blocks will be ingested in the transit format, stamping it with audience – resolved by the caller from the authenticated credential, exactly as insert_process resolves its own.

This accepts any process_id unconditionally; there is no check that the caller is authorized to write a stream onto that process. The stream is stamped with the caller’s own audience, not the process’s, so blocks_view’s mismatch predicate is what keeps a later block from surfacing under the wrong audience if process_id belongs to someone else.

A re-registration of an existing stream_id under a different audience is rejected via Self::check_stream_audience_conflict, mirroring Self::check_process_audience_conflict.

Source

pub fn register_otel_stream( &self, stream_id: Uuid, process_id: Uuid, tags: Vec<String>, format: &str, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Registers a stream produced by an OTLP ingestion path, stamping it with audience, exactly like Self::insert_stream.

dependencies_metadata and objects_metadata are filled with the CBOR sentinel for an empty Vec<UserDefinedType> so legacy decode sites continue to work. format distinguishes per-block dispatch downstream (e.g. "otlp/v1/logs"). Stream properties are always empty for OTel — scope and per-event attrs live on individual rows during materialization, not on the stream.

Hack: piggybacking OTLP onto the transit-shaped streams row (with empty metadata sentinels) is expedient for two formats but won’t scale. To support more formats cleanly, dependencies_metadata, objects_metadata, and format should be merged into a single per-format payload column.

Same conflict guard as Self::insert_stream – see Self::check_stream_audience_conflict.

Source

pub fn insert_process( &self, body: Bytes, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Registers a process from the native (CBOR) ingestion path, stamping it with audience. audience is resolved by the caller from the authenticated credential (AuthContext.bound_audience); this method never trusts a client-supplied micromegas.* property – strip_reserved_properties drops it, and there is no property to re-append: the stamp lands on the audience column instead.

A conflicting re-registration (an existing process_id under a different audience than audience) is rejected with IngestionServiceError::AudienceConflict rather than silently no-op’d: process_id is client-chosen on this path, so a reused id under a different credential is a real, reachable case, and it is what keeps ownership_rewrite.rs’s MAX(audience) per-process resolution sound. An existing row with a NULL audience column (legacy data with no stamp; admin replication hard-fails on a missing audience column) is resolved to the deployment default the same way every reader does, then compared like any other row; it is never retro-stamped, ever – see the module-level design doc.

Source

pub fn register_otel_process( &self, process_id: Uuid, exe: String, username: String, computer: String, distro: String, cpu_brand: String, tsc_frequency: i64, start_time: DateTime<Utc>, start_ticks: i64, properties: Vec<Property>, audience: &WriteAudience, ) -> impl Future<Output = Result<(), IngestionServiceError>>

Registers a process originating from OTLP. Idempotent via ON CONFLICT DO NOTHING.

realname is set equal to username (OTel has no separate “real name” concept). parent_process_id is always NULL — OTel has no parent-process model. insert_time is the server wall clock, matching the existing insert_process path.

audience is stamped on the audience column, exactly like insert_process; client-supplied micromegas.* properties are stripped via strip_reserved_properties the same way. Same conflict guard as insert_process, and for a confidentiality reason, not just consistency: processes is a single table shared with the native path, and insert_process accepts a client-chosen process_id stamped with the caller’s own audience. Because process_id_from_resource’s derivation formula is public, any ingestion credential can pre-register (via the native path) the exact process_id a victim audience’s OTLP producer will later derive; without this guard the genuine producer’s stream/blocks would silently land on a row stamped with the squatter’s audience, leaking that audience’s data to the squatter. check_process_audience_conflict closes that hole the same way it does for insert_process.

Trait Implementations§

Source§

impl Clone for WebIngestionService

Source§

fn clone(&self) -> WebIngestionService

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<T> Scope for T

§

fn with<F, R>(self, f: F) -> R
where Self: Sized, F: FnOnce(Self) -> R,

Scoped with ownership.
§

fn with_ref<F, R>(&self, f: F) -> R
where F: FnOnce(&Self) -> R,

Scoped with reference.
§

fn with_mut<F, R>(&mut self, f: F) -> R
where F: FnOnce(&mut Self) -> R,

Scoped with mutable reference.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> Value for T
where T: Send + Sync + 'static,

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more