couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Cottlehuber <...@jsonified.com>
Subject Re: Using Elixir language for CouchDB hacking
Date Sat, 30 Nov 2013 00:44:51 GMT
Hi Alexei!

After a bit of fiddling, it works - at least the config & loading the genserver automatically.

Here’s the config you want to use (i.e. updates to local.ini)

    [native_query_servers]
    erlang = {couch_native_process, start_link, []}
    elixir = {'Elixir.CouchQuery', start_link, []}

check with this:

Π dch@akai couch_plugins-0.1 % pie get http://localhost:5984/_config/native_query_servers
GET /_config/native_query_servers HTTP/1.1
Accept: application/json
…
Server: CouchDB/1.6.0+build.bae0b27 (Erlang OTP/R16B02)

{
    "elixir": "{'Elixir.CouchQuery', start_link, []}",
    "erlang": "{couch_native_process, start_link, []}"
}

And if you try to build a temp view with type elixir using futon then the genserver is correctly
started for you - yay!

For the moment I put your files here:

Π dch@akai couch_elixir-0.1 % pwd

    $COUCHDB/lib/couchdb/erlang/lib/couch_elixir-0.1

Π dch@akai couch_elixir-0.1 % elixirc -o ebin --verbose lib/couchquery.ex
Compiled lib/couchquery.ex

Π dch@akai couch_elixir-0.1 % tree
.
├── ebin/
│   └── Elixir.CouchQuery.beam
└── lib/
    └── couchquery.ex

But any dir under $COUCH/lib/couchdb/erlang/lib/something-0.123
should work fine I think. I guess we could make this a plugin of sorts.

I’d suggest adding elixir in here too somehow, maybe also as a plugin?

└── lib/
    ├── eex/
    │   └── ebin/
    │       ├── Elixir.EEx.AssignsEngine.beam
    │       ├── Elixir.EEx.Compiler.beam
    │       ├── Elixir.EEx.Engine.beam
    │       ├── Elixir.EEx.SmartEngine.beam
    │       ├── Elixir.EEx.State.beam
    │       ├── Elixir.EEx.SyntaxError.beam
    │       ├── Elixir.EEx.Tokenizer.beam
    │       ├── Elixir.EEx.TransformerEngine.beam
    │       ├── Elixir.EEx.beam
    │       └── eex.app
    ├── elixir/
    │   └── ebin/
    │       ├── Elixir.Access.Atom.beam
    │       ├── Elixir.Access.HashDict.beam
    │       ├── Elixir.Access.List.beam
    │       ├── Elixir.Access.beam
    │       ├── Elixir.Application.Behaviour.beam
    │       ├── Elixir.ArgumentError.beam
    │       ├── Elixir.ArithmeticError.beam

… etc.

so you should have the full elixir runtime available.

If you look inside ./couchdb[1] you can probably turn it into
an iex shell directly too.

And read closely couch_native_process.erl[2] which you’ll want to re-use a lot of, most
likely.

I’ve not read plugins in detail yet, [3][4] but I’m keen to see what you come up with!

[1]: https://github.com/apache/couchdb/blob/master/bin/couchdb.tpl.in
[2]: https://github.com/apache/couchdb/blob/master/src/couchdb/couch_native_process.erl 
[3]: https://github.com/apache/couchdb/tree/master/src/my-first-couchdb-plugin
[4]: http://docs.couchdb.org/en/latest/experimental.html#plugins

A+
Dave



Mime
View raw message