Skip to content

Commit 4049811

Browse files
committed
docs: update examples for retry policy
Examples in the documentation are updated to show how to set a retry policy directly on a statement.
1 parent 8058e70 commit 4049811

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

docs/source/retry-policy/default.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,21 @@ To use in a [simple query](../queries/simple.md):
3333
# extern crate scylla;
3434
# use scylla::Session;
3535
# use std::error::Error;
36+
# use std::sync::Arc;
3637
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
3738
use scylla::query::Query;
3839
use scylla::transport::ExecutionProfile;
3940
use scylla::transport::retry_policy::DefaultRetryPolicy;
4041

42+
// Create a Query manually and set the retry policy
43+
let mut my_query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(?)");
44+
my_query.set_retry_policy(Some(Arc::new(DefaultRetryPolicy::new())));
45+
46+
// You can also set retry policy in an execution profile
4147
let handle = ExecutionProfile::builder()
4248
.retry_policy(Box::new(DefaultRetryPolicy::new()))
4349
.build()
4450
.into_handle();
45-
46-
// Create a Query manually and set the retry policy
47-
let mut my_query: Query = Query::new("INSERT INTO ks.tab (a) VALUES(?)");
4851
my_query.set_execution_profile_handle(Some(handle));
4952

5053
// Run the query using this retry policy
@@ -59,21 +62,23 @@ To use in a [prepared query](../queries/prepared.md):
5962
# extern crate scylla;
6063
# use scylla::Session;
6164
# use std::error::Error;
65+
# use std::sync::Arc;
6266
# async fn check_only_compiles(session: &Session) -> Result<(), Box<dyn Error>> {
6367
use scylla::prepared_statement::PreparedStatement;
6468
use scylla::transport::ExecutionProfile;
6569
use scylla::transport::retry_policy::DefaultRetryPolicy;
6670

67-
let handle = ExecutionProfile::builder()
68-
.retry_policy(Box::new(DefaultRetryPolicy::new()))
69-
.build()
70-
.into_handle();
71-
7271
// Create PreparedStatement manually and set the retry policy
7372
let mut prepared: PreparedStatement = session
7473
.prepare("INSERT INTO ks.tab (a) VALUES(?)")
7574
.await?;
75+
prepared.set_retry_policy(Some(Arc::new(DefaultRetryPolicy::new())));
7676

77+
// You can also set retry policy in an execution profile
78+
let handle = ExecutionProfile::builder()
79+
.retry_policy(Box::new(DefaultRetryPolicy::new()))
80+
.build()
81+
.into_handle();
7782
prepared.set_execution_profile_handle(Some(handle));
7883

7984
// Run the query using this retry policy

0 commit comments

Comments
 (0)