Comments (4)
My purpose is to avoid a dangling Database
instance that the database it refers to has been dropped.
Say we have an instance of connection conn
, and we derived a database instance db
and the name of database is test_db
:
let conn = Connection::establish_jwt("http://localhost:8529", "username", "password").await.unwrap();
let db = conn.db("test_db").unwrap();
If we simple drop database test_db
with conn
, the db
object is a nonsense that every request fails on runtime. Since rust is a compile language, it's not like python or javascript that a coder can instantly response in the interpreter. Instead of handling it after it happen, it's better to avoid it in the first place if we know it will fails. In this specific case, I think it is better to fail at compiler time than runtime.
Maybe we can move the create_database
to Normal role and only keep drop_database
in Admin
, this might alleviate your problems with r2d2. Though this can cause confusion.
BTW, the async/await support is on air in develop branch. I will publish it once I finished strong typing lib error.
from arangors.
@fMeow Thank you for your answer. I somehow don't quite agree. The part about Rust being a statically typed language with many compiler checks refers mainly to the fact that unsafe programming styles should be mitigated, like ending up with dangling pointers, not handling paths in a decision tree etc. So it removes a lot of possibilities for fatal crashes / vulnerabilities / other unwanted effects.
Regarding the database connection, I agree that a connection to a deleted database will not be of any value. But handling an error of this form (a database that's being queried does not exist anymore) is not something you can possibly verify at compile time. For one part, it could very well be that the ArangoDB cluster houses other applications with admin access (and they could for whatever reason delete a database still in use), or an administrator could do the same. I could actually even do the same with the current 'arangors' implementation by spawning a separate admin connection and deleting the database.
Apart from that I also think that the error is quite nice to handle, as ArangoDB replies:
{
"error": true,
"errorNum": 1228,
"errorMessage": "database not found",
"code": 404
}
So pushing everything into one connection could make sense, as it will remove some complexity that might not be required. What do you think?
BTW, the async/await support is on air in develop branch. I will publish it once I finished strong typing lib error.
That's very pleasant news!
from arangors.
Thank you for your illustration.
I make it clear that Admin
role is the one to perform admin operation, like something on _system
database, backup/restore and other functions that can be reached in _api/admin
.
Certainly creation and delete of database should not counted as admin role. So I moved create_database
and drop_database
to Normal role.
This comes in the 0.3 version.
from arangors.
@fMeow perfect, I'm looking forward to those changes. Many thanks!
from arangors.
Related Issues (20)
- Add Trait for Database<T> and Transaction<T> HOT 4
- arangors::Connexion problem
- rust web development HOT 1
- User Management HOT 2
- reqwest + rustls HOT 6
- Release: new version with transactions, analyzers and views? HOT 2
- Example dependency using the blocking feature in README.md is wrong. HOT 1
- Transaction support improvements
- Error Improvements HOT 1
- Improve error message when credentials for connection are wrong HOT 5
- Make fields on `InsertOption`, `UpdateOption`, etc public HOT 3
- reqwest 0.11 breaks tokio dependencies HOT 4
- Is this project unmaintained? HOT 3
- Make Document and Header derive Clone HOT 2
- Unit test failing on AqlQueryBuilder HOT 5
- rustls features don't work
- arangors 0.5.0 phantom compile errors HOT 11
- Are bind parameters passed on to HTTP API? HOT 3
- save and update views HOT 1
- support pipeline analyzer HOT 1
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 arangors.