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

Request cancellation



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


      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.


        For Gerrit Dashboard: GOCBC-1063
        # Subject Branch Project Status CR V



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



              Gerrit Reviews

                There are no open Gerrit changes