-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vaibhav Rabber <[email protected]>
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use streamstore::{ | ||
client::{ClientConfig, StreamClient}, | ||
types::{AppendInput, AppendRecordBatch, BasinName, CommandRecord}, | ||
}; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let token = std::env::var("S2_AUTH_TOKEN")?; | ||
let config = ClientConfig::new(token); | ||
let basin: BasinName = "my-basin".parse()?; | ||
let stream = "my-stream"; | ||
let stream_client = StreamClient::new(config, basin, stream); | ||
|
||
let tail = stream_client.check_tail().await?; | ||
|
||
let latest_seq_num = tail - 1; | ||
let trim_request = CommandRecord::trim(latest_seq_num); | ||
|
||
let append_record_batch = AppendRecordBatch::try_from_iter([trim_request]) | ||
.expect("valid batch with 1 command record"); | ||
let append_input = AppendInput::new(append_record_batch); | ||
let _ = stream_client.append(append_input).await?; | ||
|
||
Ok(()) | ||
} |