$30 off During Our Annual Pro Sale. View Details »

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. Benoit Chesneau @benoitc Erlang Factory San Francisco - 2014-03-06 opencouch

    http://enki-multimedia.org
  2. open couchdb to other
 Erlang applications

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

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

    want something simpler: opencouch [1] But… [1] http://github.com/refuge/opencouch
  8. [open]couch

  9. • a full erlang application • Only application env (no

    config) • code fixes… • some refactoring • WIP… opencouch [1] http://github.com/refuge/opencouch
  10. 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
  11. 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
  12. 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
  13. what’s [next]?

  14. ! • use human readable data structures • add the

    replication • horizontal scaling • … What’s next?
  15. Want to sponsor it? contact contact@enkim.eu