Contexts on HTTP calls
JulianKnodt opened this issue · 6 comments
I was wondering whether it would be possible to add contexts to any client calls, to make it more idiomatic. It would be easy to implement as a breaking change, as you could just stick a context into the codegen template, but that's definitely painful to old users of the package. I think it also may be a lot of bloat to add a new set of methods for context, but I was wondering what you thought of it.
Short answer: yes, this library really should use contexts, and not just in the SOAP calls.
This is something that I started thinking about doing a while back, and there was some work I did on the v2
branch to do that and other things. For one reason or another, I never completed that work, and since then various fixes and changes have merged into master
.
There's a lot of things I'd do differently in this package if I were to redesign them, but they'd almost all be breaking changes. It would likely be best to do such breaking changes in bulk on a separate v2 package to avoid breaking existing users.
If this package branched out to a v2, it'd be good to know which things need doing, not just contexts. IPv6 is one thing, although I know basically zero about how multicast/UPnP works with IPv6. There's also other breaking API changes I'd likely make, which would probably make substantial differences to how the SOAP APIs are defined.
I need to ponder that a bit, but would be interested in your thoughts and others on that.
Hm, I'm not particularly experienced in releasing packages and maintaining compatibility for older versions.
What I think would be best would probably be having a numbered version as you suggest, and seems to be recommended by the golang team. One thing for a v2 might be to release a non major version, and expect breaking changes such as adding IPv6 or others before reaching a completed v2. I suspect that trying to do everything in bulk would probably take way too long and lead to the package not being completed, as is the case when there is feature creep.
One other approach patching existing clients might be to make it so that a UPnP client could patch in a context for the next call... but that seems really hacky and not ideal. But that's just a random idea.
So hopefully commit 5a0d4bd fixes your current needs. I've made some start on a v2, but as you note it will likely take a while for the limited free time I spend on goupnp. Let me know if this change doesn't work well for you.
I think the actions still need to use the context inside of the http call by attaching it to the request, but it's good as an entry point!
I think the actions still need to use the context inside of the http call by attaching it to the request, but it's good as an entry point!
Ah, that should be in 6145404, which I submitted prior.
ahhhh cool cool then it should be good from my pov!