Giter VIP home page Giter VIP logo

arangors's People

Contributors

anderssorby avatar arn-the-long-beard avatar bakjos avatar dependabot-preview[bot] avatar dependabot[bot] avatar fmeow avatar inzanez avatar joerg84 avatar manevillef avatar mrtnzlml avatar muhammad-davatgar avatar sharwinbobde avatar theduke avatar velvia avatar vihu avatar weasy666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

arangors's Issues

Error Improvements

Hello,

In arangors there are two error types:

  • ArangoError which map the ArangoDB HTTP responses whith code, error num and message
  • ClientError 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.

Document CRUD support?

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.

Is this project unmaintained?

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! ๐Ÿ˜Ž

Add Index deletion through collection

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

Improve error message when credentials for connection are wrong

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 ๐Ÿ˜‰

Reconsider futures-based interface

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.

support pipeline analyzer

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.

reqwest 0.11 breaks tokio dependencies

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

save and update views

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.

VelocyPack format

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 + rustls

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.

Normal / Admin connection

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.

Implement `Clone` on public structs

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.

Unit test failing on AqlQueryBuilder

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 :

image

Did somebody sae that 0.5.0 tests were failing ?

arangors 0.5.0 phantom compile errors

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`.

Proposal: Move `sync` and `async` features into seperate modules

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.

Remove header from document

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.

Make fields on `InsertOption`, `UpdateOption`, etc public

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:

  • Removing the TypedBuilder implementations and making a custom builder system
  • Making the fields public allowing builder and custom

Either way I can make a MR for this

Unimplemented methods

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

Could Clone be added to Connection?

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.

Are bind parameters passed on to HTTP API?

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

Add CONTRIBUTING.md

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.

rustls features don't work

Related PR: #81

When using either:

  • reqwest_blocking_rustls
  • reqwest_async_rustls

the arangors::Connection type is missing.

`blocking` feature doesn't compile

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

User used to connect requires access to _system database

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 anErr 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)

Transaction support improvements

Hello,

I am very happy with the work done by @bakjos on Streaming transaction support. I have a few suggestions:

  • Implement a conversion method from a classinc Collection<ReqwestClient> to a transactional Collection<ReqwestClient>, editing its session field adding the header value for the transaction
  • Adding documentation on various methods or an explanation on how it works would be nice, I had to look at the source code for quirte a while to understand it.

As soon as I'm done implementing this in my aragog ODM/OGM, I can make a MR for these suggestions

Change log level of connection

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.

info!("Established");

How to use tests

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 ... FAILED

failures:

---- test_aql_str stdout ----
thread 'test_aql_str' panicked at 'called Result::unwrap() on an Err value: Serde(Error("missing field jwt", line: 1, column: 75))', tests/aql.rs:1:1
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

---- test_aql stdout ----
thread 'test_aql' panicked at 'called Result::unwrap() on an Err value: Serde(Error("missing field jwt", line: 1, column: 75))', tests/aql.rs:1:1

---- test_aql_bind_vars stdout ----
thread 'test_aql_bind_vars' panicked at 'called Result::unwrap() on an Err value: Serde(Error("missing field jwt", line: 1, column: 75))', tests/aql.rs:1:1

failures:
test_aql
test_aql_bind_vars
test_aql_str

test 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.

Development Branch

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

Example dependency using the blocking feature in README.md is wrong.

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 }```

AqlQuery with bind_vars

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'

[Question] Writing bare-metal (from scratch container) applications.

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?

Streaming Transactions API Support?

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?

QueryExtra

@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:

  • aql_fetch_all
  • aql_query

might be hard. But it could still be convenient to have something integrated. How about adding new functions:

  • aql_fetch_all_extra
  • aql_query_extra

which would return QueryExtra data in addition to the results.

Make Document and Header derive Clone

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

How to use arangors with a web server

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

Support batch operations

Hi

would it make sense to implement batch operations like:

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.

User Management

Is anyone already working on the user management module of milestone 1.0.x ?

If not, I'd like to pick it up.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.