-
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.
feat, test, refactor: whole lotta crap
- use docs.rs/darling for the entity macro, because its just so much easier - setup the example running in ci - improve the parser a wee bit
- Loading branch information
Showing
37 changed files
with
737 additions
and
862 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
# Counter columns | ||
If you have a table that uses scylla's [`counter`](https://opensource.docs.scylladb.com/stable/cql/types.html#counters) type, you can use the `#[counter]` attribute macro on an entity column along with using the [`scylla::frame::value::Counter`](https://docs.rs/scylla/latest/scylla/frame/value/struct.Counter.html) type. | ||
If you have a table that uses scylla's [`counter`](https://opensource.docs.scylladb.com/stable/cql/types.html#counters) type, you can use the `#[entity(counter)]` attribute macro on an entity column along with using the [`scylla::frame::value::Counter`](https://docs.rs/scylla/latest/scylla/frame/value/struct.Counter.html) type. | ||
|
||
```rust | ||
#use scyllax::prelude::*; | ||
# | ||
#[entity] | ||
pub struct PersonLoginEntity { | ||
#[pk] | ||
#[entity(pk)] | ||
pub id: uuid::Uuid, | ||
#[pk] | ||
#[entity(pk)] | ||
pub person_id: uuid::Uuid, | ||
#[counter] | ||
#[entity(counter)] | ||
pub count: scylla::frame::value::Counter, | ||
} | ||
``` | ||
|
||
Similarly to `#[pk]`, the `#[counter]` attribute also tells the upsert macro how to use the column in the query. | ||
Similarly to `#[entity(pk)]`, the `#[entity(counter)]` attribute also tells the upsert macro how to use the column in the query. |
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
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# Example | ||
Are you looking for a real-life example of scyllax? You're in luck! The `exmaple` directory in our GitHub repository contains a full example of scyllax in action -- it's actually used to run tests! | ||
Are you looking for a real-life example of scyllax? You're in luck! The `example` directory in our GitHub repository contains a full example of scyllax in action -- it's actually used to run tests! | ||
|
||
[https://github.com/trufflehq/scyllax/tree/main/example](https://github.com/trufflehq/scyllax/tree/main/example) |
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
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
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
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,44 @@ | ||
//! benches | ||
use example::entities::person::{self, queries::PersonQueries}; | ||
use scyllax::prelude::{create_session, Executor}; | ||
use std::sync::Arc; | ||
use tracing_subscriber::prelude::*; | ||
|
||
async fn test_select(executor: Arc<Executor<PersonQueries>>) { | ||
let query = person::queries::GetPersonByEmail { | ||
email: "[email protected]".to_string(), | ||
}; | ||
|
||
let _ = executor | ||
.execute_read(&query) | ||
.await | ||
.expect("person not found"); | ||
} | ||
|
||
const RUNS: usize = 100_000; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), anyhow::Error> { | ||
tracing_subscriber::registry() | ||
.with(tracing_subscriber::EnvFilter::from_default_env()) | ||
.with(tracing_subscriber::fmt::layer()) | ||
.init(); | ||
|
||
let known_nodes = std::env::var("SCYLLA_NODES").unwrap_or_else(|_| String::new()); | ||
let known_nodes = known_nodes.split(',').collect::<Vec<_>>(); | ||
let default_keyspace = std::env::var("SCYLLA_DEFAULT_KEYSPACE").ok(); | ||
|
||
let session = create_session(known_nodes, default_keyspace).await?; | ||
let executor = Arc::new(Executor::<PersonQueries>::new(session).await?); | ||
|
||
let start = std::time::Instant::now(); | ||
for _ in 0..RUNS { | ||
test_select(executor.clone()).await; | ||
} | ||
let end = std::time::Instant::now(); | ||
|
||
println!("elapsed: {:#?}", end - start); | ||
println!("per run: {:?}", (end - start) / RUNS as u32); | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.