Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update broken examples #2

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Examples

on:
push:
branches:
- main
- 'branch-*'
pull_request:
branches:
- main
- 'branch-*'

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: full

jobs:
Examples:
runs-on: ubuntu-latest
timeout-minutes: 60
services:
scylladb:
image: scylladb/scylla-tls
ports:
- 9042:9042
- 9142:9142
options:
--health-cmd "cqlsh --debug"
--health-interval 5s
--health-retries 10
env:
working-directory: ./scylla
steps:
- uses: actions/checkout@v3
- name: Check
run: cargo check --verbose --features "ssl"
working-directory: ${{env.working-directory}}
- name: Run allocations example
run: cargo run --example allocations
- name: Run auth example
run: cargo run --example auth
- name: Run basic example
run: cargo run --example basic
# - name: Run cloud example
# run: cargo run --example cloud
# - name: Run compare-tokens example
# run: cargo run --example compare-tokens
- name: Run cql-time-types example
run: cargo run --example cql-time-types
- name: Run cqlsh-rs example
run: cargo run --example cqlsh-rs
# - name: Run custom_deserialization example
# run: cargo run --example custom_deserialization
- name: Run custom_load_balancing_policy example
run: cargo run --example custom_load_balancing_policy
# - name: Run execution_profile example
# run: cargo run --example execution_profile
- name: Run get_by_name example
run: cargo run --example get_by_name
- name: Run logging example
run: cargo run --example logging
- name: Run parallel-prepared example
run: cargo run --example parallel-prepared
- name: Run parallel example
run: cargo run --example parallel
- name: Run query_history example
run: cargo run --example query_history
- name: Run custom_load_balancing_policy example
run: cargo run --example custom_load_balancing_policy
- name: Run schema_agreement example
run: cargo run --example schema_agreement
- name: Run select-paging example
run: cargo run --example select-paging
- name: Run select-paging example
run: cargo run --example select-paging
- name: Run speculative-execution example
run: cargo run --example speculative-execution
- name: Run tls example
run: cargo run --example tls
- name: Run tower example
run: cargo run --example tower
- name: Run custom_load_balancing_policy example
run: cargo run --example custom_load_balancing_policy
- name: Run user-defined-type example
run: cargo run --example user-defined-type
- name: Run value_list example
run: cargo run --example value_list
8 changes: 4 additions & 4 deletions examples/compare-tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ async fn main() -> Result<()> {

session
.query(
"CREATE TABLE IF NOT EXISTS ks.t (pk bigint primary key)",
"CREATE TABLE IF NOT EXISTS ks.compare_tokens_example (pk bigint primary key)",
&[],
)
.await?;

let prepared = session.prepare("INSERT INTO ks.t (pk) VALUES (?)").await?;
let prepared = session.prepare("INSERT INTO ks.compare_tokens_example (pk) VALUES (?)").await?;

for pk in (0..100_i64).chain(99840..99936_i64) {
session
.query("INSERT INTO ks.t (pk) VALUES (?)", (pk,))
.query("INSERT INTO ks.compare_tokens_example (pk) VALUES (?)", (pk,))
.await?;

let serialized_pk = (pk,).serialized()?.into_owned();
Expand All @@ -43,7 +43,7 @@ async fn main() -> Result<()> {
);

let qt = session
.query(format!("SELECT token(pk) FROM ks.t where pk = {}", pk), &[])
.query(format!("SELECT token(pk) FROM ks.compare_tokens_example where pk = {}", pk), &[])
.await?
.rows
.unwrap()
Expand Down
8 changes: 4 additions & 4 deletions examples/custom_deserialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ async fn main() -> Result<()> {
session.query("CREATE KEYSPACE IF NOT EXISTS ks WITH REPLICATION = {'class' : 'NetworkTopologyStrategy', 'replication_factor' : 1}", &[]).await?;
session
.query(
"CREATE TABLE IF NOT EXISTS ks.t (pk int PRIMARY KEY, v text)",
"CREATE TABLE IF NOT EXISTS ks.custom_deserialization_test (pk int primary key, v text)",
&[],
)
.await?;

session
.query("INSERT INTO ks.t (pk, v) VALUES (1, 'asdf')", ())
.query("INSERT INTO ks.custom_deserialization_test (pk, v) VALUES (1, 'asdf')", ())
.await?;

// You can implement FromCqlVal for your own types
Expand All @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
}

let (v,) = session
.query("SELECT v FROM ks.t WHERE pk = 1", ())
.query("SELECT v FROM ks.custom_deserialization_test WHERE pk = 1", ())
.await?
.single_row_typed::<(MyType,)>()?;
assert_eq!(v, MyType("asdf".to_owned()));
Expand All @@ -62,7 +62,7 @@ async fn main() -> Result<()> {
impl_from_cql_value_from_method!(MyOtherType, into_my_other_type);

let (v,) = session
.query("SELECT v FROM ks.t WHERE pk = 1", ())
.query("SELECT v FROM ks.custom_deserialization_test WHERE pk = 1", ())
.await?
.single_row_typed::<(MyOtherType,)>()?;
assert_eq!(v, MyOtherType("asdf".to_owned()));
Expand Down
2 changes: 1 addition & 1 deletion examples/execution_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async fn main() -> Result<()> {
println!("Connecting to {} ...", uri);

let profile1 = ExecutionProfile::builder()
.consistency(Consistency::EachQuorum)
.consistency(Consistency::LocalQuorum)
.serial_consistency(Some(SerialConsistency::Serial))
.request_timeout(Some(Duration::from_secs(42)))
.load_balancing_policy(Arc::new(load_balancing::DefaultPolicy::default()))
Expand Down
Loading