#![allow(unused_attributes)]
#![allow(unused_imports)]
#![allow(unused_results)]
#![allow(unused_variables)]
#![allow(dead_code)]
use eventstore::{
Client, PersistentSubscriptionEvent, PersistentSubscriptionOptions,
PersistentSubscriptionToAllOptions, ReplayParkedMessagesOptions, SubscriptionFilter,
};
async fn create_persistent_subscription(client: &Client) -> eventstore::Result<()> {
client
.create_persistent_subscription("test-stream", "subscription-group", &Default::default())
.await?;
Ok(())
}
async fn connect_to_persistent_subscription_to_stream(client: &Client) -> eventstore::Result<()> {
let mut sub = client
.subscribe_to_persistent_subscription(
"test-stream",
"subscription-group",
&Default::default(),
)
.await?;
loop {
let event = sub.next().await?;
sub.ack(event).await?;
}
}
async fn connect_to_persistent_subscription_to_all(client: &Client) -> eventstore::Result<()> {
let mut sub = client
.subscribe_to_persistent_subscription_to_all("subscription-group", &Default::default())
.await?;
loop {
let event = sub.next().await?;
sub.ack(event).await?;
}
}
async fn create_persistent_subscription_to_all(client: &Client) -> eventstore::Result<()> {
let options = PersistentSubscriptionToAllOptions::default()
.filter(SubscriptionFilter::on_stream_name().add_prefix("test"));
client
.create_persistent_subscription_to_all("subscription-group", &options)
.await?;
Ok(())
}
async fn connect_to_persistent_subscription_with_manual_acks(
client: &Client,
) -> eventstore::Result<()> {
let mut sub = client
.subscribe_to_persistent_subscription(
"test-stream",
"subscription-group",
&Default::default(),
)
.await?;
loop {
let event = sub.next().await?;
sub.ack(event).await?;
}
}
async fn update_persistent_subscription(client: &Client) -> eventstore::Result<()> {
let options = PersistentSubscriptionOptions::default()
.resolve_link_tos(true)
.checkpoint_lower_bound(20);
client
.update_persistent_subscription("test-stream", "subscription-group", &options)
.await?;
Ok(())
}
async fn delete_persistent_subscription(client: &Client) -> eventstore::Result<()> {
client
.delete_persistent_subscription("test-stream", "subscription-group", &Default::default())
.await?;
Ok(())
}
async fn get_persistent_subscription_to_stream_info(client: &Client) -> eventstore::Result<()> {
let info = client
.get_persistent_subscription_info("test-stream", "subscription-group", &Default::default())
.await?;
println!(
"GroupName: {}, EventStreamId: {}, Status: {:?}",
info.group_name, info.event_source, info.status
);
Ok(())
}
async fn get_persistent_subscription_to_all_info(client: &Client) -> eventstore::Result<()> {
let info = client
.get_persistent_subscription_info_to_all("subscription-group", &Default::default())
.await?;
println!(
"GroupName: {}, EventStreamId: {}, Status: {:?}",
info.group_name, info.event_source, info.status
);
Ok(())
}
async fn replay_parked_to_stream(client: &Client) -> eventstore::Result<()> {
let options = ReplayParkedMessagesOptions::default().stop_at(10);
client
.replay_parked_messages("test-stream", "subscription-group", &options)
.await?;
Ok(())
}
async fn replay_parked_to_all(client: &Client) -> eventstore::Result<()> {
let options = ReplayParkedMessagesOptions::default().stop_at(10);
client
.replay_parked_messages_to_all("subscription-group", &options)
.await?;
Ok(())
}
async fn list_persistent_subscription_to_stream(client: &Client) -> eventstore::Result<()> {
let subscriptions = client
.list_persistent_subscriptions_for_stream("test-stream", &Default::default())
.await?;
for s in subscriptions {
println!(
"GroupName: {}, EventStreamId: {}, Status: {:?}",
s.group_name, s.event_source, s.status
);
}
Ok(())
}
async fn list_persistent_subscription_to_all(client: &Client) -> eventstore::Result<()> {
let subscriptions = client
.list_persistent_subscriptions_to_all(&Default::default())
.await?;
for s in subscriptions {
println!(
"GroupName: {}, EventStreamId: {}, Status: {:?}",
s.group_name, s.event_source, s.status
);
}
Ok(())
}
async fn list_all_persistent_subscription(client: &Client) -> eventstore::Result<()> {
let subscriptions = client
.list_all_persistent_subscriptions(&Default::default())
.await?;
for s in subscriptions {
println!(
"GroupName: {}, EventStreamId: {}, Status: {:?}",
s.group_name, s.event_source, s.status
);
}
Ok(())
}
async fn restart_persistent_subscription_subsystem(client: &Client) -> eventstore::Result<()> {
client
.restart_persistent_subscription_subsystem(&Default::default())
.await?;
Ok(())
}