diff --git a/CHANGELOG.md b/CHANGELOG.md index b120815..390f51a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.1.7 (2017-02-13) + +Fix: + + - Sphinx Documentation + ## 0.1.6 (2017-02-10) Fix: diff --git a/README.rst b/README.rst index 445e460..b427f7c 100644 --- a/README.rst +++ b/README.rst @@ -27,13 +27,13 @@ Riak KV operations Yes Riak Datatypes Yes Riak BucketTypes Yes Custom resolver Yes -Node list support No +Node list support WIP Custom quorum No Connections Pool No Operations timeout No Security No -Riak Search No -MapReduce No +Riak Search WIP +MapReduce WIP Tested python versions `3.5, 3.6 `__ Tested Riak versions `2.1.3, 2.1.4 `__ ================================ ============================== diff --git a/aioriak/bucket.py b/aioriak/bucket.py index 0312e1a..428e258 100644 --- a/aioriak/bucket.py +++ b/aioriak/bucket.py @@ -193,9 +193,10 @@ async def new(self, key=None, data=None, content_type='application/json', A shortcut for manually instantiating a new :class:`~aioriak.riak_object.RiakObject` or a new :class:`~aioriak.datatypes.Datatype`, based on the presence and value - of the :attr:`datatype ` bucket property. When - the bucket contains a :class:`~aioriak.datatypes.Datatype`, all - arguments are ignored except ``key``, otherwise they are used to + of the :attr:`datatype ` bucket + property. When the bucket contains a + :class:`~aioriak.datatypes.Datatype`, all arguments are ignored except + ``key``, otherwise they are used to initialize the :class:`~aioriak.riak_object.RiakObject`. :param key: Name of the key. Leaving this to be None (default) @@ -235,7 +236,7 @@ async def delete(self, key, **kwargs): ''' Deletes a key from Riak. Short hand for ``bucket.new(key).delete()``. See :meth:`RiakClient.delete() - ` for options. + ` for options. :param key: The key for the object :type key: string @@ -270,7 +271,7 @@ class BucketType: properties on a Riak bucket type and access buckets within its namespace. - Async implementation of :class:`riak.bucket.BucketType` + Async implementation of riak.bucket.BucketType ''' def __init__(self, client, name): ''' diff --git a/aioriak/client.py b/aioriak/client.py index 22f8d17..1fcb4f3 100644 --- a/aioriak/client.py +++ b/aioriak/client.py @@ -4,7 +4,7 @@ from weakref import WeakValueDictionary from .transport import create_transport from .bucket import BucketType, Bucket -from riak.resolver import default_resolver +from aioriak.resolver import default_resolver from riak.util import bytes_to_str, str_to_bytes from aioriak.datatypes import TYPES @@ -134,7 +134,8 @@ def _set_resolver(self, value): resolver = property(_get_resolver, _set_resolver, doc='''The sibling-resolution function for this client. - Defaults to :func:`riak.resolver.default_resolver`.''') + Defaults to :func:`aioriak.resolver.default_resolver`. + ''') def close(self): if not self._closed: diff --git a/aioriak/datatypes/counter.py b/aioriak/datatypes/counter.py index b3a18c8..c8182f8 100644 --- a/aioriak/datatypes/counter.py +++ b/aioriak/datatypes/counter.py @@ -6,7 +6,7 @@ class Counter(Datatype): ''' A convergent datatype that represents a counter which can be incremented or decremented. This type can stand on its own or be - embedded within a :class:`~riak.datatypes.Map`. + embedded within a :class:`~aioriak.datatypes.Map`. ''' type_name = 'counter' diff --git a/aioriak/resolver.py b/aioriak/resolver.py new file mode 100644 index 0000000..b0b2d06 --- /dev/null +++ b/aioriak/resolver.py @@ -0,0 +1,40 @@ +# Copyright 2010-present Basho Technologies, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +def default_resolver(riak_object): + """ + The default conflict-resolution function, which does nothing. To + implement a resolver, define a function that sets the + :attr:`siblings ` property + on the passed :class:`RiakObject ` + instance to a list containing a single :class:`RiakContent + ` object. + + :param riak_object: an object-in-conflict that will be resolved + :type riak_object: :class:`RiakObject ` + """ + pass + + +def last_written_resolver(riak_object): + """ + A conflict-resolution function that resolves by selecting the most + recently-modified sibling by timestamp. + + :param riak_object: an object-in-conflict that will be resolved + :type riak_object: :class:`RiakObject ` + """ + riak_object.siblings = [max(riak_object.siblings, + key=lambda x: x.last_modified), ] diff --git a/docs/bucket.rst b/docs/bucket.rst index 9ecaffb..d63604f 100644 --- a/docs/bucket.rst +++ b/docs/bucket.rst @@ -30,10 +30,10 @@ If Bucket Types are not specified, the *default* bucket type is used. These buckets should be created via the :meth:`bucket() ` method on the client object, like so:: - import riak + import aioriak async def go(): - client = await riak.RiakClient.create() + client = await aioriak.RiakClient.create() mybucket = client.bucket('mybucket') Buckets with a user-specified Bucket Type can also be created via the same diff --git a/docs/datatypes.rst b/docs/datatypes.rst index 25166a2..904efd4 100644 --- a/docs/datatypes.rst +++ b/docs/datatypes.rst @@ -37,7 +37,7 @@ All Data Types must be stored in buckets bearing a the ``allow_mult`` property set to ``true``. These Data Types are stored just like :class:`RiakObjects -`, so size constraints that apply to +`, so size constraints that apply to normal Riak values apply to Riak Data Types too. An in-depth discussion of Data Types, also known as CRDTs, diff --git a/docs/index.rst b/docs/index.rst index 49998c7..54b67c9 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -18,15 +18,15 @@ Riak KV operations Yes Riak Datatypes Yes Riak BucketTypes Yes Custom resolver Yes -Node list support No +Node list support WIP Custom quorum No Connections Pool No Operations timout No Security No -Riak Search No -MapReduce No -Tested python versions `3.5.0, 3.5.1 `_ -Tested Riak versions `2.1.3 `_ +Riak Search WIP +MapReduce WIP +Tested python versions `3.5, 3.6 `__ +Tested Riak versions `2.1.3, 2.1.4 `__ ================================ ============================== Installation @@ -40,7 +40,7 @@ Requirements ------------ - Python >= 3.5 -- riak>=2.1.3 +- riak==2.7.0 Contribute ---------- diff --git a/docs/object.rst b/docs/object.rst index c5a72dd..bb80858 100644 --- a/docs/object.rst +++ b/docs/object.rst @@ -6,8 +6,8 @@ Values & Objects Keys in Riak are namespaced into :class:`buckets `, and their associated values are represented -by :class:`objects `, not to be confused with Python -"objects". A :class:`RiakObject` is a container for the key, the +by :class:`objects `, not to be confused with Python +"objects". A :class:`aioriak.riak_object.RiakObject` is a container for the key, the :ref:`vclock`, the value(s) and any metadata associated with the value(s). @@ -121,11 +121,11 @@ written again. How you choose to resolve the conflict is up to you, but you can automate the process using a :attr:`resolver ` function. -.. autofunction:: riak.resolver.default_resolver -.. autofunction:: riak.resolver.last_written_resolver +.. autofunction:: aioriak.resolver.default_resolver +.. autofunction:: aioriak.resolver.last_written_resolver If you do not supply a resolver function, or your resolver leaves multiple siblings present, accessing the :ref:`object_accessors` will -result in a :exc:`ConflictError ` being raised. +result in a :exc:`ConflictError ` being raised. .. autoexception:: aioriak.error.ConflictError diff --git a/setup.py b/setup.py index d825517..9c859c9 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,26 @@ from setuptools import setup, find_packages +import codecs +import os from commands import (docker_build, docker_start, docker_stop, setup_riak, create_bucket_types, Test) + +HERE = os.path.abspath(os.path.dirname(__file__)) + + +def read(*parts): + """ + Build an absolute path from *parts* and and return the contents of the + resulting file. Assume UTF-8 encoding. + """ + with codecs.open(os.path.join(HERE, *parts), "rb", "utf-8") as f: + return f.read() + setup( name='aioriak', - version='0.1.6', + version='0.1.7', description='Async implementation of Riak DB python client', + long_description=read("README.rst"), author='Makc Belousov', author_email='m.belousov@rambler-co.ru', url='https://github.com/rambler-digital-solutions/aioriak',