Return-Path: Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: (qmail 37824 invoked from network); 6 Mar 2009 00:29:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2009 00:29:41 -0000 Received: (qmail 63630 invoked by uid 500); 6 Mar 2009 00:29:40 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 63591 invoked by uid 500); 6 Mar 2009 00:29:40 -0000 Mailing-List: contact dev-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list dev@couchdb.apache.org Received: (qmail 63580 invoked by uid 99); 6 Mar 2009 00:29:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Mar 2009 16:29:40 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of jchris@gmail.com designates 209.85.200.172 as permitted sender) Received: from [209.85.200.172] (HELO wf-out-1314.google.com) (209.85.200.172) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 06 Mar 2009 00:29:32 +0000 Received: by wf-out-1314.google.com with SMTP id 28so219635wff.29 for ; Thu, 05 Mar 2009 16:29:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:received:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to :content-type:content-transfer-encoding; bh=srORvA5msKITcK5b4/3f7r5BOiS+Ud5DHgD1TvziK/M=; b=w8ZmPEjA7qMCYXUdlUU4xD0o9RqMiHQ+qQvL18GTxA3mCiJ2IAItYQYs20V68yjLo5 coo2bBIJ2/T4UKU0kSvnCyPaBc6mNNXQPZ6PIivO17JLQ22/RApNmNUVLE9iiQtIINet cUCRbhnlAlPOFP6QmQ36kBjOsUND/tob1Oyi4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type :content-transfer-encoding; b=ctFWCViQHn143xlUFlI4t0nYQD01lXKi2ccoXrMzZIB2cIJq6kEPjkl5ibXoPIBmPU nLWVAQLsfL9mLZiJAX4BMXWb4E8qlxgK9XtoLwXcd4Vn9d0RoW3bwvISnJLu867en4Ee 94G9LOo9JtUKppKuSQxDraWBOPqH001t3vaEY= MIME-Version: 1.0 Sender: jchris@gmail.com Received: by 10.142.44.11 with SMTP id r11mr777416wfr.240.1236299352150; Thu, 05 Mar 2009 16:29:12 -0800 (PST) In-Reply-To: References: Date: Thu, 5 Mar 2009 16:29:12 -0800 X-Google-Sender-Auth: 240736597a0dbdf8 Message-ID: Subject: Re: Erlang API Discussion From: Chris Anderson To: dev@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org On Thu, Mar 5, 2009 at 4:16 PM, Ben Browning wrote: > A prerequisite for partitioning and a general nice-to-have feature is > an Erlang API for CouchDB. Let's get the discussion going; I'd love to > see an initial version of the API included with the 0.10 release. > > The API will overlap quite a bit with the code in couch_http_db.erl, > couch_http_view.erl, etc. I propose refactoring this code into the > Erlang API methods and having the couch_http_*.erl files use the > Erlang API. This helps us reduce code duplication and will allow us to > test the Erlang API with the existing HTTP tests. I'm not sure having the HTTP wrapper use the API is the best plan, as it might turn out to be indirection for indirections sake. If it turns out to be simpler to use the Erlang API, then of course lets do, but if it is slower or more confusing, than we shouldn't feel like we have to. > > For the initial version of the API, I'd prefer to only expose a subset > of the HTTP API. Document CRUD methods are an obvious one and at least > a basic form of view queries would be nice. The Erlang API needs to be > just as stable, if not more stable, than the HTTP API - I'm open to > implementing more or less pending reasonable discussion. +1 to keeping it limited to document CRUD on the first round. View queries will be harder to model as they rely on sending side-effects out the HTTP socket (maybe replace http socket with gen-server reply?) Internally, all database operations are updates, and they are all bulk (sometimes with bulk size of 1). I'm not sure how much we want to hide this from the user. It might be better to keep the API wrapper thin, so the user sees this. Then we can potentially add wrappers so you don't have to remember what the structure of a delete is, for instance. Chris -- Chris Anderson http://jchris.mfdz.com