Namdak Tonpa 7 years ago
parent
commit
98dc75ef1b
2 changed files with 7 additions and 8 deletions
  1. 3 3
      man/kvs_stream.htm
  2. 4 5
      src/kvs_stream.erl

+ 3 - 3
man/kvs_stream.htm

@@ -28,10 +28,10 @@
    The main descriptor of the list is the cursor which holds the cached value of one of list elements
    and also two pointers to first and last elements along with default traversal direction.
    Cursor should be stored in databse, if there is no cursor for some data then this data is not alive yet.
-   The data could be added only from list ends.
-   The data in list could be removed by record id.
+   The data could be added only to list ends.
+   The data in list could be removed only by record id.
    The list could not contain duplicates or even records with the same id.
-   When you consume the stream, the data is not deleted, you need to remove it manually.</p>
+   When you consume the stream, the data is not deleted.</p>
     </section>
     <section>
 

+ 4 - 5
src/kvs_stream.erl

@@ -22,11 +22,10 @@ next(#cur{val=[]}=C)  -> {error,[]};
 next(#cur{val=B}=C)   -> lookup(kvs:get(tab(B),en(B)),C).
 prev(#cur{val=[]}=C)  -> {error,[]};
 prev(#cur{val=B}=C)   -> lookup(kvs:get(tab(B),ep(B)),C).
-take(N,{ok,#cur{}}=C) -> take(N,C);
-take(N,{error,X})     -> {error,X};
-take(N,#cur{dir=D}=C) -> take(acc(D),N,C,[]).
-
-seek(I,  {ok,#cur{}=C})  -> seek(I,C);
+take(N,{ok,#cur{}}=C)    -> take(N,C);
+take(N,{error,X})        -> {error,X};
+take(N,#cur{dir=D}=C)    -> take(acc(D),N,C,[]).
+seek(I,  {ok,#cur{}=C})  -> seek(I,C); % accept ok/error functors is ok
 seek(I,  {error,X})      -> {error,X};
 seek(I,  #cur{val=[]}=C) -> {error,[]};
 seek(I,   #cur{val=B}=C) -> {ok,R}=kvs:get(tab(B),I), C#cur{val=R}.