Comments (7)
@pkolaczk do you know what might be the cause? I was able to reproduce by trying to use (and slightly adapt to be precise) the uuid example code. I can share a gist if helpful.
from stargate-grpc-rust-client.
Can you show me your Cargo.toml and the command line you're building and running the program?
Feature uuid
must be enabled explicitly to allow conversions to/from uuid::Uuid
.
It is not sufficient to only add the uuid
dependency.
from stargate-grpc-rust-client.
uuid = { version = "0.8.2", features = ["serde","v4"] }
stargate-grpc = {version = "0.3.0", features = ["uuid","macros","chrono"]}
stargate-grpc-derive = "0.2.0"
I didn't notice this at first, and it did help with conversion to cql, but the reverse still fails.
I should note, it may be helpful to expand the documentation a bit to more explicitly call this out, as with other cases like udt attributes IntoValue/TryFromValue, and how to handle sharing the mutable client. I'm fairly new to rust, maybe it's just me, but it would go a long way for my project.
from stargate-grpc-rust-client.
ok, so after adding the "uuid" feature, can you paste the actual code that's causing the problem?
let userid: Uuid = userid_res.rows.first().try_into()?;
That doesn't look right IMHO, because you're trying to convert the whole Row
into a single Uuid
.
You probably wanted to convert a column value to a Uuid
.
Have you tried:
let userid: Uuid = userid_res.rows.first().try_take(0)?;
I should note, it may be helpful to expand the documentation a bit to more explicitly call this out, as with other cases like udt attributes IntoValue/TryFromValue
The docs contain a paragraph on exactly that. Is there anything missing there?
https://docs.rs/stargate-grpc/0.3.0/stargate_grpc/#working-with-uuids
and how to handle sharing the mutable client
Don't share. Simply create multiple clients. They are very lightweight.
from stargate-grpc-rust-client.
That doesn't look right IMHO, because you're trying to convert the whole
Row
into a singleUuid
. You probably wanted to convert a column value to aUuid
. Have you tried:let userid: Uuid = userid_res.rows.first().try_take(0)?;
rows.first() returns option, so I think it would have to be something closer to:
let userid_res: ResultSet = session.execute_query(userid_query).await?.try_into()?; let userid: Uuid; if let Some(row) = userid_res.rows.first() { userid = row.try_take(0).try_into()?; };
but this doesn't work either.
I should note, it may be helpful to expand the documentation a bit to more explicitly call this out, as with other cases like udt attributes IntoValue/TryFromValue
The docs contain a paragraph on exactly that. Is there anything missing there?
Only that I can't get it to work based on the docs. :/
Don't share. Simply create multiple clients. They are very lightweight.
One of the big advantages of Http/2 is that it allows multiple requests over the same connection, reducing connection overhead and boosting perf. Even Http/1.1 allows connection sharing, though with some limits. This advantage is lost if you have to open a connection for every request. For this use case, we can assume a high volume of concurrent requests. Protobuf gives us a bit of an edge, but I need to share connections. Unless I overlooked something?
from stargate-grpc-rust-client.
but this doesn't work either.
Then please provide the error message.
Only that I can't get it to work based on the docs. :/
All examples in the docs are fully compiled and tested automatically.
Also there is examples
folder, and as far as I remember, one of the examples shows how to use uuids.
Have you tried looking there?
One of the big advantages of Http/2 is that it allows multiple requests over the same connection
Sure, but I didn't write you should create multiple connections, but just create multiple clients.
Cloning the clients is cheap and doesn't create more connections:
Tonic docs say:
/// `Channel` provides a
/// `Clone` implementation that is _cheap_. This is because at the very top level
/// the channel is backed by a `tower_buffer::Buffer` which runs the connection
/// in a background task and provides a `mpsc` channel interface. Due to this
/// cloning the `Channel` type is cheap and encouraged.
from stargate-grpc-rust-client.
In just released 0.4.0, you can try:
let row = userid_res.rows.first().unwrap();
let (userid,): (Uuid,) = row.try_into()?;
from stargate-grpc-rust-client.
Related Issues (9)
- Remove use of `Payload` HOT 2
- Rename master branch to main HOT 2
- Set user-agent
- How does CQL respond when there is an error? Requesting pointers for catching the errors
- Feature: WASM/WASI support
- Testing with Stargate Docker container
- How to use Blob?
- How to use StargateClient in web framework like axum?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stargate-grpc-rust-client.