Noah Levitt 8ec2d853b6 connect quickly when a server is down
Another tweak to that end. We have observed that when a rethinkdb server
is offline, an attempt to connect to it takes a second or two to time
out. On the other hand, if the host is up but the port is not open
(rethinkdb is not running or something like that), the connection
failure happens very quickly.

To achieve good performance in case a rethinkdb server is down, we are
now setting a timeout on the connect() call. The timeout starts at
0.1 sec, for quick retry, and backs off up to 10 sec in case of repeated
failures.
2018-11-01 19:17:50 +00:00
2017-05-22 14:28:22 -07:00
2018-10-29 16:58:04 -07:00

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. image:: https://travis-ci.org/internetarchive/doublethink.svg?branch=master
    :target: https://travis-ci.org/internetarchive/doublethink

doublethink
============

RethinkDB python library. Provides connection manager and ORM framework
(object-relational mapping, sometimes called ODM or OM for nosql databases).

Connection Manager
------------------

Three main purposes:

- round-robin connections among database servers
- make sure connections close at proper time
- retry retry-able queries on failure

Not currently a connection pool, because it doesnt keep any connections open.
Should be possible to implement connection pooling without changing the API.
However, testing suggests there would be no appreciable performance gain from
connection pooling.

Usage Example
~~~~~~~~~~~~~

::

    import doublethink
    rr = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')
    rr.table('mytable').insert({'foo':'bar','baz':2}).run()
    for result in rr.table('mytable'):
        print("result={}".format(result))

ORM
---

Simple yet powerful ORM system. *Does not enforce a schema.*

Usage Example
~~~~~~~~~~~~~

::

    import doublethink

    rr = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')

    class MyTable(doublethink.Document):
        pass
    MyTable.table_create(rr)

    doc1 = MyTable(rr, {'animal': 'elephant', 'size': 'large'})
    doc1.save()

    doc1_copy = MyTable.load(rr, doc1.id)
    doc1_copy.food = 'bread'
    doc1_copy.save()

    doc1.first_name = 'Frankworth'
    doc1.save()

    doc1.refresh()

Service Registry
----------------

Now also has a ServiceRegistry class, a lightweight solution for service
discovery for distributed services. Maintains service info and status in
a rethinkdb table called “services”.

Description
WARC writing MITM HTTP/S proxy
Readme 4.5 MiB
Languages
Python 97.1%
Dockerfile 2%
Shell 0.9%