|
@@ -16,138 +16,129 @@
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</nav><header>
|
|
</nav><header>
|
|
- <a href="../index.html"><img src="https://n2o.dev/img/Synrc Neo.svg" /></a>
|
|
|
|
|
|
+ <a href="../index.html"><img src="https://n2o.dev/img/synrc.svg" /></a>
|
|
<h1>STREAM</h1>
|
|
<h1>STREAM</h1>
|
|
-</header><main>
|
|
|
|
|
|
+</header>
|
|
|
|
+<main>
|
|
|
|
+ <article>
|
|
<section>
|
|
<section>
|
|
-
|
|
|
|
-<h3>INTRO</h3>
|
|
|
|
-
|
|
|
|
-<p>The STREAM module provides chain accumulation, traversal and persistence.
|
|
|
|
- </p>
|
|
|
|
-
|
|
|
|
- <p></p><blockquote><p></p><ul><li><b><a href="#writer">writer/1</a></b> — creates writer cursor to db.</li><li><b><a href="#reader">reader/1</a></b> — creates reader cursor to db.</li><li><b><a href="#save">save/1</a></b> — stores cursor to db.</li><li><b><a href="#load">load_reader/1</a></b> — loads reader cursor.</li><li><b><a href="#load">load_writer/1</a></b> — loads writer cursor.</li><li><b><a href="#top">top/1</a></b> — returns top of the chain.</li><li><b><a href="#bot">bot/1</a></b> — returns bottom of the chain.</li><li><b><a href="#next">next/1</a></b> — moves reader next.</li><li><b><a href="#prev">prev/1</a></b> — moves reader prev.</li><li><b><a href="#take">take/1</a></b> — takes N elements from reader.</li><li><b><a href="#drop">drop/1</a></b> — skips N elements from reader.</li><li><b><a href="#add">add/1</a></b> — adds element to list.</li><li><b><a href="#append">append/2</a></b> — adds element to feed.</li><li><b><a href="#append">cut/2</a></b> — cleanup feed by a given timestamp.</li></ul></blockquote>
|
|
|
|
-
|
|
|
|
- <p>
|
|
|
|
- You can grab <a style="margin-bottom:30px;" href="https://raw.githubusercontent.com/synrc/kvs/master/src/kvs_stream.erl">kvs_stream</a>
|
|
|
|
- and use it in your applications without importing <b>synrc/kvs</b> dependency,
|
|
|
|
- as this module is self-containing.
|
|
|
|
- The possible applications are: public and private feeds, FIFO queues,
|
|
|
|
- unread messages, chat applications, blockchain etc.<br /><br />
|
|
|
|
- </p></section>
|
|
|
|
|
|
+ <h3>INTRO</h3>
|
|
|
|
+ <p>The STREAM module provides chain accumulation, traversal and persistence.</p>
|
|
|
|
+ <blockquote>
|
|
|
|
+ <ul><li><b><a href="#writer">writer/1</a></b> — creates writer cursor to db.</li>
|
|
|
|
+ <li><b><a href="#reader">reader/1</a></b> — creates reader cursor to db.</li>
|
|
|
|
+ <li><b><a href="#save">save/1</a></b> — stores cursor to db.</li>
|
|
|
|
+ <li><b><a href="#load_reader">load_reader/1</a></b> — loads reader cursor.</li>
|
|
|
|
+ <li><b><a href="#load_writer">load_writer/1</a></b> — loads writer cursor.</li>
|
|
|
|
+ <li><b><a href="#top">top/1</a></b> — returns top of the chain.</li>
|
|
|
|
+ <li><b><a href="#bot">bot/1</a></b> — returns bottom of the chain.</li>
|
|
|
|
+ <li><b><a href="#next">next/1</a></b> — moves reader next.</li>
|
|
|
|
+ <li><b><a href="#prev">prev/1</a></b> — moves reader prev.</li>
|
|
|
|
+ <li><b><a href="#take">take/1</a></b> — takes N elements from reader.</li>
|
|
|
|
+ <li><b><a href="#drop">drop/1</a></b> — skips N elements from reader.</li>
|
|
|
|
+ <li><b><a href="#add">add/1</a></b> — adds element to list.</li>
|
|
|
|
+ <li><b><a href="#append">append/2</a></b> — adds element to feed.</li>
|
|
|
|
+ <li><b><a href="#cut">cut/2</a></b> — cleanup feed by a given timestamp.</li>
|
|
|
|
+ </ul></blockquote>
|
|
|
|
+
|
|
|
|
+ <p>You can grab <a style="margin-bottom:30px;" href="https://raw.githubusercontent.com/synrc/kvs/master/src/kvs_stream.erl">kvs_stream</a>
|
|
|
|
+ and use it in your applications without importing <b>synrc/kvs</b> dependency,
|
|
|
|
+ as this module is self-containing.
|
|
|
|
+ The possible applications are: public and private feeds, FIFO queues,
|
|
|
|
+ unread messages, chat applications, blockchain etc.<br /><br /></p>
|
|
|
|
+ </section>
|
|
<section>
|
|
<section>
|
|
|
|
+ <h3>WRITER</h3>
|
|
|
|
|
|
-<h3>WRITER</h3>
|
|
|
|
-
|
|
|
|
-<p>Writer cursor represents append list chain with some cached values.
|
|
|
|
- E.g., chain size, first element of the chain, cached value of
|
|
|
|
- previous written message and field for passing arguments for stream functions, like add.</p>
|
|
|
|
|
|
+ <p>Writer cursor represents append list chain with some cached values.
|
|
|
|
+ E.g., chain size, first element of the chain, cached value of
|
|
|
|
+ previous written message and field for passing arguments for stream functions, like add.</p>
|
|
|
|
|
|
-<figure><code>
|
|
|
|
- -record(writer, { id = [] :: term(),
|
|
|
|
|
|
+ <figure><code> -record(writer, { id = [] :: term(),
|
|
count = 0 :: integer(),
|
|
count = 0 :: integer(),
|
|
cache = [] :: [] | tuple(),
|
|
cache = [] :: [] | tuple(),
|
|
args = [] :: term(),
|
|
args = [] :: term(),
|
|
- first = [] :: [] | tuple() } ).
|
|
|
|
-
|
|
|
|
-</code></figure>
|
|
|
|
|
|
+ first = [] :: [] | tuple() } ).</code></figure>
|
|
|
|
+ <p>For adding data to database you need first create writer cursor,
|
|
|
|
+ set the args field with record from metainfo and call save function.</p>
|
|
|
|
|
|
-<p>For adding data to database you need first create writer cursor,
|
|
|
|
- set the args field with record from metainfo and call save function.</p>
|
|
|
|
|
|
+ <h4 id="writer">writer(term()) -> #writer{}.</h4>
|
|
|
|
+ <p>Creates writer cursor.</p>
|
|
|
|
|
|
-<h4>writer(term()) -> #writer{}.</h4>
|
|
|
|
|
|
+ <h4 id="add">add(#writer{}) -> #writer{}.</h4>
|
|
|
|
+ <p>Adds element to list declared by writer cursor.</p>
|
|
|
|
|
|
-<p>Creates writer cursor.</p>
|
|
|
|
|
|
+ <h4 id="append">append(tuple(), list()) -> term().</h4>
|
|
|
|
+ <p>Adds record to feed.</p>
|
|
|
|
|
|
-<h4>add(#writer{}) -> #writer{}.</h4>
|
|
|
|
|
|
+ <h4 id="cut">cut(list(), term()) -> #ok{} | #error{}.</h4>
|
|
|
|
+ <p>Adds record to feed.</p>
|
|
|
|
|
|
-<p>Adds element to list declared by writer cursor.</p>
|
|
|
|
|
|
+ <h4 id="load_writer">load_writer(#writer{}) -> #writer{}.</h4>
|
|
|
|
+ <p>Loads writer cursor.</p>
|
|
|
|
|
|
-<h4>load_writer(#writer{}) -> #writer{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Loads writer cursor.</p>
|
|
|
|
-
|
|
|
|
-<h4>save(#writer{}) -> #writer{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Flushes writer cursor to database.</p>
|
|
|
|
|
|
+ <h4 id="save">save(#writer{}) -> #writer{}.</h4>
|
|
|
|
+ <p>Flushes writer cursor to database.</p>
|
|
|
|
|
|
</section>
|
|
</section>
|
|
<section>
|
|
<section>
|
|
|
|
|
|
-<h3>READER</h3>
|
|
|
|
-
|
|
|
|
-<figure><figcaption>Reader Cursor</figcaption><code>
|
|
|
|
- -record(reader, { id = [] :: integer(),
|
|
|
|
|
|
+ <h3>READER</h3>
|
|
|
|
+ <figure><figcaption>Reader Cursor</figcaption>
|
|
|
|
+ <code> -record(reader, { id = [] :: integer(),
|
|
pos = 0 :: [] | integer(),
|
|
pos = 0 :: [] | integer(),
|
|
cache = [] :: [] | integer(),
|
|
cache = [] :: [] | integer(),
|
|
args = [] :: term(),
|
|
args = [] :: term(),
|
|
feed = [] :: term(),
|
|
feed = [] :: term(),
|
|
- dir = 0 :: 0 | 1 } ).
|
|
|
|
-
|
|
|
|
-</code></figure>
|
|
|
|
-
|
|
|
|
-<h4>reader(integer()) -> #reader{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Creates reader cursor.</p>
|
|
|
|
|
|
+ dir = 0 :: 0 | 1 } ).</code></figure>
|
|
|
|
|
|
-<h4>load_reader(#reader{}) -> #reader{}.</h4>
|
|
|
|
|
|
+ <h4 id="reader">reader(integer()) -> #reader{}.</h4>
|
|
|
|
+ <p>Creates reader cursor.</p>
|
|
|
|
|
|
-<p>Loads reader cursor from database.</p>
|
|
|
|
|
|
+ <h4 id="load_reader">load_reader(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Loads reader cursor from database.</p>
|
|
|
|
|
|
-<h4>save(#reader{}) -> #reader{}.</h4>
|
|
|
|
|
|
+ <h4 id="save">save(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Flushes reader cursor to database.</p>
|
|
|
|
|
|
-<p>Flushes cursor to database.</p>
|
|
|
|
-
|
|
|
|
-<h4>top(#reader{}) -> #reader{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Moves cursor to top of the list.</p>
|
|
|
|
-
|
|
|
|
-<h4>bot(#reader{}) -> #reader{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Moves cursor to bottom of the list.</p>
|
|
|
|
|
|
+ <h4 id="top">top(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Moves cursor to top of the list.</p>
|
|
|
|
|
|
|
|
+ <h4 id="bot">bot(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Moves cursor to bottom of the list.</p>
|
|
</section>
|
|
</section>
|
|
<section>
|
|
<section>
|
|
-
|
|
|
|
-<h3>ITER</h3>
|
|
|
|
-
|
|
|
|
-<figure><figcaption>KVS Stream Iterator</figcaption><code>
|
|
|
|
- -record(iter, { id = [] :: [] | integer(),
|
|
|
|
|
|
+ <h3>ITER</h3>
|
|
|
|
+ <figure><figcaption>KVS Stream Iterator</figcaption>
|
|
|
|
+ <code> -record(iter, { id = [] :: [] | integer(),
|
|
next = [] :: [] | integer(),
|
|
next = [] :: [] | integer(),
|
|
- prev = [] :: [] | integer() } ).
|
|
|
|
-
|
|
|
|
-</code></figure>
|
|
|
|
|
|
+ prev = [] :: [] | integer() } ).</code></figure>
|
|
|
|
|
|
-<h4>next(#reader{}) -> #reader{}.</h4>
|
|
|
|
|
|
+ <h4 id="next">next(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Moves cursor to next. Consume data down from top.
|
|
|
|
+ Return error if list is empty, otherwise next element or last.</p>
|
|
|
|
|
|
-<p>Moves cursor to next. Consume data down from top.
|
|
|
|
- Return error if list is empty, otherwise next element or last.</p>
|
|
|
|
|
|
+ <h4 id="prev">prev(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Moves cursor to prev. Consume data up from bottom.
|
|
|
|
+ Return error if list is empty, otherwise next element or last.</p>
|
|
|
|
|
|
-<h4>prev(#reader{}) -> #reader{}.</h4>
|
|
|
|
|
|
+ <h4 id="drop">drop(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Drops N elements starting from reader.</p>
|
|
|
|
|
|
-<p>Moves cursor to prev. Consume data up from bottom.
|
|
|
|
- Return error if list is empty, otherwise next element or last.</p>
|
|
|
|
-
|
|
|
|
-<h4>drop(#reader{}) -> #reader{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Drops N elements starting from reader.</p>
|
|
|
|
-
|
|
|
|
-<h4>take(#reader{}) -> #reader{}.</h4>
|
|
|
|
-
|
|
|
|
-<p>Trying to consume N records from stream using its current value and direction.
|
|
|
|
- Returns consumed data. Usually you seek to some position and then consume some data.</p>
|
|
|
|
|
|
+ <h4 id="take">take(#reader{}) -> #reader{}.</h4>
|
|
|
|
+ <p>Trying to consume N records from stream using its current value and direction.
|
|
|
|
+ Returns consumed data. Usually you seek to some position and then consume some data.</p>
|
|
|
|
|
|
</section>
|
|
</section>
|
|
<section>
|
|
<section>
|
|
-
|
|
|
|
-<p>This module may refer to:
|
|
|
|
-<a href="kvs.htm"><b>kvs</b></a>,
|
|
|
|
-<a href="kvs_st.htm"><b>kvs_st</b></a>.
|
|
|
|
-</p>
|
|
|
|
-
|
|
|
|
|
|
+ <p>This module may refer to:
|
|
|
|
+ <a href="kvs.htm"><b>kvs</b></a>,
|
|
|
|
+ <a href="kvs_st.htm"><b>kvs_st</b></a>.
|
|
|
|
+ </p>
|
|
</section>
|
|
</section>
|
|
-</main><footer>
|
|
|
|
- 2005—2019 © Synrc Research Center
|
|
|
|
-</footer>
|
|
|
|
|
|
+ </article>
|
|
|
|
+</main>
|
|
|
|
+<footer>2005—2019 © Synrc Research Center</footer>
|
|
<script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
|
|
<script>function drop(){document.getElementById("dropdown").classList.toggle("show");}</script>
|
|
-</body></html>
|
|
|
|
|
|
+</body>
|
|
|
|
+</html>
|