overag3 / gonexus

Go API for provisioning and interacting with Sonatype's Nexus Repository Manager and Nexus IQ Server
Other
1 stars 1 forks source link

add context to public functions #4

Open chrboe opened 10 months ago

chrboe commented 10 months ago

Almost all public functions of this library make one or more HTTP requests behind the scenes. Since this is an operation that can potentially block indefinitely, it is good practice to pass a context into these functions. That way, the operation can be cancelled "from above" if necessary.

Add ...Context() variants of all public functions that end up making HTTP requests. Maintain external API compatibility by keeping the old functions as wrappers, calling the new ...Context() functions with context.Background().

An exception to this is the Client interface in nexus.go and its implementation. There, the context parameter is added directly. This is technically a breaking change, but I suspect not many people will be using this low-level interface anyway.