9/ The other is synchronous, which is not acceptable. This code needs to boogie. So I used pthreads to MAKE IT asynchronous: we call into my wrapper, my wrapper spawns a new thread, and then returns immediately. (New thread does DB call then write state bit in linked list).
-
Show this thread
-
10/ The asynchronous one - no such magic needed. So easier, right? WRONG ! First off, C API is undocumented "for expert use only". Vendors employees use it to write APIs in other languages. Not for normies!
1 reply 0 retweets 3 likesShow this thread -
11/ First problem I run into is that I inject stuff into it, API says "we good", but then ... we not. Turns out that if, in the callback, I check the status code AGAIN, only then do I learn "input too wide". So now I have to build a fragmenting / sharding layer!
1 reply 1 retweet 2 likesShow this thread -
12/ This is not my first goat rodeo, so I do that in a day or so. But then, since I'm checking the status code in the callback, I learn that "we probably wrote it, but we can't be ABSOLUTELY sure" is also a status code. ...so now I have to add a retry loop in. >>>
1 reply 0 retweets 3 likesShow this thread -
13/ And note that this retry loop is INSIDE the callback. So stack looks like * application * libuv_run_loop * ... * my libuv callback, which injects into DB * ... * ... * db callback (uncertain status code) * inject into DB * ... * ... * db callback * inject into DB * ...
1 reply 0 retweets 2 likesShow this thread -
14/ The angles do not add up to 360°, and the walls seem to breathe. Is that a tentacle?
1 reply 0 retweets 6 likesShow this thread -
15/ also, since I might have to reinject into the db, I need to carry along a data structure of all the info that I might need to inject, which means rearchitecting things. Then I have to clean it up at the end!
1 reply 0 retweets 2 likesShow this thread -
16/ Also, bc I'm doing sharding, I can no longer do a simple cleanup of the original data - shard 0 might write to db OK, but shard 3 might take 4 retries, so cleanup is VERY TRICKY.
2 replies 0 retweets 2 likesShow this thread -
17/ Also, some cleanup can't be done automatically. Sometimes we do a DB query, and get a char * to data ... but that lives inside a short lived handle, so we can't clean up the handle ourselves. Have to hide it behind a void * and give it back to app, which can call cleanup
1 reply 0 retweets 2 likesShow this thread -
18/ But note that I am not bitching - this is actually the most fun I've had coding in 2-3 years! onward!
1 reply 0 retweets 5 likesShow this thread
19/ tangentially, sometimes I wonder "am I really bringing that much value?" when I'm changing the background color of a webpage. ...because any 14 year old fresh out of a coding bootcamp could do this. ...but when I'm spinning up threads, working state machines, etc: yeah
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.