pub struct TopicRing { /* private fields */ }Expand description
FIFO ring of ObservedEvent keyed by cursor. Single owner; not
Send + Sync on its own — wrap in Arc<RwLock<…>> for cross-task
access.
Implementations§
Source§impl TopicRing
impl TopicRing
Sourcepub fn new(topic: impl Into<String>, capacity: usize, reset_epoch: u64) -> Self
pub fn new(topic: impl Into<String>, capacity: usize, reset_epoch: u64) -> Self
Construct a ring with the given capacity for a specific topic and reset epoch.
Sourcepub fn reset_epoch(&self) -> u64
pub fn reset_epoch(&self) -> u64
Current reset_epoch.
Sourcepub fn head_cursor(&self) -> u64
pub fn head_cursor(&self) -> u64
Smallest cursor currently buffered. Equal to next_cursor when empty.
Sourcepub fn next_cursor(&self) -> u64
pub fn next_cursor(&self) -> u64
Cursor that the next push will use. Useful in tests.
Sourcepub fn push(&mut self, payload: Value, received_at: String) -> u64
pub fn push(&mut self, payload: Value, received_at: String) -> u64
Push a new event with the given payload + RFC 3339 receive
timestamp. Returns the assigned cursor. If the ring is at
capacity, the oldest event is evicted (and head_cursor advances).
Sourcepub fn read_since(&self, since: u64, limit: usize) -> ReadResult
pub fn read_since(&self, since: u64, limit: usize) -> ReadResult
Read events whose cursor is strictly greater than since, capped
at limit. since == 0 means “everything currently buffered”.
Returns ReadResult::CursorExpired when since < head_cursor - 1
AND the ring has evicted at least one event the caller hasn’t seen
— i.e. there’s a real gap, not just “you’ve read everything”.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TopicRing
impl RefUnwindSafe for TopicRing
impl Send for TopicRing
impl Sync for TopicRing
impl Unpin for TopicRing
impl UnsafeUnpin for TopicRing
impl UnwindSafe for TopicRing
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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ServiceExt for T
impl<T> ServiceExt for T
§fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
fn trace_for_http(self) -> Trace<Self, SharedClassifier<ServerErrorsAsFailures>>where
Self: Sized,
§fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
fn trace_for_grpc(self) -> Trace<Self, SharedClassifier<GrpcErrorsAsFailures>>where
Self: Sized,
§fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
fn follow_redirects(self) -> FollowRedirect<Self>where
Self: Sized,
§fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_request_id<M>(
self,
header_name: HeaderName,
make_request_id: M,
) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
§fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
fn set_x_request_id<M>(self, make_request_id: M) -> SetRequestId<Self, M>where
Self: Sized,
M: MakeRequestId,
x-request-id as the header name. Read more§fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_request_id(
self,
header_name: HeaderName,
) -> PropagateRequestId<Self>where
Self: Sized,
§fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
fn propagate_x_request_id(self) -> PropagateRequestId<Self>where
Self: Sized,
x-request-id as the header name. Read more§fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
fn request_body_limit(self, limit: usize) -> RequestBodyLimit<Self>where
Self: Sized,
413 Payload Too Large responses. Read more