Add ConfigStore support#34
Conversation
There was a problem hiding this comment.
As much a note to myself as to you, but…
It looks like what this class adds (in addition to some very nice docs) is…
- Auto buffer sizing (yay)
- A
close()method
Otherwise, the API looks parallel to what we'd get from the generated class, which would be…
from wit_world.imports.config_store import Store
with Store.open("someConfig") as config:
print(config.get("someKey"), 1024) # and hope for the best bufferwiseSee you in a few minutes! Oh, also, I'd prefer to subsume open() into __init__() so you can just ConfigStore("someStore").
The buffer len arguments are there for the benefit of the component adapter, which has to work with fixed-sized buffers passed in by the user code through the witx ABI. For code using WIT bindings directly, it's ok to just let the host call back into the guest with |
Mirroring the JS SDK, we provide a simple get() interface. I opted to not trying to provide a dict facade or similar. That is possible but it doesn't seem to represent a significant ergonomic improvement and might make it more likely that user's fail to keep in mind the potential exception behavior. As with the Rust SDK, we intelligently use hint information from the host to get values with a big enough buffer if our original size is insufficient.
5bb9633 to
e188cba
Compare
Also, use larger buffer size rather than doing unecessary resizes and address a few other comments from the PR.
e188cba to
e803f69
Compare
|
I rebased these changes on the latest upstream; comments that are related can be found on the logging PR related to introduction of an inheritance hierarchy and The exceptions that are generated now are buried fairly deep which could be a bit challenging for users to work with. We max need to fix some stuff later on but I tried to document each of those potential exceptions explicitly so end-users know where they may need to dig to import appropriate exceptions. |
I wrote up a proposal on that: #41. |
erikrose
left a comment
There was a problem hiding this comment.
Looks good! Let's get it in.
Mirroring the JS SDK, we provide a simple get() interface. I opted to not trying to provide a dict facade or similar. That is possible but it doesn't seem to represent a significant ergonomic improvement and might make it more likely that user's fail to keep in mind the potential exception behavior.
As with the Rust SDK, we intelligently use hint information from the host to get values with a big enough buffer if our original size is insufficient.
Potential discussion points:
I expect to rework this code when the unified exception mapping is present, but feel there is enough here to review the important bits.