fmeow / arangors Goto Github PK
View Code? Open in Web Editor NEWEasy to use rust driver for arangoDB
Home Page: https://docs.rs/arangors
License: MIT License
Easy to use rust driver for arangoDB
Home Page: https://docs.rs/arangors
License: MIT License
Hello,
In arangors
there are two error types:
ArangoError
which map the ArangoDB HTTP responses whith code, error num and messageClientError
which is the global error enum, with a ArangoError
variant and a few other variants which are irrelevant to the document operation responses.I can make a Merge requests changes the error type of ArangoDB operations from ClientError
to a ArangoError
.
With the From<>
implementation for ClientError
this won't be breaking changes but it will at least allow more specific error handling.
Is any plan to implement the Collection
create_document
, remove_document
, update_document
methods in the near future? They are essential features for this crate. The api endpoints are rather simple to interact with, and I would be happy to implement these endpoints myself if you give me some guidance in regards to how to implement them with regards to your already existing crate architecture.
Hi
It seems that arangors::Connexion is not available anymore in version = "0.5.3"
Thanks
Title says it all.
Unexpectedly, a regular document collection is created.
Hola @fMeow! ๐ I am following this project for some time already and I noticed that it takes a very long time to merge some PRs, dependencies are not being upgraded regularly and it generally seems like this project is no longer actively maintained.
What is the status? Do you need some extra help? It would be nice to clarify this situation and to know what is the future of this project.
Thank you very much! ๐
Hello,
Currently the index deletion works by the index name (database.delete_index("index_name")
) but it fails:
ClientError(Arango(ArangoError { code: 400, error_num: 400, message: "expecting DELETE /<collection-name>/<index-identifier>" }))
I will add the collection-name
argument in a PR but I'm not sure if that's the best way to do this
Also I can't find the HTTP doc on this.
I tag @inzanez since he made the index management
Hello guys ! It is a long time ๐
I am still continuing my journey on Rust ๐
Well I saw today that if the credentials for connection are wrong we get this :
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error("missing field `jwt`"
The error comes from there :
#[maybe_async]
async fn jwt_login<T: Into<String>>(
arango_url: &Url,
username: T,
password: T,
) -> Result<String, ClientError> {
#[derive(Deserialize)]
struct JWT {
pub jwt: String,
}
let url = arango_url.join("/_open/auth").unwrap();
let mut map = HashMap::new();
map.insert("username", username.into());
map.insert("password", password.into());
let jwt: JWT = serde_json::from_str(
C::new(None)?
.post(url, &serde_json::to_string(&map)?)
.await?
.body(),
)
.unwrap();
Ok(jwt.jwt)
}
Maybe we could improve the error message maybe and give an error like " Unauthorized" or something .
What do you think ?
I can make it if you want ๐
I really need to have a asynchronous interface to Arango.
reqwest already provides the reqwest::r#async::Client
async client that can be used easily. It would need an additional refactor and major version bump when async/await hits stable, but that will only happen in late September.
Let me know if you'll accept a PR, otherwise I'll just roll my own.
arangors
currently doesn't support creating pipeline analyzers. which are very useful and would be nice to have
i have already implemented it in my own fork so ill just open a pull request. ill give a little explanation about what i have done below. it's my first contribution so i don't know where else i can put it. hope that's ok.
The 0.4.7
release bumped the reqwest
dependency to 0.11 which depends on tokio
1.x instead of 0.2.x
arangors
can no longer be used with actix-web
until they release the v4 (still in beta) based on tokio 1.x.
I think this version bump should be mentioned in the Changelog as a breaking change or rollbacked
i have checked the document for View
type and it doesn't seem to have a way of saving the created view
(or does merely creating a View
struct saves it to db as well ? i doubt it ) and also how can i update a saved view ?
if arangors doesn't provide these yet i would be happy to implement those and make a pull request.
In case it's of any use/interest, I've started work on a Rust implementation of the VelocyPack format in Rust at: https://github.com/davechallis/rust-velocypack
It's currently got some basic serialization working, currently working on the deserialization part (it's got a long way to go with documentation, decent error messages etc. though of course).
It's implemented using serde, so should hopefully end up not being too painful to work with.
reqwest has the rustls-tls
feature that will use rustls
instead of the native system openssl library.
Would be great to have an extra feature to toggle this.
Hello there
I was wondering if there were any specific reason for having two different connection types for Admin and Normal connections? Is this really a requirement, or could we just switch to a single connection type?
I'm justing seeing some problems in r2d2 as the connections cannot be converted into admin connections. And so I started thinking about it and I somehow do not really see any advantage of having this distinction. The ArangoDB API will respond with an according error if someone without access is trying to modify the _system database.
Hello,
Since I'm working on a arango ORM/ODM and currently working on migrations and schema generation I use structs like IndexSettings
, Graph
, EdgeDefinitions
, etc. But I sometimes need to clone them, I have workarounds using serde
but I wonder if we could just make these structs derive Clone
by default.
I can make a pull request for this but I don't know if you think it's useful or not.
Hey @fMeow , how are you doing ? ๐
I am still playing with Rust ๐
But I got an issue today and I am not sure why. I did updated arangor to 0.5.0 since I am using the latest actix-web
now.
Here is the error when I want to use arangors 0.5.0
or unit test it :
Did somebody sae that 0.5.0 tests were failing ?
I'm using rustc 1.57.0-nightly (f03eb6bef 2021-10-02). Getting compile errors from 0.5.0 crate:
Checking arangors v0.5.0
error[E0560]: struct `AqlQueryBuilder<'_, (__query, (HashMap<&str, Value>,), __count, __batch_size, __cache, __memory_limit, __ttl, __options)>` has no field named `_phantom`
--> /Users/evan/.cargo/registry/src/github.com-1ecc6299db9ec823/arangors-0.5.0/src/aql.rs:153:13
|
153 | _phantom: self._phantom,
| ^^^^^^^^ help: a field with a similar name exists: `phantom`
error[E0609]: no field `_phantom` on type `AqlQueryBuilder<'a, (__query, (), __count, __batch_size, __cache, __memory_limit, __ttl, __options)>`
--> /Users/evan/.cargo/registry/src/github.com-1ecc6299db9ec823/arangors-0.5.0/src/aql.rs:153:28
|
153 | _phantom: self._phantom,
| ^^^^^^^^ help: a field with a similar name exists: `phantom`
Some errors have detailed explanations: E0560, E0609.
For more information about an error, try `rustc --explain E0560`.
As came up in the discussion on this rwf2/Rocket#1433, do you think it is feasible to move the sync
and async
features into seperate modules, like reqwest
is doing? So that both can be used simultaneously within one workspace. Otherwise it would not be possible to integrate both, as an option the rocket user can choose from, in rocket_contrib
.
The current behavior of the two features would force rocket_contrib
to decide which of both to integrate and block the other feature from ever be used with it.
Hi
does it really make sense to have the Header
included in the Document<T>
structure? Wouldn't it make more sense to let the user of the driver decide whether or not that part of the response is going to be deserialized? Simply by including the header properties (merged or not) in the struct T
?
I currently use AQL queries all over the place, and this works quite well as it just serializes/deserializes T
. So I get my headers automatically, and I can send them along to the client.
If I were to use the document level driver functions instead, I would have to copy the deserialized header parts over to my T
if I needed them. And as far as I can tell, the Arango driver never actually uses the Header
structure. So it should be safe to remove the Header
fields and just deserialize to T
.
enums like:
InsertOptions
UpdateOptions
ReplaceOptions
all have their fields being private and we have to use the derived TypedBuilder
for customization.
I have an issue with that, in some cases I want to leave a None
value which is not possible in current implementation.
Example:
let builder = InsertOptions::builder();
if some_condition {
builder.wait_for_sync(true);
}
builder.build()
So I have two proposals:
TypedBuilder
implementations and making a custom builder systemEither way I can make a MR for this
There are a quite a few methods that just contain unimplemented!()
.
These should really be removed until they are implemented.
At the very least there must be a big warning in the README.
Eg Collection::create/update/replace/remove_document
Line 41 in d4f0518
It would sometimes be useful to be able to clone a Connection
after it's been created, and collections fetched etc.
All of its member structs are cloneable, so should just be a case of adding derive(Clone)
to Database
and Connection
structs.
But perhaps there's a good reason not to, I'm not that familiar with the codebase yet.
Just curious, if we use parameter binding, is this passed through to the HTTP API, or is the final AQL constructed in the client side and passed through to HTTP? This is sort of a security issue for us.
Thanks
Hello, I was thinking that maybe we could have this file so we have quick instructions for people on how to help the project.
What do you think?
It can be good for beginners like me too.
Related PR: #81
When using either:
reqwest_blocking_rustls
reqwest_async_rustls
the arangors::Connection
type is missing.
Hola! ๐ I saw that one month ago, this awesome commit landed: 1be43eb
However, it doesn't seem to be released yet. ๐ค Would it be possible to release a new version with this change, please? Thank you very much for considering it! ๐
Hello, I have the following in the Cargo.toml
just like the example.
arangors = { version = "0.4.5", features = ["blocking"], default-features = false }
Here's the output on build
=
Compiling arangors v0.4.5
error[E0599]: no method named `map_err` found for opaque type `impl std::future::Future` in the current scope
--> /Users/felixdemaneville/.cargo/registry/src/github.com-1ecc6299db9ec823/arangors-0.4.5/src/client/reqwest.rs:39:14
|
39 | .map_err(|e| ClientError::HttpClient(format!("{:?}", e)))?;
| ^^^^^^^ method not found in `impl std::future::Future`
|
= help: items from traits can only be used if the trait is in scope
= note: the following trait is implemented but not in scope; perhaps add a `use` for it:
`use futures_util::future::try_future::TryFutureExt;`
error: aborting due to previous error
I don't know if there was a regression or if I'm doing something wrong
When trying to connect to arangodb without the user having access to _system
arangors will fail with thread 'main' panicked at 'called
Result::unwrap()on an
Err value: ErrorMessage { msg: "not authorized to execute this request" }', src/libcore/result.rs:999:5
In the requests logs this shows up as "GET","HTTP/1.1",401,0,95,"/_api/database/user",0.000039
I can connect just fine using arangosh and pyArango without giving the user access to _system
so is this request really necessary?
The code is copied from the example: Connection::establish_basic_auth("http://localhost:8529", "username", "password").unwrap();
(replaced with the proper credentials)
Hi,
Is arangors still under maintanence ? I notice that it's not active recently.
I want to to use ArangoDB in actix, an backend rust web framework:
actix/actix-web#3058 (comment)
Hello,
We don't have any option to create Named Graphs with arangors
and I need the feature for my own crate.
Based on https://www.arangodb.com/docs/stable/http/gharial-management.html#drop-a-graph and the Index management Pull request by @inzanez I did this: #47
I'm not sure if it's the way you want to do it but It works. The graphs are not editable, this can be a future pull request.
Thank you !
Hello,
I am very happy with the work done by @bakjos on Streaming transaction support. I have a few suggestions:
Collection<ReqwestClient>
to a transactional Collection<ReqwestClient>
, editing its session
field adding the header value for the transactionAs soon as I'm done implementing this in my aragog
ODM/OGM, I can make a MR for these suggestions
Could you maybe change the log level to debug? Otherwise, using arangors with r2d2_arangors in Rocket spams the console on starting the server, because the connection pool opens a lot of connections and on every connection the message gets printed.
arangors/src/connection/mod.rs
Line 219 in cfa2ae9
Hi
is there someone already working on index management?
Hey Mate ! How are you doing ?
Since I have a lot of time and I decided to focus more on Rust for the next few days, I am working on the Apis that are not implemented. I know they are not priority but they are easier to reach because I am a baby at rust.
But before, I got some errors when I do cargo test
Here is the result
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
Running target/debug/deps/aql-61c500ad8a94bb5b
running 4 tests
test common::test_setup ... ok
test test_aql_str ... FAILED
test test_aql ... FAILED
test test_aql_bind_vars ... FAILEDfailures:
---- test_aql_str stdout ----
thread 'test_aql_str' panicked at 'calledResult::unwrap()
on anErr
value: Serde(Error("missing fieldjwt
", line: 1, column: 75))', tests/aql.rs:1:1
note: run withRUST_BACKTRACE=1
environment variable to display a backtrace---- test_aql stdout ----
thread 'test_aql' panicked at 'calledResult::unwrap()
on anErr
value: Serde(Error("missing fieldjwt
", line: 1, column: 75))', tests/aql.rs:1:1---- test_aql_bind_vars stdout ----
thread 'test_aql_bind_vars' panicked at 'calledResult::unwrap()
on anErr
value: Serde(Error("missing fieldjwt
", line: 1, column: 75))', tests/aql.rs:1:1failures:
test_aql
test_aql_bind_vars
test_aql_strtest result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 0 filtered out
error: test failed, to rerun pass '--test aql'
I get this error on both dev and master. I do not understand where the error is located because it says line 1 for each of them. It looks like not every test is used also.
What is your advice ?
Best regards,
Arn with a very long beard.
PS : I tried with ./init_db.sh file and then run tests but it still does not work.
Hi
would you mind opening up a development branch where I could submit subsequent pull requests? I would like to extend the functionality of arangors in the months to come.
Best regards
README.md says that you need to select features as "blocking" to use synchronous feature.
But I think correct option for use synchronous is "reqwest_blocking".
Please change "features = ["blocking"]" to "features = ["reqwest_blocking"]".
Problem section
[dependencies]
## This one is async
arangors = { version = "0.4", default-features = false }
## This one is synchronous
arangors = { version = "0.4", features = ["blocking"], default-features = false }```
Hi
How is one supposed to be using bind_vars? Using the web-query-builder from ArangoDB, I'm used to being able to create queries as follows:
INSERT @user INTO @@collection
with user: { "name": "Test" }
and @collection: "users"
.
Assuming I tried the same with the query builder, I tried:
const COLLECTION: &str = "users";
#[derive(Serialize)]
pub struct User {
name: String,
}
fn main() {
let user = User { name: "Tester".to_string() };
let conn = Connection::establish_jwt("http://localhost:8529", "root", "Password")
.unwrap();
let db = conn.db("Test").unwrap();
let json = serde_json::to_string(&user).unwrap();
let aql = AqlQuery::builder()
.query("INSERT @user INTO @@collection LET result = NEW RETURN result")
.bind_var("@collection", COLLECTION)
.bind_var("user", json)
.build();
let result: Vec<Value> = db.aql_query(aql).expect("Query failed");
}
However, that fails, as the query generated escapes the double quotes in the JSON that I generated. Resulting in this:
{"query":"INSERT @client INTO @@collection LET result = NEW RETURN result","bindVars":{"client":"{\"name\":\"Tester\"}","@collection":"fs_clients" }
instead of this
{"query":"INSERT @client INTO @@collection LET result = NEW RETURN result","bindVars":{"client":"{"name":"Tester"}","@collection":"fs_clients" }
If I tried assigning the user
struct directly however:
const COLLECTION: &str = "users";
#[derive(Serialize)]
pub struct User {
name: String,
}
fn main() {
let user = User { name: "Tester".to_string() };
let conn = Connection::establish_jwt("http://localhost:8529", "root", "Password")
.unwrap();
let db = conn.db("Test").unwrap();
let aql = AqlQuery::builder()
.query("INSERT @user INTO @@collection LET result = NEW RETURN result")
.bind_var("@collection", COLLECTION)
.bind_var("user", user)
.build();
let result: Vec<Value> = db.aql_query(aql).expect("Query failed");
}
I cannot compile, as:
^^^^^^^^ the trait 'std::convert::From<User>' is not implemented for 'serde_json::value::Value'
Does arangors require any linked Linux user-land components?
I'm looking for a way of creating single binaries that use arrangodb servers that can be instanced as a single file in a "from scratch" container.
In particular does it require any linked security components for SSL connections? or can it perform that with just the binary and a cert?
Any plans on adding support for this: https://www.arangodb.com/2019/08/rc7-of-arangodb-3-5-streaming-transactions-api/
Also, definitely keep up the good work here! I am planning on cutting a system over to ArangoDB which has previously been based on MongoDB. It would be excellent to see support for this stuff as well as async support based on the new futures & async/await features landing in Rust.
Also, I built the Wither ODM a while back, which is great, but the MongoDB team has left the underlying driver in a pretty stagnant state. Do you think there is value in building a data modelling ODM-like system for Arango as well?
@fMeow Did you have any plans on how to implement retrieval of QueyExtra
data? I would like to implement that asap, as I need it.
I was just scanning through the code and think that extending the existing functions:
might be hard. But it could still be convenient to have something integrated. How about adding new functions:
which would return QueryExtra
data in addition to the results.
Hello, it's a simple request, but is there any reason why these two structures don't derive Clone. I'm trying to return by value and I'm struggling a bit how to get an owned Document out of the local results vector
Hello !
First, I am huge fan of ArangoDB, and I am starting rust serisouly only now. So big thank you for having made this package ! I am very fresh on rust, like a newbie, nice contrast from my js/ts world lol
Your package is the most advanced regarding Arango driver for Rust. But it seems you might need extra help maybe.
But first, I need some help. I am trying to use Arangodb on a actix-web server that I am making. But I am getting this error message
Here is the message I am having
error[E0277]: the trait bound
arangors::database::Database<'_>: std::clone::Clone
is not satisfied in[closure@src/main.rs:130:38: 161:6 db:arangors::database::Database<'_>]
And here is the code that make it happen
let conn = Connection::establish_jwt("http://localhost:8529", "USER", "BEST PASSWORDEVER").unwrap();
let db= conn.db("test_db").unwrap() ;
let mut server = HttpServer::new(|| {
App::new()
.data(db)
.wrap(Logger::default())
.service(
web::scope("/api")
.service(
web::resource("/auth")
.route(web::post().to(login))
),
)
});
I tried to implement it with :
impl Clone for Database { fn clone(&self) -> Self { unimplemented!() } }
But then I got
|
104 | impl Clone for Database {
| ^^^^^^^^^^^^^^^--------
| | |
| |arangors::database::Database
is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
Do you know how could I handle arangors inside my web server ? I do not want to write backend in Foxx Microservice, I really need to write rust code for my stuff. Also, if you need contributors, maybe I could be one if you want. But never done it before. I just have much time available right now.
Best regards,
a man with a very long beard because the barbershop is closed due to you know lol
Add a trait so that it would be possible to use a generic function.
Hi
would it make sense to implement batch operations like:
arangors::collection::Collection
based on [this documentation])(https://www.arangodb.com/docs/stable/http/document-working-with-documents.html#create-multiple-documents).I guess this could be achieved using aql
as well (bindvars with a Vec
), but especially bulk import / export will give some performance benefits, according to the documentation.
Is anyone already working on the user management module of milestone 1.0.x
?
If not, I'd like to pick it up.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.