Struct EventQueue

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

Implementations§

Source§

impl EventQueue

Source

pub fn new(store: Arc<CacheStore>, events: Arc<EventsClient>) -> Self

Source

pub fn with_logger(self, logger: Arc<Logger>) -> Self

Source

pub fn enqueue(self: &Arc<Self>, envelope_json: &str) -> RovenueResult<()>

Validate envelope_json (must parse as an EventEnvelope whose eventType starts with one of QUEUED_EVENT_PREFIXES — anything else is rejected as InvalidArgument, this is not a general-purpose enqueue), persist it (bounded at 100 entries, drop-oldest — see CacheStore::append_queued_event), then trigger a best-effort background drain. The caller (funnel sessions emit pre-stamped envelopes) is responsible for stamping version/eventId/subscriberId before calling this — those fields must already be baked into envelope_json so a drain that runs after a log_out() still posts under the identity the event was actually attributed to.

Source

pub fn trigger_drain(self: &Arc<Self>)

Spawns a background thread to run drain_once. Fire-and-forget and non-blocking — callers on the configure()/ set_foreground() paths must never wait on network I/O here.

Source

pub fn drain_once(&self)

Peek (oldest first) -> POST /v1/events -> delete on 2xx. On connectivity failure / 5xx/429, or a non-poison 4xx (401/403 auth blip, 408, etc. — see RovenueError::is_poison), the entry (and everything behind it) is retained and the drain stops — at-least-once delivery, safe because the server dedupes on the deterministic event id and bounded because the queue itself is capped at 100 with drop-oldest. Only a genuine envelope rejection (400/422) is poison: retaining it would wedge every later entry behind it forever, so it is dropped (loudly logged) and the drain continues with the next entry.

Single-in-flight: a drain already running makes this call a no-op — the in-progress drain will pick up anything enqueued meanwhile since it re-peeks the store on every iteration. There is a narrow window between the drain loop seeing an empty queue and the flag actually clearing where a concurrent enqueue() can land its own no-op drain; see the re-arm check below.

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

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.

§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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
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.
§

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

§

fn vzip(self) -> V

§

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