Module couchbeam_changes

Function Index

changes_loop/3
fetch/1Equivalent to fetch(Db, []).
fetch/2Collect Changes.
parse_changes_options/1parse changes options and return a changes_args record.
stream/2Equivalent to stream(Db, Client, []).
stream/3Stream changes to a pid.

Function Details

changes_loop/3

changes_loop(Args::changes_args(), UserFun::function(), Params::{Url::string(), IbrowseOpts::list()}) -> ok

fetch/1

fetch(Db::db()) -> {ok, LastSeq::integer(), Rows::list()} | {error, LastSeq::integer(), Error::term()}

Equivalent to fetch(Db, []).

fetch/2

fetch(Db::db(), Options::changes_options1()) -> {ok, LastSeq::integer(), Rows::list()} | {error, LastSeq::integer(), Error::term()}

Collect Changes. Could be used to make a blocking call to a longpoll change feed

Db : a db record

ChangesOptions :: changes_options() [continuous | longpoll | normal
     | include_docs | {since, integer()}
     | {timeout, integer()}
     | heartbeat | {heartbeat, integer()}
     | {filter, string()} | {filter, string(), list({string(), string() | integer()}

Resut: {ok, LastSeq::integer(), Rows::list()} or {error, LastSeq, Error}. LastSeq is the last sequence of changes.

parse_changes_options/1

parse_changes_options(Options::changes_options()) -> changes_args()

parse changes options and return a changes_args record

stream/2

stream(Db::db(), Client::pid() | function()) -> {ok, StartRef::term(), ChangesPid::pid()} | {error, term()}

Equivalent to stream(Db, Client, []).

stream/3

stream(Db::db(), Client::pid() | function(), Options::changes_options()) -> {ok, StartRef::term(), ChangesPid::pid()} | {ok, ChangesPid::pid()} | {error, term()}

Stream changes to a pid

Db : a db record

Client : pid or callback where to send changes events where events are The pid receive these events:

{change, StartRef, {done, Lastseq::integer()}
Connection terminated or you got all changes
{change, StartRef, Row :: ejson_object()}
Line of change
{error, LastSeq::integer(), Msg::term()}
Got an error, connection is closed when an error happend.
LastSeq is the last sequence of changes.

While the callbac could be like:
       fun({done, LastSeq}) ->
           ok;
       fun({done, LastSeq}) ->
           ok;
       fun({done, LastSeq}) ->
           ok.

>ChangesOptions :: changes_options() [continuous | longpoll | normal
     | include_docs | {since, integer()}
     | {timeout, integer()}
     | heartbeat | {heartbeat, integer()}
     | {filter, string()} | {filter, string(), list({string(), string() | integer()}

Return {ok, StartRef, ChangesPid} or {error, Error}. Ref can be used to disctint all changes from this pid. ChangesPid is the pid of the changes loop process. Can be used to monitor it or kill it when needed.


Generated by EDoc, Aug 31 2012, 10:02:31.