Closed panosfol closed 4 months ago
Write now in order to implement a new database system, we need to follow these steps: For the config:
- Create a new struct that holds all the necessary info to connect to the database, and place it in |config.h|
- Add a new field to struct |config_t| located in |config.h| for the newly created struct
- Allocate memory for the new struct inside |initialize_config| in |config.c|
This can be fixed.
- Add to the |ini_parse| in |config.c| all the necessary checks to populate the fields of the struct For the database operations:
Not sure about this, theoretically we can automate this but not sure how at this moment.
- Add a field to the |db_t| struct in |db.h| that holds a pointer to the struct created in |config.h|
We can make "typedef struct postgres_t" a generic "typedef struct db_fields" since most database will be OK with it.
- Implement the |connect|, |replicate|, |close| functions for the new database system
- Make sure all the allocated memory is freed
These two are very custom and I prefer to leave them as they are. We want users to freely implement their own replication logic, apart from the usual one.
I was thinking maybe if there was a way to automate some of these steps through a script? (I've seen a script for "code injection" using Ruby).
No.
Im not sure if thats applicable on our case but there is a lot of stuff given the struct name and the fields from config, that we can actually automate for multiple database systems. I'm pretty sure all SQL databases will have the same fields for the struct, and maybe many of the NoSQL databases too, we can even automate that.
Write now in order to implement a new database system, we need to follow these steps: For the config: Create a new struct that holds all the necessary info to connect to the database, and place it in |config.h| Add a new field to struct |config_t| located in |config.h| for the newly created struct Allocate memory for the new struct inside |initialize_config| in |config.c| This can* be fixed.
- Add to the |ini_parse| in |config.c| all the necessary checks to populate the fields of the struct For the database operations: Not sure about this, theoretically we can automate this but not sure how at this moment.
- Add a field to the |db_t| struct in |db.h| that holds a pointer to the struct created in |config.h| We can make "typedef struct postgres_t" a generic "typedef struct db_fields" since most database will be OK with it.
- Implement the |connect|, |replicate|, |close| functions for the new database system * Make sure all the allocated memory is freed These two are very custom and I prefer to leave them as they are. We want users to freely implement their own replication logic, apart from the usual one. I was thinking maybe if there was a way to automate some of these steps through a script? (I've seen a script for "code injection" using Ruby). No. … Im not sure if thats applicable on our case but there is a lot of stuff given the struct name and the fields from config, that we can actually automate for multiple database systems. I'm pretty sure all SQL databases will have the same fields for the struct, and maybe many of the NoSQL databases too, we can even automate that.
I wasnt looking to automate all of these, some will stay the way they are. But we can simplify some of them.
Can we close this also? @panosfol
Yes all the major issues has been addressed.
Write now in order to implement a new database system, we need to follow these steps:
For the config:
config.h
config_t
located inconfig.h
for the newly created structinitialize_config
inconfig.c
ini_parse
inconfig.c
all the necessary checks to populate the fields of the structFor the database operations:
db_t
struct indb.h
that holds a pointer to the struct created inconfig.h
connect
,replicate
,close
functions for the new database systemI was thinking maybe if there was a way to automate some of these steps through a script? (I've seen a script for "code injection" using Ruby). Im not sure if thats applicable on our case but there is a lot of stuff given the struct name and the fields from config, that we can actually automate for multiple database systems. I'm pretty sure all SQL databases will have the same fields for the struct, and maybe many of the NoSQL databases too, we can even automate that.