couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From darobin <...@git.apache.org>
Subject couchdb pull request: Rewrite using functions
Date Thu, 25 Oct 2012 16:19:07 GMT
GitHub user darobin opened a pull request:

    https://github.com/apache/couchdb/pull/38

    Rewrite using functions

    This pull request implements the ability of using functions for rewriting in addition
to the rewriting microlanguage that is currently available. The motivation for doing so comes
from a discussion on the users' list in which it turned out that I wasn't the only one who
found the microlanguage limited (the latter still works just the same though).
    
    It uses the same "rewrites" ddoc key so that you can't have both. I think that this is
a feature: specifying both and having to figure out which takes precedence would be excessive
complication IMHO. And it's of course possible to have the function implement the microlanguage
if for some reason one wishes to use both simultaneously.
    
    I've provided some docs in the comments — if the patch is accepted and those need to
be mirrored (and expanded) somewhere else, simply tell me where is the preferred location.
I've also written some tests; I guess that there could be more but it seems clear that it
works and doesn't break existing rewrites.
    
    The only change that it makes to the current HTTP interface is that previously if you
added a ddoc with a string as the value for "rewrites" you'd get a 400. Now, if that strings
is a valid function is just works, and if it's not you get a 500. I doubt that this will break
anything.
    
    Some caveats:
    
    • This is essentially my Hello World to Erlang. It's not out of the question that I've
written something that looks terrifyingly stupid or woefully more convoluted than it needs
to be.
    
    • I've tried to follow the coding conventions that I noticed, apologies if I messed
it up here or there.
    
    • The rewrite functions are meant to be cacheable at least for the lifetime of a given
ddoc but I haven't added such caching. I don't know how much it would affect performance (though
I would expect some). I also don't know whether it should vary on userCtx or not. Either way,
I think that it's an optimisation that can be added later.
    


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/darobin/couchdb rewrite-js

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb/pull/38.patch

----
commit 7cb449346ebe033073fb70f774f11d4fe1e8b991
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T00:27:55-07:00

    rewrite as a function

commit e4c60abca42e606553096c7f6c3f5bf0311ed2b6
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T06:32:34-07:00

    now that strings are acceptable, strings that aren't functions ought to return 500

commit 8135966bf31ffa5741a23549f0e204ee7beb1da4
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T07:27:47-07:00

    function based rewrite that works at least for simple cases

commit 5322893f43b126522bd1ebf4f0bb490c0fab59bd
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T07:50:38-07:00

    refactor rewrite processing; minor fix in test

commit 43e98e6e79e8b659270df4ec8872f09e5dc04a78
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T08:06:51-07:00

    pass the path after _rewrite to the rewrite function, it makes things simpler

commit 44e3b633a6a88f3bbd76272bab915071a95e3cde
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T08:10:00-07:00

    test that not matching returns 500

commit f3f6c05a1084d4a019e82777696d2f80202b6c0a
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T08:45:50-07:00

    more tests to check that it actually works

commit ba446cb71ed0debff42fbc94adbea5014e64d174
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T08:54:24-07:00

    cleaning up comments

commit efccc87c9797b8f520ccaaf88025fab1bbb6e508
Author: Robin Berjon <robin@berjon.com>
Date:   2012-10-25T09:00:35-07:00

    docs

----


Mime
View raw message