Skip to content

Allow cancellation of topic map go routine #60

Open
@alexellis

Description

Allow cancellation of topic map go routine

Expected Behaviour

Once the topic map is being built in its own go routine, there should be some way to cancel / pause that work.

Why? Perhaps it needs to back-off for some reason, or the broker isn't available. Perhaps it should pause and restart at a later time.

Current Behaviour

Once started, there is no way to stop the topic map from being rebuilt.

Possible Solution

Introduce a Context or cancellation channel to the SDK.

The map is rebuilt in this go routine using a timer:

https://github.com/openfaas/connector-sdk/blob/master/types/controller.go#L141

Then each result is published to the subscribers via this Go routine:

https://github.com/openfaas/connector-sdk/blob/master/types/controller.go#L102

Steps to Reproduce (for bugs)

  1. Setup the controller
  2. Observe that it's building a map from the gateway
  3. Call cancel with the new API
  4. See that it stops building the map

Context

It's a best practice for Go APIs to provide cancellation.

Users have requested this in the past.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions