Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Opencouch

 Opencouch

Discover opencouch, open couchdb to your #Erlang applications. Lightning Talk given at the Erlang Factory 2014

Benoit Chesneau

March 07, 2014
Tweet

More Decks by Benoit Chesneau

Other Decks in Technology

Transcript

  1. • wanted an easy way to extend Apache CouchDB •

    Embed couchdb in a refuge [1] application Legacy [1] http://refuge.io
  2. • 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
  3. $ 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…
  4. • still an ini • lot of useless applications •

    want something simpler: opencouch [1] But… [1] http://github.com/refuge/opencouch
  5. • a full erlang application • Only application env (no

    config) • code fixes… • some refactoring • WIP… opencouch [1] http://github.com/refuge/opencouch
  6. 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
  7. 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
  8. ! • use human readable data structures • add the

    replication • horizontal scaling • … What’s next?