Uploaded image for project: 'Couchbase Go SDK'
  1. Couchbase Go SDK
  2. GOCBC-1063

Request cancellation

    XMLWordPrintable

Details

    • Improvement
    • Resolution: Fixed
    • Major
    • 2.3.0
    • None
    • None
    • None
    • 1

    Description

      Propagating cancellation is important for well-designed applications to avoid continuing work that will just be discarded by the caller or client. This is of particular importance for requests that cross application boundaries such as database requests.

      The gocb package does not appear to provide any mechanism to cancel requests. For example, if I'm implementing an HTTP handler in my application that makes a query to Couchbase, I need to be able to cancel the request if the client cancels the HTTP request. There are other situations where cancellation is important, but that is probably the most common use-case.

       

      The defacto standard for cancellation in Golang, particularly in the net/http package, is to pass a context.Context as the first argument to any function that performs blocking network requests or long-running work. Please update the gocb API to include methods that accept a context.Context and attach this context to any http requests that are made under the hood.

       

      In order to encourage good application design, and to keep the already large package API from effectively doubling, I recommend altering the existing APIs and cutting a new major version. However introducing alternative functions that accept a context.Context would also be acceptable and then would only require a minor version bump.

      Attachments

        Activity

          People

            charles.dixon Charles Dixon
            adam.levy@couchbase.com Adam Levy
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              PagerDuty