-
Notifications
You must be signed in to change notification settings - Fork 12
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
Create a HTTP
server on top of struct_db
#3
Comments
Hi @elliot14A, Thank you so much for your interest in the project and for proposing this feature. Initially, I hadn't considered creating an HTTP server as a primary feature, but upon reflection, I believe it could add significant value and versatility to I'm totally on board about the potential this brings to the project and for you to start working on this. Before you start, could you share some more details? Do you have any specific server functionalities in mind? Are there any particular Rust libraries that you'd like to use? Also, do you have a specific design and code organization structure that you're thinking about? Any insight would be incredibly beneficial as it will help to align our visions and ensure a seamless integration of the feature with the existing codebase. Looking forward to your response, and thanks again for your initiative! |
Thanks for the positive response. Regarding your questions, I think it would be great to have basic CRUD (Create, Read, Update, Delete) operations through HTTP endpoints, as well as the ability to query the database through URL parameters for the start, just as the implementation of SurrealDB. I think IndraDB which is a GraphDB uses gRPC. I'm open to both implementations. Coming to the architecture I really like ports and adapters architecture I think we should follow this design pattern and code organization structure. I think axum is great choice for http server. Would love to listen to your opinion on these approach I have mentioned. |
@elliot14A I agree, starting with a simple HTTP server allowing CREATE/READ operations would be a good first iteration to validate the prototype. My main concern would be the separation of the server and database code. I suggest creating a sub-separate crate which could be optionally enabled as a feature and added as a member of the workspace Another aspect to consider is that SurrealDB and IndraDB are not embedded databases by default; they are designed to be used as separate servers. Here, we are dealing with an entirely different paradigm. As Regarding the HTTP server library, I also agree on using axum. |
@vincent-herlemont I understand now, even I thought of creating a separate crate for the http server implementation as well. So, on a higher level POST is this fine? |
@elliot14A Yes, your approach looks sound to me! You're welcome to create the PR when you're ready. In the meantime, I'm setting up the continuous integration (CI) to ensure that we maintain a high level of code quality throughout the project. |
Hey @vincent-herlemont, I have started working the implementation. But, I have faced an issue where I need your advise. |
here is an more elaborate explanation: #[derive(Serialize, Deserialize, Debug, Clone)]
#[struct_db::struct_db(fn_primary_key(p_key))]
struct Item {
id: i32,
list: Vec<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone)]
#[struct_db::struct_db(fn_primary_key(p_key))]
struct Collection {
id: i32,
items: Vec<Item>,
}
impl Collection {
pub fn p_key(&self) -> Vec<u8> {
self.id.to_be_bytes().to_vec()
}
} here we have two structs collection and item. {
"id": 2,
"items": [{
"id": 2,
"name": ["Item 2"]
}]
} so how should I serialise this json data from the request just by knowing the name of the table. Is there by which I can create the struct instance from the name of the struct. |
@elliot14A Unfortunately, the approach you're trying to take with If you want to establish a relationship between #[derive(Serialize, Deserialize, Debug, Clone)]
#[struct_db::struct_db(fn_primary_key(p_key))]
struct Collection {
id: i32,
item_ids: Vec<i32>,
} This will allow you to create a relationship between As a tip, you can use the fn struct_db_schema() -> struct_db::Schema function to retrieve the schema. This may provide some of the information you need. If you run into any issues, feel free to open a PR and I'll be glad to assist. |
Similar to
SurrealDB
andIndraDB
create aHTTP
server. If you need this feature please let me know I'll start working on it.The text was updated successfully, but these errors were encountered: