Hey there I was wondering of using Zig as my main programming language. So I was trying to link Zig with my main database service which was edgedb. But me being a total noob could not find a way too seamlessly connect it without using the edgedb http extension. So I needed help on creating a 100% native driver for it on Zig and I thought this was this was the place to do so, I am going to create a public repo on github and I could use some help.
If you don’t want to use the HTTP interface, you need to talk the binary protocol. It is documented and, if the documentation is not perfectly clear, there are several existing libraries in various languages, so you can get information and inspiration from them. (My first impression of this binary protocol is that developing a Zig library to use it is not a one-weekend project.)
Just my personal programming experience…
Any application level communication protocol consists of
- message exchange pattern (request-reply as a very common example)
- data formats
So it is very natural to separate these two independent aspects.
But look at all these numerous libraries - every libpq
, libhiredis
and so on include both i/o logic (including connect) and data manipulation/transforms. And I do think it’s not always good (well, it might be good for some one-shot scripts, but it usually not good for 24x7 running services).
What I usually do… no matter with what (redis server via tcp or some device connected to serial port) my program has to communicate with:
- implement some library (plugin) that only knows how to
- form requests
- interpret replies
- possibly buffers (realloc and whatsnot) handling
- all i/o logic (including connections/handshakes) is outside of that library and is governed by an application
dug out my old post on D lang (very nice, btw, but GC sucks) forum:
I can speak to the accuracy of this in terms of the mortgage finance industry as well - almost every piece of code I’ve worked on that dealt with establishing connections (single or pooled) ultimately handled when to open/close connections and how they’re formatted. They do all kinds of auditing with those connections.
@dee0xeed Quick funny story… there was an auditing table at one of the companies I’ve contracted for that was collecting user activity since the mid 90’s. Last month, it finally passed the 2,147,483,647
values mark for its identity column and overflowed the integer, breaking the whole system. Funny stuff, but it just goes to show that there is a lot that surrounds connection handling and the backend that formats queries/results ultimately needs to be agnostic about what is done with those connections.
Anyhow, welcome to the forum @cyrilguiz, good to have you. I think the next step here is to post some code for us to chat about. That will help move this conversation from theory to something practical
yes, definitely we need 256 bit computers to handle all that zillions of ƒ/¥/₪ etc…
but they will anyway overflow the buffer with string representation of an any given number
I once revamped the (C CGI-based!) backend for a bank that was migrating to a new system “real soon now” and needed tighter security in their legacy. One of the things I did was introduce a MySQL database to store session information. About ten years later (ten years!) I got a call from the bank because the website had stopped working… Mind you, this was the transactional banking website. There was no support contract, but out of friendship with the engineers, I visited. It took me 10 minutes to realize the sessions table in MySQL had never been cleaned up, and had overflown something or somewhere… That was when I learned that, sometimes, the software we write might outlive all of our plans, and even ourselves.
Thanks Andrew