-
Notifications
You must be signed in to change notification settings - Fork 849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generated interfaces for the various services are not self-complete #14010
Comments
Hi @amshuman-kr thanks for this issue! Indeed now the SDKs in @jhendrixMSFT Could you also provide some insights? For instance, are there some minor features in track 2 that could also be backported to track 1? |
@ArcturusZhang Thanks for the quick response!
Couldn't making the following changes to the generated service API interfaces solve this without breaking compatibility?
Please note that the above changes keep the Something like this will need to be done for all the methods in all the generated service API interfaces and the generated future structs, of course. |
@amshuman-kr well, this solution has some problems. |
Given the current situation, I can't think of any way to avoid this other than changing the
Is anyone currently using the XXXapi interfaces considering that they are not self-complete? Would the alternative of generating a fresh set of self-complete interfaces in the XXX package in a separate interfaces.go file be acceptable? That way the only existing code that would be touched would be the type of the |
I have a few ideas on how to implement this. Here are some prototypes. Change While it's technically a breaking change, I think this is pretty compatible. It would also be the easiest way for callers to mock the future. The downside is that it affects all public surface area that uses long-running operations. Change This is definitely a breaking change as the clients no longer satisfy the API interface (note the commented-out check on line 60) , you have to use the I need to think about this some more and discuss with the team. Please feel free to share your thoughts as well. I'll also point out that for our track 2 SDK we already return interfaces for futures (called pollers in track 2), see https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/arm/compute/2020-09-30/armcompute#VirtualMachinesClient.BeginCreateOrUpdate for an example. |
A variant to the second option would be to generate this as a new set of interfaces side-by-side with the existing ones. |
A colleague suggested another approach which I think is best, and shouldn't be a breaking change unless you're creating your own This changes the This way you can replace the definition of |
Yes, this indeed seems to solve the problem without breaking existing functionality. |
@alexeldeib I know you were interested in this in the past. |
Thanks @jhendrixMSFT, @ArcturusZhang for so quickly addressing this and also making a release! ❤️ |
Bug Report
.../services/XXX/mgmt/*/XXX/XXXapi
master
(and older releases)The API interface abstractions for the various services are not self-complete and cannot be used without using the corresponding concrete implementation structure. For example, the
CreateOrUpdate
function in the interfaceVirtualMachinesClientAPI
returns the structVirtualMachinesCreateOrUpdateFuture
which cannot be used in any meaningful way without calling theGetResult
function which takes the concrete implementation structVirtualMachinesClient
instead of the corresponding interfaceVirtualMachinesClientAPI
. Also, theGetResult
function uses the following two aspects of the concrete implementation structVirtualMachinesClient
which are not part of theVirtualMachinesClientAPI
interface abstraction.VirtualMachinesClient
struct implements theautorest.Sender
which is used in the calls tofuture.DoneWithContext
andautorest.DecorateSender
andfuture.GetResult
.VirtualMachinesClient
supports the methodCreateOrUpdateSender
which is not part of the correspondingVirtualMachinesClientAPI
interface.The generated interfaces for other services (and the methods in them) also seem to have the same problem which prevents them being used consistently without referring to the corresponding concrete implementation. This also makes it difficult to generate and use mock implementation for these interfaces in unit test cases.
What did you expect or want to happen?
The generated API interfaces for the various services are self-consistent and can be used without referring to the corresponding implementation structs except while instantiating the interface implementation.
How can we reproduce it?
N/A
Anything we should know about your environment.
N/A
Also, please let me know if this is the wrong repo to raise this issue and if I should raise it on the repo where the code generation happens (Azure/autorest, perhaps?).
The text was updated successfully, but these errors were encountered: