atoz
atoz copied to clipboard
How to use `atoz` with `--threads:on`
Hi @disruptek
I'm testing the various API's and now I have come to testing the library within a multi threaded universe.
When enabling --threads:on
the compilation fails due to gcsafe
. In atoz
we have many global vars
, but I can manually convert them into proc
's, e.g.:
var headObject* = Call_HeadObject_21626621(name: "headObject", xxxxx
But we are still relying on the rest
-package with the Recallable
, which also blocks the usage of --threads:on
.
All of this can be "avoided" by using a {.gcsafe.}:
-block - but whats the impact? Do you have an answer, or can you point me in a direction?
{.gcsafe.}:
let request = headObject.call(%*{"Bucket": bucket, "Key": key}, query=nil, header=nil, formData=nil, body=nil)
result = await request.issueRequest()
Well, the rest
module is just a hack that is meant to be replaced. I'm a little surprised it's not usable in a threaded context -- that's an oversight. It's supposed to have synchronous versions of all its API. Maybe this issue should move to that repo?
But really, OpenAPI is supposed to be used to help you compose your own API with your own code; it just provides the symbols that you need for that composition without having to do the JSON transform yourself. I guess people can import everything into global scope, but that wasn't my goal with the project. atoz
only exists because consuming the AWS APIs was impossible when the OpenAPI codegen was written -- the Nim compiler would crash due to the complexity of the macro.
I saw that in you README :wink:. Let me check it out a little more, it might be me who is messing around with my use case (Jester, httpbeast, etc.) - the rest
module itself compiles fine with threads.
Oh okay, but it's really nice to have the full AWS API available here in atoz
. Thanks for that!
Any update? If you want, I can move the codegen scripts into the atoz
repo and you can hack at them.
Hi @disruptek
No. I havn't had time to dig into it yet, and don't know when I will have the time to hack the codegen
; sorry.
Currently I have test cases which validates input using atoz
, then for use it uses sigv4
with httpClient
:
let
client = newAsyncHttpClient()
response = await client.request(sigv4SignedUrl(bucket, key, httpMethod=HttpHead), httpMethod=HttpHead)
client.close()
I understand if the issue should be closed based on my vague time estimate and lack of progress on it?
I can't think of a good reason to close the issue; maybe someone else will be able to contribute.