Uploaded image for project: 'Couchbase Python Client Library'
  1. Couchbase Python Client Library
  2. PYCBC-695

Reflect all RFC-ordained kwargs in OptionBlocks

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Major
    • 3.0.0-rc
    • None
    • None
    • None
    • 1
    • SDK1: GA and Priority List, SDK9: Coll/Txn/Doc chipping, SDK11: Coll/Txn/Docs More Chip, SDK13: Coll/Txn/Docs More Chip

    Description

      Ideally, a developer would not have to remember what the various options are for a given operation, and they would all be represented explicitly in the Options objects themselves.  

      For instance, in Java, the GetOptions has an explicit withExpiry, project, and is derived from a CommonOptions object which contains timeout, retryStrategy, etc...  So - when developing in java, this is all discoverable (unless you use Vi like I sometimes do), and is a great help.  

      In Python, GetOptions has an explicit timeout and project, and derives from OptionBlock.  But OptionBlock has no common options, it is just a dict.  Ideally, we'd pop some common ones (like timeout, retryStrategy) in there, and if OptionBlock does not extend a dict then if you use a clever IDE it will show all the options and none of the dict methods. 

      So - for sure we seem to need some things added (I just looked at GetOptions but we should sweep through all of them).  For GetOptions, we need to support returning expiry, and specifying a retryStrategy, and perhaps other things but for sure that.  Some of this may be handled by the explicit named parameters call to get, but it isn't part of the GetOptions explicitly.  My concern above was just to make using it easier, by getting away from an underlying dict.  That is of course worth debate. 

      A second thought/issue:
      I'd expect the kv interface to work something like this:

      opt = GetOptions().timeout(Seconds(3)) # we reuse this throughout the code perhaps
      ...
      collection.get('key', opt, expiry=True) #use the GetOptions passed in, but add in the expiry (just for this call) 

       

      Now, calling it with the key and options does work, but I think the idea of the Options is that you'd reuse it, and sometimes tweak that slightly by adding something for specific calls (say, adding a cas() sometimes when mutating, or bumping a timeout or retry strategy, etc...).  Right now, if I do this:

      collection.get('key', opt, project=['someField']
      

       

      I end up seeing an exception 

      couchbase_core.exceptions.ArgumentError: <Bad/insufficient arguments provided, inner_cause='ttl' is an invalid keyword argument for this function, C Source=(src/get.c,459)>
      

       

      So perhaps we don't quite handle this case yet...  Worth some discussion.

      Attachments

        1. image-2020-01-07-19-03-37-953.png
          image-2020-01-07-19-03-37-953.png
          16 kB
        2. image-2020-01-07-19-26-59-606.png
          image-2020-01-07-19-26-59-606.png
          26 kB
        3. image-2020-01-07-19-27-15-749.png
          image-2020-01-07-19-27-15-749.png
          74 kB
        4. screenshot-1.png
          screenshot-1.png
          46 kB
        5. screenshot-2.png
          screenshot-2.png
          44 kB
        6. screenshot-3.png
          screenshot-3.png
          30 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            Ellis.Breen Ellis Breen
            david.kelly David Kelly (Inactive)
            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