{"action":"created","comment":{"url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/comments/90437931","pull_request_review_id":10955637,"id":90437931,"diff_hunk":"@@ -0,0 +1,64 @@\n+import time\n+import logging\n+\n+import rethinkdb as r\n+\n+import bigchaindb\n+from bigchaindb.backend.connection import Connection\n+\n+logger = logging.getLogger(__name__)\n+\n+\n+class RethinkDBConnection(Connection):\n+    \"\"\"This class is a proxy to run queries against the database,\n+    it is:\n+    - lazy, since it creates a connection only when needed\n+    - resilient, because before raising exceptions it tries\n+      more times to run the query or open a connection.\n+    \"\"\"\n+\n+    def __init__(self, host=None, port=None, db=None, max_tries=3):\n+        \"\"\"Create a new Connection instance.\n+\n+        Args:\n+            host (str, optional): the host to connect to.\n+            port (int, optional): the port to connect to.\n+            db (str, optional): the database to use.\n+            max_tries (int, optional): how many tries before giving up.\n+        \"\"\"\n+\n+        self.host = host or bigchaindb.config['database']['host']\n+        self.port = port or bigchaindb.config['database']['port']\n+        self.db = db or bigchaindb.config['database']['name']","path":"bigchaindb/backend/rethinkdb/connection.py","position":32,"original_position":32,"commit_id":"f096290147b58001e126b2e6025b2a0259eddb13","original_commit_id":"9f9378f42f5b7519444318538a343f152e875069","user":{"login":"sohkai","id":4166642,"avatar_url":"https://avatars.githubusercontent.com/u/4166642?v=3","gravatar_id":"","url":"https://api.github.com/users/sohkai","html_url":"https://github.com/sohkai","followers_url":"https://api.github.com/users/sohkai/followers","following_url":"https://api.github.com/users/sohkai/following{/other_user}","gists_url":"https://api.github.com/users/sohkai/gists{/gist_id}","starred_url":"https://api.github.com/users/sohkai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sohkai/subscriptions","organizations_url":"https://api.github.com/users/sohkai/orgs","repos_url":"https://api.github.com/users/sohkai/repos","events_url":"https://api.github.com/users/sohkai/events{/privacy}","received_events_url":"https://api.github.com/users/sohkai/received_events","type":"User","site_admin":false},"body":"We can do this later, but I would avoid making a Connection class depend on the BDB config.","created_at":"2016-12-01T12:34:35Z","updated_at":"2016-12-01T12:34:35Z","html_url":"https://github.com/bigchaindb/bigchaindb/pull/886#discussion_r90437931","pull_request_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886","_links":{"self":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/comments/90437931"},"html":{"href":"https://github.com/bigchaindb/bigchaindb/pull/886#discussion_r90437931"},"pull_request":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886"}}},"pull_request":{"url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886","id":95691038,"html_url":"https://github.com/bigchaindb/bigchaindb/pull/886","diff_url":"https://github.com/bigchaindb/bigchaindb/pull/886.diff","patch_url":"https://github.com/bigchaindb/bigchaindb/pull/886.patch","issue_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/886","number":886,"state":"open","locked":false,"title":"Abstract DataBase connection","user":{"login":"vrde","id":134680,"avatar_url":"https://avatars.githubusercontent.com/u/134680?v=3","gravatar_id":"","url":"https://api.github.com/users/vrde","html_url":"https://github.com/vrde","followers_url":"https://api.github.com/users/vrde/followers","following_url":"https://api.github.com/users/vrde/following{/other_user}","gists_url":"https://api.github.com/users/vrde/gists{/gist_id}","starred_url":"https://api.github.com/users/vrde/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vrde/subscriptions","organizations_url":"https://api.github.com/users/vrde/orgs","repos_url":"https://api.github.com/users/vrde/repos","events_url":"https://api.github.com/users/vrde/events{/privacy}","received_events_url":"https://api.github.com/users/vrde/received_events","type":"User","site_admin":false},"body":"Load a specific connection class based on the configuration of the node.\r\n\r\nI've changed also all the calls in the main `core.py::Bigchain` class. I've simplified the signature of the `__init__` by removing all the config params for the DB, such as `host`, `port`, `dbname` and replaced them with `connection`.","created_at":"2016-11-29T13:22:45Z","updated_at":"2016-12-01T12:34:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41dae34f794a3b5a4ccd8f8ee07a0128bb635328","assignee":{"login":"sbellem","id":125458,"avatar_url":"https://avatars.githubusercontent.com/u/125458?v=3","gravatar_id":"","url":"https://api.github.com/users/sbellem","html_url":"https://github.com/sbellem","followers_url":"https://api.github.com/users/sbellem/followers","following_url":"https://api.github.com/users/sbellem/following{/other_user}","gists_url":"https://api.github.com/users/sbellem/gists{/gist_id}","starred_url":"https://api.github.com/users/sbellem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbellem/subscriptions","organizations_url":"https://api.github.com/users/sbellem/orgs","repos_url":"https://api.github.com/users/sbellem/repos","events_url":"https://api.github.com/users/sbellem/events{/privacy}","received_events_url":"https://api.github.com/users/sbellem/received_events","type":"User","site_admin":false},"assignees":[{"login":"sbellem","id":125458,"avatar_url":"https://avatars.githubusercontent.com/u/125458?v=3","gravatar_id":"","url":"https://api.github.com/users/sbellem","html_url":"https://github.com/sbellem","followers_url":"https://api.github.com/users/sbellem/followers","following_url":"https://api.github.com/users/sbellem/following{/other_user}","gists_url":"https://api.github.com/users/sbellem/gists{/gist_id}","starred_url":"https://api.github.com/users/sbellem/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbellem/subscriptions","organizations_url":"https://api.github.com/users/sbellem/orgs","repos_url":"https://api.github.com/users/sbellem/repos","events_url":"https://api.github.com/users/sbellem/events{/privacy}","received_events_url":"https://api.github.com/users/sbellem/received_events","type":"User","site_admin":false},{"login":"sohkai","id":4166642,"avatar_url":"https://avatars.githubusercontent.com/u/4166642?v=3","gravatar_id":"","url":"https://api.github.com/users/sohkai","html_url":"https://github.com/sohkai","followers_url":"https://api.github.com/users/sohkai/followers","following_url":"https://api.github.com/users/sohkai/following{/other_user}","gists_url":"https://api.github.com/users/sohkai/gists{/gist_id}","starred_url":"https://api.github.com/users/sohkai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sohkai/subscriptions","organizations_url":"https://api.github.com/users/sohkai/orgs","repos_url":"https://api.github.com/users/sohkai/repos","events_url":"https://api.github.com/users/sohkai/events{/privacy}","received_events_url":"https://api.github.com/users/sohkai/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886/commits","review_comments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886/comments","review_comment_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/886/comments","statuses_url":"https://api.github.com/repos/bigchaindb/bigchaindb/statuses/f096290147b58001e126b2e6025b2a0259eddb13","head":{"label":"bigchaindb:abstract-db-layer-connection","ref":"abstract-db-layer-connection","sha":"f096290147b58001e126b2e6025b2a0259eddb13","user":{"login":"bigchaindb","id":17097586,"avatar_url":"https://avatars.githubusercontent.com/u/17097586?v=3","gravatar_id":"","url":"https://api.github.com/users/bigchaindb","html_url":"https://github.com/bigchaindb","followers_url":"https://api.github.com/users/bigchaindb/followers","following_url":"https://api.github.com/users/bigchaindb/following{/other_user}","gists_url":"https://api.github.com/users/bigchaindb/gists{/gist_id}","starred_url":"https://api.github.com/users/bigchaindb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigchaindb/subscriptions","organizations_url":"https://api.github.com/users/bigchaindb/orgs","repos_url":"https://api.github.com/users/bigchaindb/repos","events_url":"https://api.github.com/users/bigchaindb/events{/privacy}","received_events_url":"https://api.github.com/users/bigchaindb/received_events","type":"Organization","site_admin":false},"repo":{"id":51290852,"name":"bigchaindb","full_name":"bigchaindb/bigchaindb","owner":{"login":"bigchaindb","id":17097586,"avatar_url":"https://avatars.githubusercontent.com/u/17097586?v=3","gravatar_id":"","url":"https://api.github.com/users/bigchaindb","html_url":"https://github.com/bigchaindb","followers_url":"https://api.github.com/users/bigchaindb/followers","following_url":"https://api.github.com/users/bigchaindb/following{/other_user}","gists_url":"https://api.github.com/users/bigchaindb/gists{/gist_id}","starred_url":"https://api.github.com/users/bigchaindb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigchaindb/subscriptions","organizations_url":"https://api.github.com/users/bigchaindb/orgs","repos_url":"https://api.github.com/users/bigchaindb/repos","events_url":"https://api.github.com/users/bigchaindb/events{/privacy}","received_events_url":"https://api.github.com/users/bigchaindb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bigchaindb/bigchaindb","description":"BigchainDB is a scalable blockchain database","fork":false,"url":"https://api.github.com/repos/bigchaindb/bigchaindb","forks_url":"https://api.github.com/repos/bigchaindb/bigchaindb/forks","keys_url":"https://api.github.com/repos/bigchaindb/bigchaindb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bigchaindb/bigchaindb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bigchaindb/bigchaindb/teams","hooks_url":"https://api.github.com/repos/bigchaindb/bigchaindb/hooks","issue_events_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/events{/number}","events_url":"https://api.github.com/repos/bigchaindb/bigchaindb/events","assignees_url":"https://api.github.com/repos/bigchaindb/bigchaindb/assignees{/user}","branches_url":"https://api.github.com/repos/bigchaindb/bigchaindb/branches{/branch}","tags_url":"https://api.github.com/repos/bigchaindb/bigchaindb/tags","blobs_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/refs{/sha}","trees_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bigchaindb/bigchaindb/statuses/{sha}","languages_url":"https://api.github.com/repos/bigchaindb/bigchaindb/languages","stargazers_url":"https://api.github.com/repos/bigchaindb/bigchaindb/stargazers","contributors_url":"https://api.github.com/repos/bigchaindb/bigchaindb/contributors","subscribers_url":"https://api.github.com/repos/bigchaindb/bigchaindb/subscribers","subscription_url":"https://api.github.com/repos/bigchaindb/bigchaindb/subscription","commits_url":"https://api.github.com/repos/bigchaindb/bigchaindb/commits{/sha}","git_commits_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/commits{/sha}","comments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/comments{/number}","issue_comment_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/comments{/number}","contents_url":"https://api.github.com/repos/bigchaindb/bigchaindb/contents/{+path}","compare_url":"https://api.github.com/repos/bigchaindb/bigchaindb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bigchaindb/bigchaindb/merges","archive_url":"https://api.github.com/repos/bigchaindb/bigchaindb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bigchaindb/bigchaindb/downloads","issues_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues{/number}","pulls_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls{/number}","milestones_url":"https://api.github.com/repos/bigchaindb/bigchaindb/milestones{/number}","notifications_url":"https://api.github.com/repos/bigchaindb/bigchaindb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bigchaindb/bigchaindb/labels{/name}","releases_url":"https://api.github.com/repos/bigchaindb/bigchaindb/releases{/id}","deployments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/deployments","created_at":"2016-02-08T10:12:58Z","updated_at":"2016-11-30T15:09:23Z","pushed_at":"2016-12-01T09:23:40Z","git_url":"git://github.com/bigchaindb/bigchaindb.git","ssh_url":"git@github.com:bigchaindb/bigchaindb.git","clone_url":"https://github.com/bigchaindb/bigchaindb.git","svn_url":"https://github.com/bigchaindb/bigchaindb","homepage":"https://www.bigchaindb.com/","size":6289,"stargazers_count":824,"watchers_count":824,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":161,"mirror_url":null,"open_issues_count":181,"forks":161,"open_issues":181,"watchers":824,"default_branch":"master"}},"base":{"label":"bigchaindb:abstract-db-layer","ref":"abstract-db-layer","sha":"8b5909c94eb2d2c1afe25dfd304fce8d941de1aa","user":{"login":"bigchaindb","id":17097586,"avatar_url":"https://avatars.githubusercontent.com/u/17097586?v=3","gravatar_id":"","url":"https://api.github.com/users/bigchaindb","html_url":"https://github.com/bigchaindb","followers_url":"https://api.github.com/users/bigchaindb/followers","following_url":"https://api.github.com/users/bigchaindb/following{/other_user}","gists_url":"https://api.github.com/users/bigchaindb/gists{/gist_id}","starred_url":"https://api.github.com/users/bigchaindb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigchaindb/subscriptions","organizations_url":"https://api.github.com/users/bigchaindb/orgs","repos_url":"https://api.github.com/users/bigchaindb/repos","events_url":"https://api.github.com/users/bigchaindb/events{/privacy}","received_events_url":"https://api.github.com/users/bigchaindb/received_events","type":"Organization","site_admin":false},"repo":{"id":51290852,"name":"bigchaindb","full_name":"bigchaindb/bigchaindb","owner":{"login":"bigchaindb","id":17097586,"avatar_url":"https://avatars.githubusercontent.com/u/17097586?v=3","gravatar_id":"","url":"https://api.github.com/users/bigchaindb","html_url":"https://github.com/bigchaindb","followers_url":"https://api.github.com/users/bigchaindb/followers","following_url":"https://api.github.com/users/bigchaindb/following{/other_user}","gists_url":"https://api.github.com/users/bigchaindb/gists{/gist_id}","starred_url":"https://api.github.com/users/bigchaindb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bigchaindb/subscriptions","organizations_url":"https://api.github.com/users/bigchaindb/orgs","repos_url":"https://api.github.com/users/bigchaindb/repos","events_url":"https://api.github.com/users/bigchaindb/events{/privacy}","received_events_url":"https://api.github.com/users/bigchaindb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bigchaindb/bigchaindb","description":"BigchainDB is a scalable blockchain database","fork":false,"url":"https://api.github.com/repos/bigchaindb/bigchaindb","forks_url":"https://api.github.com/repos/bigchaindb/bigchaindb/forks","keys_url":"https://api.github.com/repos/bigchaindb/bigchaindb/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bigchaindb/bigchaindb/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bigchaindb/bigchaindb/teams","hooks_url":"https://api.github.com/repos/bigchaindb/bigchaindb/hooks","issue_events_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/events{/number}","events_url":"https://api.github.com/repos/bigchaindb/bigchaindb/events","assignees_url":"https://api.github.com/repos/bigchaindb/bigchaindb/assignees{/user}","branches_url":"https://api.github.com/repos/bigchaindb/bigchaindb/branches{/branch}","tags_url":"https://api.github.com/repos/bigchaindb/bigchaindb/tags","blobs_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/refs{/sha}","trees_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bigchaindb/bigchaindb/statuses/{sha}","languages_url":"https://api.github.com/repos/bigchaindb/bigchaindb/languages","stargazers_url":"https://api.github.com/repos/bigchaindb/bigchaindb/stargazers","contributors_url":"https://api.github.com/repos/bigchaindb/bigchaindb/contributors","subscribers_url":"https://api.github.com/repos/bigchaindb/bigchaindb/subscribers","subscription_url":"https://api.github.com/repos/bigchaindb/bigchaindb/subscription","commits_url":"https://api.github.com/repos/bigchaindb/bigchaindb/commits{/sha}","git_commits_url":"https://api.github.com/repos/bigchaindb/bigchaindb/git/commits{/sha}","comments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/comments{/number}","issue_comment_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/comments{/number}","contents_url":"https://api.github.com/repos/bigchaindb/bigchaindb/contents/{+path}","compare_url":"https://api.github.com/repos/bigchaindb/bigchaindb/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bigchaindb/bigchaindb/merges","archive_url":"https://api.github.com/repos/bigchaindb/bigchaindb/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bigchaindb/bigchaindb/downloads","issues_url":"https://api.github.com/repos/bigchaindb/bigchaindb/issues{/number}","pulls_url":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls{/number}","milestones_url":"https://api.github.com/repos/bigchaindb/bigchaindb/milestones{/number}","notifications_url":"https://api.github.com/repos/bigchaindb/bigchaindb/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bigchaindb/bigchaindb/labels{/name}","releases_url":"https://api.github.com/repos/bigchaindb/bigchaindb/releases{/id}","deployments_url":"https://api.github.com/repos/bigchaindb/bigchaindb/deployments","created_at":"2016-02-08T10:12:58Z","updated_at":"2016-11-30T15:09:23Z","pushed_at":"2016-12-01T09:23:40Z","git_url":"git://github.com/bigchaindb/bigchaindb.git","ssh_url":"git@github.com:bigchaindb/bigchaindb.git","clone_url":"https://github.com/bigchaindb/bigchaindb.git","svn_url":"https://github.com/bigchaindb/bigchaindb","homepage":"https://www.bigchaindb.com/","size":6289,"stargazers_count":824,"watchers_count":824,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":161,"mirror_url":null,"open_issues_count":181,"forks":161,"open_issues":181,"watchers":824,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886"},"html":{"href":"https://github.com/bigchaindb/bigchaindb/pull/886"},"issue":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/886"},"comments":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/issues/886/comments"},"review_comments":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886/comments"},"review_comment":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/pulls/886/commits"},"statuses":{"href":"https://api.github.com/repos/bigchaindb/bigchaindb/statuses/f096290147b58001e126b2e6025b2a0259eddb13"}}}}
{"actor":{"display_login":"sohkai"}}