-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Contribution #2
Comments
Hi, @simoneromano96, thanks for your interest. If you would like to contribute, you are also welcome to join the slack workspace, so it is easier to coordinate. I'll describe the high level view of the library as I imagine it (perhaps there will be problems with lifetimes, I'm not sure, I'm rather new to rust). Please feel free to comment. The API surface will expose three main structs, the Internally, however, it is more complicated than mapping methods to rest api routes, because the library also needs to handle authentication - not just one off authentication, but also refreshing the current token, using a refresh token. I imagine using the The internal structure will mirror the typescript client, I expect. That is, the [You might notice that the python client also has a You can help out with the auth problem, or start building up the other structs (which are currently in various states of disarray). |
Hello,
Or you can use a connection struct that manage the auth token and give it to the build pattern to avoid to ask several token. I don't want to beak everything but as you start the development perhaps it's a good idea to challenge several API model with the mains use cases? |
Hi @musitdev, the client could potentially be used by a web server, and I hope to eventually write a rust CLI using this client. I think of sirixdb as similar to mongo, where in pymongo (which is what I am familiar with), where the high level break down is similar, and they are both document stores, although they are rather different in how they are document stores. Unfortunately, there is not enough documentation on actual use of SirixDB, I hope to change that in the near future, but I will presumably be dealyed 🙁. I conceived of this design because it already worked for me with the python and typescript clients. If, however there is another, better approach, I'll be happy to go that route. Before going further, I will say that although currently the client is async, I would like to support sync/multithreaded as well, as I did in the python client. However if you have another approach to authentication, I would be happy to hear it. Technically, you are correct that the auth token does not need to be persisted between api calls, however, I think it would be wasteful to ask for a token every time, particularly in a web server.
Can you elaborate on this idea, and how it would be different than the |
Ok I try to propose several API choice to manage:
|
I started my thoughts about the Rust API. I haven't finished but I would like to show you the approach that we can have. Authentication managementNeeds
PropositionThe auth process has its specific API that return an oauth token that is use to authenticate each Sirixdb call explicitly.
By default the API provide an example implementation that use KeyCloak
For the heartbeat we can provide an optional struct that manage it for the Keycloak version like:
And manage all the keep alive token process inside. A Async and non Async version should be proposed. I have to see the best way to do it. Perhaps you have some idea. The token can be used to access the database like: Some remarksFor the Sirix API, I see some pb in the python API that can be avoid or done differently in Rust.
Become Another point:
With Rust you can model the same API for different type of data and add specific data verification. |
Many thanks for your thoughts! I will quickly write some notes on your suggestions.
|
My thought about the point 3)
I don't know if these constrains (error if exist or no link to himself) are valid but it can be interesting to enumerate all so it can be integrated in the API. The goal is to block or notify during compilation the developer when he do something wrong.
It's not the final API (I even didn't try to compile it), this is an example how to use the type system to detect bad API use at compile time. In Rust it's a common practice and it's important to provide it in the API design. That why I think it's important to define what it's possible and what it's not and to try to put it in the API. |
The general thrust of your comment is to make use of the type system. For example, while in python I used an attribute to separate the resource types, and parsed based on that, in rust we can use generics at compile time. I like this idea a lot. If you have further ideas, please comment further! And of course, if you implement any of this, I will be happy review a PR 😉. |
I update the code example with the correct pattern. |
It all sounds good.
Well, they are used for their methods, which are abstractions over HTTP calls to the database. Every call does something in particular. So, reading and writing to resources will mostly be done by using XQuery/JSONiq. In the python client, I added methods that execute various simple and common queries (assuming you are using a SirixDB JSON resource as an array of objects, however, nothing requires you to use SirixDB in this way in particular). These queries are the most common use case, but I have simply been treating queries as strings, so far. I plan on reading the blog post about the error type soon. I also would like to look at how |
I think it would be interesting to start developing a CLI for the sirix client in rust, even if it is barebones, and I would be interested in exploring options. Do you have any suggestions for the design and where to start with that @mosheduminer? |
@AlvinKuruvilla I actually started work on this recently, and have a few commands working already, in a private repo. I'll just made it public at https://github.com/sirixdb/sirixsh. If you're interested in helping, we can discuss there, or in slack. |
Hello, I'd like to contribute to this Repo, where can I start? Who is managing the contributions?
The text was updated successfully, but these errors were encountered: