OpenNebula / one

The open source Cloud & Edge Computing Platform bringing real freedom to your Enterprise Cloud 🚀
http://opennebula.io
Apache License 2.0
1.23k stars 478 forks source link

Accept `context.Context` in XML-RPC requests made in the Go client #5688

Open peterwillis opened 2 years ago

peterwillis commented 2 years ago

Description Go client accepts a context and uses it when executing any XML-RPC request.

Use case It is important when using Go to consider context when performing actions. This allows for timeouts and other reasons for cancellations to be controlled by the user of the client. A good example is if the connection to the open nebula api is not temporarily unavailable. In the current implementation a request will just hang. I need this to make code that uses the open nebula api more reliable.

Interface Changes The Go client will have an additional set of methods in the same way that database/sql does in the standard library. This completely preserves backward compatibility.

Progress Status

treywelsh commented 2 years ago

Nice change :)

I worked on this change a year ago but I didn't complete it, it was implemented in the exact same way for retro compatibility so I agree with your implementation (I just shortened XXXContext to XXXCtx for shorter names).

I drop some notes I took here:

There is no big deal with these points and overall Go developers use context, I think it's a good change for Goca.