Return-Path: X-Original-To: apmail-couchdb-dev-archive@www.apache.org Delivered-To: apmail-couchdb-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DC16B18204 for ; Mon, 19 Oct 2015 18:09:14 +0000 (UTC) Received: (qmail 9103 invoked by uid 500); 19 Oct 2015 18:09:09 -0000 Delivered-To: apmail-couchdb-dev-archive@couchdb.apache.org Received: (qmail 9011 invoked by uid 500); 19 Oct 2015 18:09:08 -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 8999 invoked by uid 99); 19 Oct 2015 18:09:07 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Oct 2015 18:09:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 0A9F9C04B9 for ; Mon, 19 Oct 2015 18:09:07 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.75 X-Spam-Level: X-Spam-Status: No, score=0.75 tagged_above=-999 required=6.31 tests=[KAM_INFOUSMEBIZ=0.75, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id JKFSropfM1zW for ; Mon, 19 Oct 2015 18:08:58 +0000 (UTC) Received: from mail-lb0-f171.google.com (mail-lb0-f171.google.com [209.85.217.171]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTPS id CC29021651 for ; Mon, 19 Oct 2015 18:08:57 +0000 (UTC) Received: by lbbpp2 with SMTP id pp2so122744382lbb.0 for ; Mon, 19 Oct 2015 11:08:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version:subject:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=JQx25EvtC+xxDXu9xZg8IOHZe891EBclaM/jv6t7hfg=; b=LA46/Q4j1U4KDP45iI1VMX9serP0W5nZa0YXaq+Ca2GgG0Zdji8mvZwbJCyyKd8tS8 LdbWTMbRpfSB1qugnnZQ4BpfoMBx9Zg/goPM6MjOgrDXNf2YCfkj84A6llgU3eSwq3Yf 7JjdDkVeUG8MgtnUvmaCf7jSL8lfnPkco+kj2HgP6EJ6AU8Nw3szsHYxLpVRuCCGqmNb 8K/zAW29IkYU8b9UY4rK+6RlAwrBPDSxPrS8OdfLoQUtLTBcx5PYaIQzfDJ1p8KrI7PB LQfkdAEsPqoDzIue6XaNQWdE69vuhx4HPpUyG4Ow2XGyVNOhYevyO/yzfjJlHTxXRYK5 /MrA== X-Gm-Message-State: ALoCoQmQEe3oazDCFdhIp5W41mJynF+exO2wumuuJR9PbEWKTlSf02jRqy0c64SIaJKnaDwitYRo X-Received: by 10.194.206.38 with SMTP id ll6mr35640996wjc.116.1445278136102; Mon, 19 Oct 2015 11:08:56 -0700 (PDT) Received: from [192.168.0.6] (169-0-81-31.ip.afrihost.co.za. [169.0.81.31]) by smtp.gmail.com with ESMTPSA id jd7sm41599701wjb.19.2015.10.19.11.08.53 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 19 Oct 2015 11:08:55 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 9.0 \(3094\)) Subject: Re: [PROPOSAL] Allow rewrites to be JS function From: Garren Smith In-Reply-To: <7243D1CA-C398-423D-84E2-C12FEC1A1B6D@b2w.com> Date: Mon, 19 Oct 2015 20:08:51 +0200 Cc: andywenk@apache.org Content-Transfer-Encoding: quoted-printable Message-Id: <63D4CE75-97BC-4611-82A9-45C98753EFB5@redcometlabs.com> References: <467C2D4D-971D-4E5C-A9AA-D3B17FD18220@b2w.com> <7EB4541B-630C-47A8-A2FF-2E4B04EE8EB1@b2w.com> <700C10F8-97B2-45AC-B9CA-C19DB5B36B1F@b2w.com> <7243D1CA-C398-423D-84E2-C12FEC1A1B6D@b2w.com> To: dev@couchdb.apache.org X-Mailer: Apple Mail (2.3094) I=E2=80=99m really struggling with these proposals. I love the = enthusiasm of everyone but I keep thinking we should rather simplify = CouchDB.=20 CouchDB is ultimately a database. One with excellent sync capabilities. = And combining that with libraries like PouchDB and Hoodie make it an = amazing database to build applications with.=20 Adding routers and reverse proxies just makes it feel like we trying to = push CouchDB into being more than it needs to be. For example building Couchapp like functionality in Node.js is so simple = and way better. Languages like Go also do that really well. Far superior = than what we can do with a database. I would rather let the Node.js and Go web libraries serve content and = let us focus on building a clustered replicating database. We will draw = more people to this community if we can do that properly over creaky, = slow and limited web serving mashed on top of a database. If I look at other popular databases, I don=E2=80=99t see any of them = serving web content which is probably a sign that this idea is not = something worth pursuing.=20 However if there is a burning desire for this and developers raising = their hands to code this functionality, I would not stand in your way. = It is great to see the varied use of CouchDB out in the wild. Cheers Garren > On 19 Oct 2015, at 4:47 PM, Johs. E wrote: >=20 > Thanks Andy, > I will try and get some use cases up on confluence. > As for whoever would pick up the work after ermouth, I have of course = one big thing on the wish list that goes well with a new router = solution.. > reverse proxy > I remember asking about it when I first started to work w CouchDB and = there were some concerns regarding security. > Since then I think node.js has paved the way with content scraping and = all sorts of outgoing traffic. >=20 > Has anyone work on a reverse proxy solution for Couch? >=20 > johs >=20 >=20 >> On 18 Oct 2015, at 21:36, Andy Wenk wrote: >>=20 >> Hey Johs, >>=20 >> thanks a lot for this. I need some time to dig into it. We need a = place to >> write the user stories / use case down. So I suggest we find good = place at >> the cwiki. So I suggest to use >> = https://cwiki.apache.org/confluence/display/COUCHDB/Enhancement+Proposals = . >> Do you have write access there? If not, please ping me. >>=20 >> Great work! >>=20 >> All the best >>=20 >> Andy >>=20 >> P.S.: Jan already mentioned the feature freeze. Please take it not as = a >> demotivation but as the possibility to have a bit more time to work = on it. >>=20 >> On 17 October 2015 at 17:32, Johs Ensby wrote: >>=20 >>> Andy, >>> I will make my first use case for function in _rewrite a high level = one: >>> to create a standalone server that is an all-in-one DB server, = application >>> server, api server and web server. >>>=20 >>> I have played with the build of CouchDB 2 with rewrite function >>> implemented that ermouth put up on the irish AWS community AMI list = and >>> the new use cases are endless. >>> First, I find that there are a few things that people fail to notice = about >>> ddocs. >>> you need a tool to build a ddoc, editing JSON is not a viable = option. The >>> Ddoc Lab of ermouth is in a class of its own. If you havent tried it = yet, >>> do so from http://ddoc.me/ . Installing on your own >>> couch it is as easy as storing the application, all included as one >>> document in any database. Ddoc Lab is a component oriented IDE with = syntax >>> checking, less preprosessor and other build tools that let you keep = a well >>> organized ddoc as a source project (in one couchdb document) and you >>> publich a ddoc to any target db. >>> with this tool you can organize your js modules and templates etc = and >>> basically... >>> set up the API of your application in a ddoc. You can switch between >>> databases and their ddoc functionality based on username, role or >>> geolocation and limit access to parts of the Couch API as needed >>>=20 >>> This is the method I would recommend to explore powerful simplicity = with >>> function in rewrites >>> redirect port 80 directly to couch >>> set up 2 vhosts, one for public access pointing to youdb/_design/api = and >>> one for sysadm pointing to / >>> for admin use Fauxton and Ddoc Lab on the sysadm vhost >>> you are set to develop great systems, no big tool stack to learn, = just >>> bring in whatever js modules you like, the template engine you like, = the >>> router you like, the HTML5 stuff you like.. >>> .. or just write some very compact js code in one place where you = ealier >>> had to mess around with a whole stack of tools and systems >>>=20 >>> below is the req object that the function takes >>>=20 >>> Johs >>>=20 >>>=20 >>>=20 >>> The rewrite function has this syntax >>> function(req) { >>> .. your code that will >>> return >>> path >>> // optional >>> headers >>> method // you can change this on the fly >>> code >>> body >>> } >>>=20 >>> the function receives this req object >>> method >>> path >>> raw_path >>> query >>> headers >>> Accept >>> Accept-Encoding >>> Connection >>> Host >>> Upgrade-Insecure-Requests >>> User-Agent >>> x-couchdb-vhost-path >>> body >>> peer >>> cookie >>> userCtx >>> db >>> name >>> roles >>> secObj >>>=20 >>>> On 1. okt. 2015, at 13.40, Andy Wenk wrote: >>>>=20 >>>> Johs, >>>>=20 >>>> Yes for sure! That's always great. Maybe you can also write some = user >>> stories (given when then) or scribble some graphics. Everything is = useful >>> and will fasten the process ;-) >>>>=20 >>>> Cheers >>>>=20 >>>> Andy >>>>=20 >>>> On 1 Oct 2015 12:38, "Johs Ensby" > >>> wrote: >>>> Thanks for this Andy, >>>>=20 >>>> I can contribute to the discussion of the feature seen from a user >>> perspective. >>>> Would it be appropriate to present some use cases? >>>>=20 >>>> best >>>> Johs >>>>=20 >>>>> On 1. okt. 2015, at 12.33, Andy Wenk >> andywenk@apache.org>> wrote: >>>>>=20 >>>>> Johs, >>>>>=20 >>>>> Let me please show the steps needed. >>>>>=20 >>>>> * discuss the feature very clearly on the dev@. Please make sure = that >>> core >>>>> developers as committers with commit bits are involved >>>>>=20 >>>>> * code the feature. Make sure to implement tests >>>>>=20 >>>>> * send a pull request and show it to dev@ >>>>>=20 >>>>> * finally the community will accept or decline the feature (this = will >>>>> involve refactoring and changes) >>>>>=20 >>>>> As Alex said. The PMC or Jan do not decide about the feature. >>>>>=20 >>>>> All the best >>>>>=20 >>>>> Andy >>>>> On 1 Oct 2015 11:21, "Alexander Shorin" >> kxepal@gmail.com>> wrote: >>>>>=20 >>>>>> On Thu, Oct 1, 2015 at 12:07 PM, Johs Ensby >> johs@b2w.com>> wrote: >>>>>>> will you welcome ermouths rewrite contribution? >>>>>>=20 >>>>>> The decision is depends on the implementation. If it will be = good, why >>>>>> not? Finally, CouchDB is open source project: we cannot forbid = people >>>>>> right for contributions, we only welcome them. >>>>>>=20 >>>>>>> Arguments against couchapps has to do with performance and the = folly >>> in >>>>>> competing with node.js. >>>>>>=20 >>>>>> Performance question for the new _rewrite implementation is very >>>>>> depends on query server. Once it can process this kind of = functions, >>>>>> you may use something better than JS to gain better performance. = That >>>>>> could be Erlang native query server, or luerl-based one, or else = you >>>>>> like. >>>>>>=20 >>>>>> -- >>>>>> ,,,^..^,,, >>>>>>=20 >>>>=20 >>>=20 >>>=20 >>=20 >>=20 >> --=20 >> Andy Wenk >> Hamburg - Germany >> RockIt! >>=20 >> GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588 >>=20 >> https://people.apache.org/keys/committer/andywenk.asc >=20