Slide 1

Slide 1 text

Benoit Chesneau @benoitc Erlang Factory San Francisco - 2014-03-06 opencouch http://enki-multimedia.org

Slide 2

Slide 2 text

open couchdb to other
 Erlang applications

Slide 3

Slide 3 text

• wanted an easy way to extend Apache CouchDB • Embed couchdb in a refuge [1] application Legacy [1] http://refuge.io

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

• Started with rcouch [1] • Build Apache CouchDB as an Erlang/OTP release • Allows someone to embed rcouch in its own application: couch_core Legacy [1] http://github.com/refuge/rcouch

Slide 6

Slide 6 text

$ git clone https://github.com/refuge/rcouch.git! $ cd rcouch! $ make && make rel! $ ./rel/rcouch/bin/rcouch console! ….! [<0.49.0>] [notice] Changed loglevel of ./log/couch.log to info! [<0.160.0>] [info] HTTP API started on "http://0.0.0.0:5984/"! Eshell V5.10.4 (abort with ^G)! $ rcouch in action…

Slide 7

Slide 7 text

• still an ini • lot of useless applications • want something simpler: opencouch [1] But… [1] http://github.com/refuge/opencouch

Slide 8

Slide 8 text

[open]couch

Slide 9

Slide 9 text

• a full erlang application • Only application env (no config) • code fixes… • some refactoring • WIP… opencouch [1] http://github.com/refuge/opencouch

Slide 10

Slide 10 text

1> couch:start().! ! {ok,[crypto,sasl,asn1,public_key,ssl,syntax_tools,compiler,! goldrush,lager,couch]}! ! 2> {ok, Db} = couch_server:create(<<"testdb">>, []).! {ok,{db,<0.97.0>,nil,<<"1394151778355726">>,<0.96.0>,! ….! open a database

Slide 11

Slide 11 text

3> Doc = couch_doc:from_json_obj({[{<<"_id">>, <<"a">>}]}).! {doc,<<"a">>,{0,[]},{[]},[],false,[]}! 5> couch_db:update_doc(Db, Doc, []). ! {ok,{1,! <<150,122,0,223,245,224,42,221,65,129,145,56,171,179,40,! 77>>}} store a doc

Slide 12

Slide 12 text

4> {ok, Total} = couch_db:get_doc_count(Db).! {ok,0}! 7> {ok, Db1} = couch_db:reopen(Db). ! {ok,{db,<0.97.0>,nil,<<"1394151778355726">>,<0.96.0>,! #Ref<0.0.0.216>,! ….! 5> {ok, Total1} = couch_db:get_doc_count(Db1).! {ok,1}! 6> couch_db:enum_docs(Db1, fun(FullDocInfo, _OffsetReds, Acc) -> ! 6> io:format("full doc info: ~p~n", [FullDocInfo]), ! 6> {ok, Acc} ! 6> end, nil, []). ! full doc info: {full_doc_info,<<"a">>,1,false,! [{1,! {<<150,122,0,223,245,224,42,221,65,129,145 171,179,40,77>>,! {leaf,false,79,1,39},! []}}],! 39}! {ok,1,nil}! doc has been stored

Slide 13

Slide 13 text

what’s [next]?

Slide 14

Slide 14 text

! • use human readable data structures • add the replication • horizontal scaling • … What’s next?

Slide 15

Slide 15 text

Want to sponsor it? contact [email protected]