nginx/nginx-plus-go-client

Support cancellation of NGINX Plus API calls

Closed this issue · 4 comments

Is your feature request related to a problem? Please describe.

As a developer, I'd like to be able to cancel any call I make to NGINX Plus API.

This is required for my software for:

  • graceful termination. When that happens, I'd like to be able to quickly terminate any in-progress API calls.
  • configuring a API call timeout. I'd like to control how long I can allow a call to NGINX Plus API to last.

Describe the solution you'd like

Using Context https://pkg.go.dev/context#Context is common for that.

func (client *NginxClient) AddHTTPServer(upstream string, server UpstreamServer) error {

func (client *NginxClient) AddHTTPServer(ctx context.Context, upstream string, server UpstreamServer) error {

Describe alternatives you've considered

There is hard-corded timeout that internally creates a context that ensures that a request to NGINX Plus API can't take longer than 10s.
https://github.com/nginxinc/nginx-plus-go-client/blob/970573b15737ed294b847ff19989bf9d0e6b182c/client/nginx.go#L855

However, I'd like to control cancelation via a context (which can be cancelled before timeout expires). Additionally, I want to control the value of the timeout.

Additional context

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

This issue was closed because it has been stalled for 7 days with no activity.

Added @oliveromahony on Agent team for implementation. Let us know if this is wrong!

@mpstefan my current workload and availability in the next month doesn't allow me to do this as a priority. If someone else can take it on that would be great. I'll sync with the team tomorrow