{"id":6342,"date":"2012-09-05T16:49:17","date_gmt":"2012-09-05T21:49:17","guid":{"rendered":"http:\/\/bobbeaty.com\/wp\/?p=6342"},"modified":"2012-09-06T07:17:18","modified_gmt":"2012-09-06T12:17:18","slug":"im-loving-couchdb-more-by-the-day","status":"publish","type":"post","link":"https:\/\/bobbeaty.com\/wp\/archives\/6342","title":{"rendered":"I&#8217;m Loving CouchDB More by the Day"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/bobbeaty.com\/wp\/wp-content\/uploads\/2012\/08\/CouchDB.png\" alt=\"CouchDB\" title=\"CouchDB.png\" border=\"0\" width=\"130\" height=\"91\" style=\"float:right;\" \/><\/p>\n<p>Today I was really battling a <em>nasty<\/em> problem with the <a href=\"https:\/\/github.com\/couchrest\">CouchRest<\/a> client for <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a>. This is a ruby gem, and in general, it's pretty decent, but it really starts to fall down when you need to use a proxy to get to <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a>, and this guy starts having all kings of problems.<\/p>\n<p>There were timeout issues, so I decided to try and make it work. So I <a href=\"https:\/\/github.com\/drbobbeaty\/couchrest\">forked<\/a> the project on GitHub, and started to get to work. THe major point was that the underlying <a href=\"https:\/\/github.com\/archiloque\/rest-client\">RestClient<\/a> gem had the ability to set things like the timeout for creating the connection as well as timeouts for reading, etc. It's really <em>very<\/em> flexible. My goal was to allow the settings to be applied on a <em>per-database<\/em> basis. Then, for every command, use these as the defaults, but overlay any call-time options as well.<\/p>\n<p>The idea was really nice. I was planning on submitting a pull request for this as it only took me about an hour to do. But when I went to test it, it failed with some 502 Bad Gateway error.<\/p>\n<p>Argh!<\/p>\n<p>More proxy problems!<\/p>\n<p>Then I was talking to one of the guys in the group about this issue and he brought up that I could write to my <em>local<\/em> <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a>, and then <em>replicate<\/em> it to a different database on a different server!<\/p>\n<p>BING!<\/p>\n<p>This is <strong><em>exactly<\/em><\/strong> what I'd been looking for. I get fast and efficient writes to my <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a>, but it gets written up to the shared server as I'm connected to the network. This is <strong>great!<\/strong><\/p>\n<p>The configuration is simple - it's a simple doc in the <tt>_replicator<\/tt> database, and I'm in business. This is really quite amazing. First, go to the overview in the <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a> web page, and select the <tt>_replicator<\/tt> database:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto; border-color:#ababab;\" src=\"https:\/\/img.skitch.com\/20120906-rdqcxantt5iymy3xn4yf95pr7b.jpg\" alt=\"Replicator database\" border=\"1\" width=\"350\" height=\"140\" \/><\/p>\n<p>then create a new document:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto; border-color:#ababab;\" src=\"https:\/\/img.skitch.com\/20120906-x3cx8c59xu3wnrwy23mqy5nw51.jpg\" alt=\"New Document\" border=\"1\", width=\"350\" height=\"164\" \/><\/p>\n<p>Finally, populate it with these essential key\/value pairs:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" style=\"display:block; margin-left:auto; margin-right:auto; border-color:#ababab;\" src=\"https:\/\/img.skitch.com\/20120906-enqufns39pkuj4qpgpbp1bhf32.jpg\" alt=\"replication doc\" border=\"1\" width=\"400\" height=\"269\" \/><\/p>\n<ul>\n<li><strong>source<\/strong> - this is the source for replication - it only goes one-way, so this can be a local database, or a remote one. But it's where the data is coming <em>from<\/em><\/li>\n<li><strong>target<\/strong> - this is the destination for replication - again, local or remote, it makes no difference. Make sure to put in the port and the database name in the URL<\/li>\n<li><strong>proxy<\/strong> - if needed, put in the URL of the proxy to get to either of these databases<\/li>\n<li><strong>continuous<\/strong> - set to true if you want it to always be replicating<\/li>\n<\/ul>\n<p>Save this document and then look at the <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a> status page to see it replicate. It's like magic! OK, not really, but the handling of the proxy is so far superior to the way that CouchRest was dealing with it it's not even funny. This just works!<\/p>\n<p>I'm more and more convinced that <a href=\"http:\/\/couchdb.apache.org\">CouchDB<\/a> is an amazing product.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today I was really battling a nasty problem with the CouchRest client for CouchDB. This is a ruby gem, and in general, it&#8217;s pretty decent, but it really starts to fall down when you need to use a proxy to get to CouchDB, and this guy starts having all kings of problems. There were timeout [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,6,4],"tags":[],"class_list":["post-6342","post","type-post","status-publish","format-standard","hentry","category-coding","category-cube-life","category-open-source-software"],"_links":{"self":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/comments?post=6342"}],"version-history":[{"count":4,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6342\/revisions"}],"predecessor-version":[{"id":6352,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/posts\/6342\/revisions\/6352"}],"wp:attachment":[{"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/media?parent=6342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/categories?post=6342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bobbeaty.com\/wp\/wp-json\/wp\/v2\/tags?post=6342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}