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

Request cancellation

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.3.0
    • 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

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          2.3.0 has been moved out so this will be added as uncommitted functionality in 2.2.3

          charles.dixon Charles Dixon added a comment - 2.3.0 has been moved out so this will be added as uncommitted functionality in 2.2.3

          Build sync_gateway-3.0.0-225 contains gocb commit 9ced163 with commit message:
          GOCBC-1063: Add support for context.Context

          build-team Couchbase Build Team added a comment - Build sync_gateway-3.0.0-225 contains gocb commit 9ced163 with commit message: GOCBC-1063 : Add support for context.Context

          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:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty