warcprox/README.rst

72 lines
1.8 KiB
ReStructuredText
Raw Permalink Normal View History

2017-03-01 17:37:13 -08:00
.. image:: https://travis-ci.org/internetarchive/doublethink.svg?branch=master
:target: https://travis-ci.org/internetarchive/doublethink
2017-02-23 16:07:14 -08:00
doublethink
============
2017-02-23 16:07:14 -08:00
RethinkDB python library. Provides connection manager and ORM framework
(object-relational mapping, sometimes called ODM or OM for nosql databases).
2017-02-23 16:07:14 -08:00
Connection Manager
------------------
2017-02-23 16:07:14 -08:00
Three main purposes:
2017-02-23 16:07:14 -08:00
- round-robin connections among database servers
- make sure connections close at proper time
- retry retry-able queries on failure
2017-02-23 16:07:14 -08:00
Not currently a connection pool, because it doesnt keep any connections open.
Should be possible to implement connection pooling without changing the API.
2017-05-22 14:28:22 -07:00
However, testing suggests there would be no appreciable performance gain from
connection pooling.
2017-02-23 16:07:14 -08:00
Usage Example
~~~~~~~~~~~~~
2017-02-23 16:07:14 -08:00
::
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'):
2017-02-23 16:07:14 -08:00
print("result={}".format(result))
ORM
---
Simple yet powerful ORM system. *Does not enforce a schema.*
Usage Example
~~~~~~~~~~~~~
::
import doublethink
2017-02-23 16:07:14 -08:00
rr = doublethink.Rethinker(['db0.foo.com', 'db0.foo.com:38015', 'db1.foo.com'], 'my_db')
2017-02-23 16:07:14 -08:00
class MyTable(doublethink.Document):
2017-02-23 16:07:14 -08:00
pass
MyTable.table_create(rr)
2017-02-23 16:07:14 -08:00
doc1 = MyTable(rr, {'animal': 'elephant', 'size': 'large'})
2017-02-23 16:07:14 -08:00
doc1.save()
doc1_copy = MyTable.load(rr, doc1.id)
2017-02-23 16:07:14 -08:00
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”.