nginx-plus-go-client icon indicating copy to clipboard operation
nginx-plus-go-client copied to clipboard

Support cancellation of NGINX Plus API calls

Open pleshakov opened this issue 1 year ago • 2 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

pleshakov avatar Jan 18 '24 15:01 pleshakov

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.

github-actions[bot] avatar Mar 19 '24 01:03 github-actions[bot]

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

github-actions[bot] avatar Mar 26 '24 01:03 github-actions[bot]

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

mpstefan avatar Sep 11 '24 16:09 mpstefan

@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

oliveromahony avatar Sep 11 '24 18:09 oliveromahony