Skip to main content

CursorRegistry

Struct CursorRegistry 

Source
pub struct CursorRegistry { /* private fields */ }
Expand description

Issue #807 / PRD #750 — process-wide cursor registry for /query/stream.

On a fresh stream the server mints an opaque token, pins the read snapshot LSN, and records it here scoped to the requesting (tenant, principal) with a TTL. A later resume request presents the token; resolve returns the pinned query + snapshot only when the token is live AND the caller’s scope matches.

In-memory is acceptable for this first cut (per the issue): the registry is shared via Arc so cloned server handles enforce against one map.

Implementations§

Source§

impl CursorRegistry

Source

pub fn new() -> Arc<CursorRegistry>

Source

pub fn register( &self, snapshot_lsn: u64, tenant: &str, principal: &str, query: &str, entity_types: Option<Vec<String>>, capabilities: Option<Vec<String>>, opened_at_ms: u64, ttl_ms: u64, ) -> String

Mint + record a cursor for a freshly-opened stream, returning the opaque token handed to the client. The entry expires at opened_at_ms + ttl_ms (saturating).

Source

pub fn cancel_token_for(&self, token: &str) -> Option<CancelToken>

Issue #808 / 750d — clone out the shared cancel token for a cursor the caller just minted, so the live streaming handler can poll the same flag a later cancel request raises. No scope check: the only caller is the handler that owns the freshly-registered token.

Source

pub fn cancel( &self, token: &str, tenant: &str, principal: &str, ) -> Result<CancelToken, CursorReject>

Issue #808 / 750d — cancel + tombstone a cursor on behalf of (tenant, principal). Raises the shared cancel token (so an in-flight stream observing it stops) and marks the entry cancelled so a later resume is refused with CursorReject::Cancelled.

Scope is checked exactly as in resolve: a token owned by a different tenant/principal — or one that never existed — returns CursorReject::NotFound so an unauthorized caller cannot cancel, or even confirm the existence of, a foreign stream. Cancelling an already-cancelled cursor is idempotent.

Source

pub fn resolve( &self, token: &str, tenant: &str, principal: &str, now_ms: u64, ) -> Result<CursorResume, CursorReject>

Resolve a resume token for (tenant, principal) as of now_ms.

Scope is checked before expiry: a token owned by a different tenant or principal resolves to CursorReject::NotFound — identical to a token that was never issued — so an unauthorized caller learns nothing about its existence. Only the rightful owner can observe CursorReject::Expired.

Trait Implementations§

Source§

impl Debug for CursorRegistry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for CursorRegistry

Source§

fn default() -> CursorRegistry

Returns the “default value” for a type. 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<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

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

impl<L> LayerExt<L> for L

Source§

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

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

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

Initializes a with the given initializer. Read more
Source§

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

Dereferences the given pointer. Read more
Source§

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

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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