pub struct ReadSessionRequest {
pub start: ReadStart,
pub limit: ReadLimit,
pub until: Option<RangeTo<u64>>,
pub clamp: bool,
}
Expand description
Read session request.
Fields§
§start: ReadStart
Starting position for records. Retrieved batches will start at the first record whose position is greater than or equal to it.
limit: ReadLimit
Limit on how many records can be returned. When a limit is specified, the session will be terminated as soon as the limit is met, or when the current tail of the stream is reached – whichever occurs first. If no limit is specified, the session will remain open after catching up to the tail, and continue tailing as new messages are written to the stream.
until: Option<RangeTo<u64>>
Exclusive timestamp to read until.
If provided, this is applied as an additional constraint on top of the limit
,
and will guarantee that all records returned have timestamps < the provided until
.
clamp: bool
Clamp the start position at the tail position.
Implementations§
Source§impl ReadSessionRequest
impl ReadSessionRequest
Sourcepub fn new(start: ReadStart) -> Self
pub fn new(start: ReadStart) -> Self
Create a new request with the specified starting point.
Examples found in repository?
9async fn main() -> Result<(), Box<dyn std::error::Error>> {
10 let token = std::env::var("S2_ACCESS_TOKEN")?;
11 let config = ClientConfig::new(token);
12 let basin: BasinName = "my-favorite-basin".parse()?;
13 let stream = "my-favorite-stream";
14 let stream_client = StreamClient::new(config, basin, stream);
15
16 let start_seq_num = 0;
17 let read_session_request = ReadSessionRequest::new(ReadStart::SeqNum(start_seq_num));
18 let mut read_stream = stream_client.read_session(read_session_request).await?;
19
20 loop {
21 select! {
22 next_batch = read_stream.next() => {
23 let Some(next_batch) = next_batch else { break };
24 let next_batch = next_batch?;
25 println!("{next_batch:?}");
26 }
27 _ = tokio::signal::ctrl_c() => break,
28 }
29 }
30
31 Ok(())
32}
Sourcepub fn with_limit(self, limit: ReadLimit) -> Self
pub fn with_limit(self, limit: ReadLimit) -> Self
Overwrite limit.
Sourcepub fn with_until(self, until: RangeTo<u64>) -> Self
pub fn with_until(self, until: RangeTo<u64>) -> Self
Provide an until
timestamp.
Sourcepub fn with_clamp(self, clamp: bool) -> Self
pub fn with_clamp(self, clamp: bool) -> Self
Clamp the start position at the tail position.
Trait Implementations§
Source§impl Clone for ReadSessionRequest
impl Clone for ReadSessionRequest
Source§fn clone(&self) -> ReadSessionRequest
fn clone(&self) -> ReadSessionRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ReadSessionRequest
impl Debug for ReadSessionRequest
Source§impl Default for ReadSessionRequest
impl Default for ReadSessionRequest
Source§fn default() -> ReadSessionRequest
fn default() -> ReadSessionRequest
Auto Trait Implementations§
impl Freeze for ReadSessionRequest
impl RefUnwindSafe for ReadSessionRequest
impl Send for ReadSessionRequest
impl Sync for ReadSessionRequest
impl Unpin for ReadSessionRequest
impl UnwindSafe for ReadSessionRequest
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request