keuss 1.6.10 → 1.6.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (202) hide show
  1. package/Pipeline/Queue.js +12 -2
  2. package/Queue.js +18 -8
  3. package/TODO +0 -1
  4. package/backends/bucket-mongo-safe.js +42 -44
  5. package/backends/bucket-mongo.js +6 -8
  6. package/examples/snippets/06-random-consumer-producer.js +5 -5
  7. package/package.json +6 -6
  8. package/test/backends_bucket-at-least-once.js +43 -35
  9. package/test/backends_deadletter.js +10 -1
  10. package/.nyc_output/ad035de4-a3d3-451b-b2ad-402e8ed517b8.json +0 -1
  11. package/.nyc_output/c8683d6c-e7e6-496b-ab0d-1ff730837d08.json +0 -1
  12. package/.nyc_output/processinfo/ad035de4-a3d3-451b-b2ad-402e8ed517b8.json +0 -1
  13. package/.nyc_output/processinfo/c8683d6c-e7e6-496b-ab0d-1ff730837d08.json +0 -1
  14. package/.nyc_output/processinfo/index.json +0 -1
  15. package/coverage/base.css +0 -224
  16. package/coverage/block-navigation.js +0 -79
  17. package/coverage/index.html +0 -162
  18. package/coverage/keuss/Pipeline/BaseLink.js.html +0 -636
  19. package/coverage/keuss/Pipeline/Builder.js.html +0 -615
  20. package/coverage/keuss/Pipeline/ChoiceLink.js.html +0 -294
  21. package/coverage/keuss/Pipeline/DirectLink.js.html +0 -231
  22. package/coverage/keuss/Pipeline/Pipeline.js.html +0 -258
  23. package/coverage/keuss/Pipeline/Queue.js.html +0 -939
  24. package/coverage/keuss/Pipeline/Sink.js.html +0 -147
  25. package/coverage/keuss/Pipeline/index.html +0 -175
  26. package/coverage/keuss/QFactory-MongoDB-defaults.js.html +0 -219
  27. package/coverage/keuss/QFactory.js.html +0 -459
  28. package/coverage/keuss/Queue.js.html +0 -2274
  29. package/coverage/keuss/Signal.js.html +0 -312
  30. package/coverage/keuss/Stats.js.html +0 -174
  31. package/coverage/keuss/backends/bucket-mongo-safe.js.html +0 -2952
  32. package/coverage/keuss/backends/bucket-mongo.js.html +0 -1167
  33. package/coverage/keuss/backends/index.html +0 -175
  34. package/coverage/keuss/backends/mongo.js.html +0 -897
  35. package/coverage/keuss/backends/pl-mongo.js.html +0 -723
  36. package/coverage/keuss/backends/ps-mongo.js.html +0 -1038
  37. package/coverage/keuss/backends/redis-list.js.html +0 -513
  38. package/coverage/keuss/backends/redis-oq.js.html +0 -543
  39. package/coverage/keuss/bench/all-mongo.js.html +0 -393
  40. package/coverage/keuss/bench/index.html +0 -149
  41. package/coverage/keuss/bench/multi-q.js.html +0 -324
  42. package/coverage/keuss/bench/redis-oq-consumer-producer.js.html +0 -225
  43. package/coverage/keuss/bench/redis-oq-consumer.js.html +0 -189
  44. package/coverage/keuss/bench/redis-oq-producer.js.html +0 -198
  45. package/coverage/keuss/docusaurus/.docusaurus/client-modules.js.html +0 -93
  46. package/coverage/keuss/docusaurus/.docusaurus/docusaurus.config.js.html +0 -402
  47. package/coverage/keuss/docusaurus/.docusaurus/index.html +0 -136
  48. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/01a85c17.4e57aa0a.js.html +0 -69
  49. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/09d5ad39.3009117f.js.html +0 -69
  50. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/1.12cf3eb8.js.html +0 -69
  51. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/12559443.a244228c.js.html +0 -69
  52. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/17896441.5efb3558.js.html +0 -69
  53. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/1be78505.f9c04817.js.html +0 -69
  54. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/2.4e2dc02c.js.html +0 -72
  55. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/3.d549a05d.js.html +0 -69
  56. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/36.db0e809a.js.html +0 -69
  57. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/37637b3c.28c0900b.js.html +0 -69
  58. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/3d8d21df.2228b429.js.html +0 -69
  59. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/45a5cd1f.951da354.js.html +0 -69
  60. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/52c38f7a.785707bc.js.html +0 -69
  61. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/57ffbe3d.04d3e53e.js.html +0 -69
  62. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/5f7c35e9.2fa77599.js.html +0 -69
  63. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/6299bd84.ec197a3e.js.html +0 -69
  64. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/6875c492.cdf3e939.js.html +0 -69
  65. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/6beec1d2.6873e708.js.html +0 -69
  66. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/7b786ad4.bbce08e6.js.html +0 -69
  67. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/8070e160.400a4e57.js.html +0 -69
  68. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/88c93c54.e868a433.js.html +0 -69
  69. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/8d3e6f9e.aadf6d32.js.html +0 -69
  70. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/9bc74468.516633c5.js.html +0 -69
  71. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/9beb87c2.71e3744d.js.html +0 -69
  72. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/a3732fac.b0f98dbf.js.html +0 -69
  73. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/a6aa9e1f.6ac55e6c.js.html +0 -69
  74. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/baf0d4a2.b50efd2d.js.html +0 -69
  75. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/c4f5d8e4.e9dfd999.js.html +0 -69
  76. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/ccc49370.1831890b.js.html +0 -69
  77. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/d4942345.7d23b349.js.html +0 -69
  78. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/e2244795.4ea3d168.js.html +0 -69
  79. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/e64fe266.308265e8.js.html +0 -69
  80. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/f78725cc.5f3e115d.js.html +0 -69
  81. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/fa8d8063.2312a332.js.html +0 -69
  82. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/index.html +0 -565
  83. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/main.66f1008c.js.html +0 -72
  84. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/runtime~main.7d73b048.js.html +0 -69
  85. package/coverage/keuss/docusaurus/.docusaurus/keuss-gh-pages/styles.b5ee3016.js.html +0 -69
  86. package/coverage/keuss/docusaurus/.docusaurus/registry.js.html +0 -165
  87. package/coverage/keuss/docusaurus/.docusaurus/routes.js.html +0 -447
  88. package/coverage/keuss/docusaurus/build/01a85c17.4e57aa0a.js.html +0 -69
  89. package/coverage/keuss/docusaurus/build/09d5ad39.3009117f.js.html +0 -69
  90. package/coverage/keuss/docusaurus/build/1.12cf3eb8.js.html +0 -69
  91. package/coverage/keuss/docusaurus/build/12559443.a244228c.js.html +0 -69
  92. package/coverage/keuss/docusaurus/build/17896441.5efb3558.js.html +0 -69
  93. package/coverage/keuss/docusaurus/build/1be78505.f9c04817.js.html +0 -69
  94. package/coverage/keuss/docusaurus/build/2.4e2dc02c.js.html +0 -72
  95. package/coverage/keuss/docusaurus/build/3.d549a05d.js.html +0 -69
  96. package/coverage/keuss/docusaurus/build/36.db0e809a.js.html +0 -69
  97. package/coverage/keuss/docusaurus/build/37637b3c.28c0900b.js.html +0 -69
  98. package/coverage/keuss/docusaurus/build/3d8d21df.2228b429.js.html +0 -69
  99. package/coverage/keuss/docusaurus/build/45a5cd1f.951da354.js.html +0 -69
  100. package/coverage/keuss/docusaurus/build/52c38f7a.785707bc.js.html +0 -69
  101. package/coverage/keuss/docusaurus/build/57ffbe3d.04d3e53e.js.html +0 -69
  102. package/coverage/keuss/docusaurus/build/5f7c35e9.2fa77599.js.html +0 -69
  103. package/coverage/keuss/docusaurus/build/6299bd84.ec197a3e.js.html +0 -69
  104. package/coverage/keuss/docusaurus/build/6875c492.cdf3e939.js.html +0 -69
  105. package/coverage/keuss/docusaurus/build/6beec1d2.6873e708.js.html +0 -69
  106. package/coverage/keuss/docusaurus/build/7b786ad4.bbce08e6.js.html +0 -69
  107. package/coverage/keuss/docusaurus/build/8070e160.400a4e57.js.html +0 -69
  108. package/coverage/keuss/docusaurus/build/88c93c54.e868a433.js.html +0 -69
  109. package/coverage/keuss/docusaurus/build/8d3e6f9e.aadf6d32.js.html +0 -69
  110. package/coverage/keuss/docusaurus/build/9bc74468.516633c5.js.html +0 -69
  111. package/coverage/keuss/docusaurus/build/9beb87c2.71e3744d.js.html +0 -69
  112. package/coverage/keuss/docusaurus/build/a3732fac.b0f98dbf.js.html +0 -69
  113. package/coverage/keuss/docusaurus/build/a6aa9e1f.6ac55e6c.js.html +0 -69
  114. package/coverage/keuss/docusaurus/build/baf0d4a2.b50efd2d.js.html +0 -69
  115. package/coverage/keuss/docusaurus/build/c4f5d8e4.e9dfd999.js.html +0 -69
  116. package/coverage/keuss/docusaurus/build/ccc49370.1831890b.js.html +0 -69
  117. package/coverage/keuss/docusaurus/build/d4942345.7d23b349.js.html +0 -69
  118. package/coverage/keuss/docusaurus/build/e2244795.4ea3d168.js.html +0 -69
  119. package/coverage/keuss/docusaurus/build/e64fe266.308265e8.js.html +0 -69
  120. package/coverage/keuss/docusaurus/build/f78725cc.5f3e115d.js.html +0 -69
  121. package/coverage/keuss/docusaurus/build/fa8d8063.2312a332.js.html +0 -69
  122. package/coverage/keuss/docusaurus/build/index.html +0 -565
  123. package/coverage/keuss/docusaurus/build/main.66f1008c.js.html +0 -72
  124. package/coverage/keuss/docusaurus/build/runtime~main.7d73b048.js.html +0 -69
  125. package/coverage/keuss/docusaurus/build/styles.b5ee3016.js.html +0 -69
  126. package/coverage/keuss/docusaurus/docusaurus.config.js.html +0 -360
  127. package/coverage/keuss/docusaurus/index.html +0 -110
  128. package/coverage/keuss/docusaurus/sidebars.js.html +0 -96
  129. package/coverage/keuss/docusaurus/src/pages/index.html +0 -97
  130. package/coverage/keuss/docusaurus/src/pages/index.js.html +0 -450
  131. package/coverage/keuss/examples/pipelines/builder/index.html +0 -97
  132. package/coverage/keuss/examples/pipelines/builder/index.js.html +0 -450
  133. package/coverage/keuss/examples/pipelines/simplest/index.html +0 -97
  134. package/coverage/keuss/examples/pipelines/simplest/index.js.html +0 -183
  135. package/coverage/keuss/examples/pipelines/simulation-fork/index.html +0 -97
  136. package/coverage/keuss/examples/pipelines/simulation-fork/index.js.html +0 -414
  137. package/coverage/keuss/examples/snippets/01-simplest-pop-push.js.html +0 -195
  138. package/coverage/keuss/examples/snippets/02-simplest-reserve-rollback-commit.js.html +0 -201
  139. package/coverage/keuss/examples/snippets/03-simplest-producer-consumer-loops.js.html +0 -300
  140. package/coverage/keuss/examples/snippets/04-bucket-mongo-safe-insert-reserve-commit.js.html +0 -303
  141. package/coverage/keuss/examples/snippets/05-insert-reserve-rollback-deadletter.js.html +0 -384
  142. package/coverage/keuss/examples/snippets/06-random-consumer-producer.js.html +0 -879
  143. package/coverage/keuss/examples/snippets/index.html +0 -188
  144. package/coverage/keuss/examples/snippets/redislabs-consumer-producer.js.html +0 -201
  145. package/coverage/keuss/examples/snippets/with-redis-stats-and-signaller-consumer-producer.js.html +0 -222
  146. package/coverage/keuss/examples/webhooks/app.js.html +0 -279
  147. package/coverage/keuss/examples/webhooks/consumer.js.html +0 -363
  148. package/coverage/keuss/examples/webhooks/index.html +0 -123
  149. package/coverage/keuss/examples/webhooks/index.js.html +0 -234
  150. package/coverage/keuss/index.html +0 -149
  151. package/coverage/keuss/playground/index.html +0 -136
  152. package/coverage/keuss/playground/pl-rollback.js.html +0 -234
  153. package/coverage/keuss/playground/pl1.js.html +0 -291
  154. package/coverage/keuss/playground/q1.js.html +0 -168
  155. package/coverage/keuss/playground/simple-pl.js.html +0 -195
  156. package/coverage/keuss/signal/index.html +0 -123
  157. package/coverage/keuss/signal/local.js.html +0 -306
  158. package/coverage/keuss/signal/mongo-capped.js.html +0 -378
  159. package/coverage/keuss/signal/redis-pubsub.js.html +0 -399
  160. package/coverage/keuss/stats/index.html +0 -123
  161. package/coverage/keuss/stats/mem.js.html +0 -519
  162. package/coverage/keuss/stats/mongo.js.html +0 -930
  163. package/coverage/keuss/stats/redis.js.html +0 -894
  164. package/coverage/keuss/utils/RedisConn.js.html +0 -150
  165. package/coverage/keuss/utils/RedisOrderedQueue.js.html +0 -864
  166. package/coverage/keuss/utils/index.html +0 -110
  167. package/coverage/prettify.css +0 -1
  168. package/coverage/prettify.js +0 -2
  169. package/coverage/sort-arrow-sprite.png +0 -0
  170. package/coverage/sorter.js +0 -170
  171. package/docusaurus/README.md +0 -33
  172. package/docusaurus/babel.config.js +0 -3
  173. package/docusaurus/blog/2020-08-04-welcome.md +0 -10
  174. package/docusaurus/docs/about.md +0 -14
  175. package/docusaurus/docs/api/factory.md +0 -102
  176. package/docusaurus/docs/api/queue.md +0 -247
  177. package/docusaurus/docs/api/signal.md +0 -38
  178. package/docusaurus/docs/api/stats.md +0 -37
  179. package/docusaurus/docs/changelog.md +0 -51
  180. package/docusaurus/docs/concepts.md +0 -116
  181. package/docusaurus/docs/examples.md +0 -10
  182. package/docusaurus/docs/quickstart.md +0 -195
  183. package/docusaurus/docs/style-guide.md +0 -202
  184. package/docusaurus/docs/usage/buckets.md +0 -43
  185. package/docusaurus/docs/usage/no-signaller.md +0 -16
  186. package/docusaurus/docs/usage/pipelines/about.md +0 -128
  187. package/docusaurus/docs/usage/pipelines/building.md +0 -158
  188. package/docusaurus/docs/usage/pipelines/examples.md +0 -10
  189. package/docusaurus/docs/usage/pipelines/processors.md +0 -187
  190. package/docusaurus/docs/usage/putting-all-together.md +0 -153
  191. package/docusaurus/docs/usage/redis-conns.md +0 -70
  192. package/docusaurus/docs/usage/shutdown.md +0 -11
  193. package/docusaurus/docusaurus.config.js +0 -96
  194. package/docusaurus/package.json +0 -33
  195. package/docusaurus/sidebars.js +0 -44
  196. package/docusaurus/src/css/custom.css +0 -25
  197. package/docusaurus/src/pages/index.js +0 -127
  198. package/docusaurus/src/pages/styles.module.css +0 -37
  199. package/docusaurus/static/.nojekyll +0 -0
  200. package/docusaurus/static/img/favicon.ico +0 -0
  201. package/docusaurus/static/img/logo.svg +0 -1
  202. package/docusaurus/yarn.lock +0 -8384
@@ -1,247 +0,0 @@
1
- ---
2
- id: queue
3
- title: Queue API
4
- sidebar_label: Queue
5
- ---
6
-
7
- ### `stats`: Queue stats
8
-
9
- ```javascript
10
- q.stats ((err, res) => {
11
- ...
12
- })
13
- ```
14
-
15
- * `res` contains usage statistics (elements inserted, elements extracted, paused status).
16
-
17
- ### `name`: Queue name
18
-
19
- ```javascript
20
- var qname = q.name ()
21
- ```
22
-
23
- ### `type`: Queue type
24
-
25
- ```javascript
26
- var qtype = q.type ()
27
- ```
28
-
29
- Returns a string with the type of the queue (the type of backend which was used to create it).
30
-
31
- ### `size`: Queue occupation
32
-
33
- ```javascript
34
- q.size ((err, res) => {
35
- ...
36
- })
37
- ```
38
-
39
- Returns the number of elements in the queue that are already elligible (that is, excluding scheduled elements with a schedule time in the future).
40
-
41
- ### `totalSize`: Total queue occupation
42
-
43
- ```javascript
44
- q.totalSize ((err, res) => {
45
- ...
46
- })
47
- ```
48
-
49
- Returns the number of elements in the queue (that is, including scheduled elements with a schedule time in the future).
50
-
51
- ### `schedSize`: Size of Scheduled
52
-
53
- ```javascript
54
- q.schedSize ((err, res) => {
55
- ...
56
- })
57
- ```
58
-
59
- Returns the number of scheduled elements in the queue (that is, those with a schedule time in the future). Returns 0 if the queue does not support scheduling.
60
-
61
- ### `resvSize`: Reserved elements size
62
-
63
- ```javascript
64
- q.resvSize ((err, res) => {
65
- ...
66
- })
67
- ```
68
-
69
- Returns the number of reserved elements in the queue. Returns `null` if the queue does not support reserve.
70
-
71
- ### `pause` / `paused`: Pause/Resume
72
-
73
- ```javascript
74
- // pauses the queue
75
- q.pause (true)
76
-
77
- // resumes the queue
78
- q.pause (false)
79
-
80
- // gets paused status of queue
81
- q.paused ((err, is_paused) => {
82
- ...
83
- })
84
- ```
85
-
86
- Pauses/Resumes all consumers on this queue (calls to `pop()`). Producers are not afected (calls to `push()`).
87
-
88
- The pause/resume condition is propagated via the signallers, so this affects all consumers, not only those local to the process, if a redis-pubsub or mongo-capped signaller is used.
89
-
90
- Also, the paused condition is stored as stats, so any new call to `pop()` will honor it.
91
-
92
- ### `next_t`: Time of schedule of next message
93
-
94
- ```javascript
95
- q.next_t ((err, res) => {
96
- ...
97
- })
98
- ```
99
-
100
- Returns a `Date`, or `null` if queue is empty. Queues with no support for schedule/delay always return `null
101
-
102
- ### `push`: Add element to queue
103
-
104
- ```javascript
105
- q.push (payload, [opts,] (err, res) => {
106
- ...
107
- })
108
- ```
109
-
110
- Adds payload to the queue and calls passed callback upon completion. Callback's *res* will contain the id assigned to the inserted element, if the backup provides one.
111
-
112
- `payload` can be an `object`, `array`, `string`, `number` or `Buffer`
113
-
114
- Possible opts:
115
-
116
- * `mature`: unix timestamp where the element would be elligible for extraction. It is guaranteed that the element won't be extracted before this time.
117
- * `delay`: delay in seconds to calculate the mature timestamp, if mature is not provided. For example, a delay=120 guarantees the element won't be extracted until 120 secs have elapsed *at least*.
118
- * `tries`: value to initialize the retry counter, defaults to 0 (still no retries).
119
- * `hdrs`: object with scalar-valued keys (ie, string, number or boolean) to be added alongside the `payload` as general purpose headers
120
-
121
- :::note
122
- **mature** and **delay** have no effect if the backend does not support delay/schedule.
123
- :::
124
-
125
- ### `pop`: Get element from queue
126
-
127
- ```javascript
128
- var tr = q.pop (cid, [opts,] (err, res) => {
129
- ...
130
- })
131
- ```
132
-
133
- Obtains an element from the queue. Callback is called with the element obtained if any, or if an error happened. If defined, the operation will wait for `opts.timeout` seconds for an element to appear in the queue before bailing out (with both `err` and `res` being null). However, it immediately returns an id that can be used to cancel the operation at anytime.
134
-
135
- `*cid*` is an string that identifies the consumer entity; it is used only for debugging purposes.
136
-
137
- Possible opts:
138
-
139
- * **timeout**: milliseconds to wait for an elligible element to appear in the queue to be returned. If not defined it will wait forever
140
- * **reserve**: if `true` the element is only reserved, not completely returned. This means either *ok* or *ko* operations are needed upon the obtained element once processed, otherwise the element will be rolled back (and made available again) at some point in the future (this is only available on backends capable of reserve/commit).
141
-
142
- ### `cancel`: Cancel a pending Pop
143
-
144
- ```javascript
145
- var tr = q.pop (cid, opts, (err, res) => {...});
146
- .
147
- .
148
- .
149
- q.cancel (tr);
150
- ```
151
-
152
- Cancels a pending `pop` operation, identified by the value returned by `pop()`
153
-
154
- If no `tr` param is passed, or it is `null`, all pending `pop` operations on the queue are cancelled. Cancelled `pop` operations will get `'cancel'` (a string) in the `error` parameter value of the callback.
155
-
156
- ### `ok`: Commit a reserved element
157
-
158
- ```javascript
159
- q.ok (id, (err, res) => {
160
- ...
161
- })
162
- ```
163
-
164
- Commits a reserved element by its id (the id would be assigned to `res._id` on the `res` param of `pop()` operation). This effectively erases the element from the queue.
165
-
166
- Alternatively, you can pass the entire `res` object from the `pop()` operation:
167
-
168
- ```javascript
169
- var tr = q.pop ('my-consumer-id', {reserve: true}, (err, res) => {
170
- // do something with res
171
- ...
172
-
173
- // commit it
174
- q.ok (res, (err, res) => {
175
- ...
176
- });
177
- });
178
- ```
179
-
180
- ### `ko`: Roll back a reserved element
181
-
182
- ```javascript
183
- q.ko (id, next_t, (err, res) => {
184
- ...
185
- })
186
- ```
187
-
188
- Rolls back a reserved element by its id (the id would be at `res._id` on the `res` param of `pop()` operation). This effectively makes the element available again at the queue, marking it to be mature at `next_t` (`next_t` being a millsec-unixtime). If no `next_t` is specified or a `null` is passed, `now()` is assumed.
189
-
190
- the `res` param of the callback can take the following values:
191
- * `true` if all went ok and an element was in fact rolled back
192
- * *nullish* if the element does not exist in the queue
193
- * `'deadletter'` (as string) if the rollback resulted in the element being moved to deadletter
194
-
195
- As with `ok()`, you can use the entire `res` object as `id`:
196
-
197
- ```javascript
198
- var tr = q.pop ('my-consumer-id', {reserve: true}, (err, res) => {
199
- // do something with res
200
- ...
201
-
202
- // commit or rollback it
203
- if (succeed) q.ok (res, (err, res) => {
204
- ...
205
- })
206
- else q.ko (res, (err, res) => {
207
- if (res === 'deadletter') {
208
- // moved to deadletter
209
- ...
210
- }
211
- ...
212
- })
213
- });
214
- ```
215
-
216
- :::important
217
- You must pass the entire `res` object for the [deadletter](../api/factory#dead-letter) feature to work; even if activated at the factory, `ko()` will not honor deadletter if you only pass the `res._id` as `id`.
218
- :::
219
-
220
- ### `remove`: Delete elements from queue by id
221
-
222
- ```javascript
223
- q.remove (id, (err, res) => {
224
- ...
225
- })
226
- ```
227
-
228
- Remvoes an element from a queue, by using the id returned at insertion time (backends supporting `remove` will return an in upon insertion). A reserved element can not be removed, and will be considered as nonexistent
229
-
230
- the `res` param of the callback can take the following values:
231
- * `true` if all went ok and the element was removed
232
- * *nullish* if the element does not exist in the queue
233
-
234
- ### `drain`: Drain queue
235
-
236
- ```javascript
237
- q.drain (err => {
238
- ...
239
- })
240
- ```
241
-
242
- Drains a queue. This is a needed operation when a backend does read-ahead upon a `pop()`, or buffers `push()` operations for later; in this case, you may want to be sure that all extra elemens read are actually popped, and all pending pushes are committed.
243
-
244
- :::warning
245
- 'drain' will immediately inhibit `push()`: any call to `push()` will immediately result in a `'drain'` (a string) in the `error` parameter value of the callback. The callback will be called when all pending pushes are committed, and all read-ahead on a pop() has been actually popped.
246
- :::
247
- Also, `drain()` will also call `cancel()` on the queue immediately before finishing, in case of success.
@@ -1,38 +0,0 @@
1
- ---
2
- id: signal
3
- title: Signaller API
4
- sidebar_label: Signaller
5
- ---
6
- ## Signaler factory
7
-
8
- Signaller factory is passed to queues either in queue creation or in backend init, inside *opts.signaller*. Note that the result for the *new* operation is indeed the factory; the result of the `require` is therefore a *metafactory*.
9
-
10
- ```javascript
11
- var signal_redis_pubsub = require ('keuss/signal/redis-pubsub');
12
-
13
- var local_redis_opts = {
14
- Redis: {
15
- port: 6379,
16
- host: 'localhost',
17
- db: 6
18
- }
19
- };
20
-
21
- var f_opts = {
22
- signaller: {
23
- provider: signal_redis_pubsub,
24
- opts: local_redis_opts
25
- }
26
- .
27
- .
28
- .
29
- }
30
-
31
- MQ (f_opts, (err, factory) => {
32
- // queues created by factory here will use a redis pubsub signaller, hosted at redis at localhost, db 6
33
- })
34
- ```
35
-
36
- :::note
37
- The signaller has no public api *per se*; it is considered just a piece of infrastructure to glue queues together.
38
- :::
@@ -1,37 +0,0 @@
1
- ---
2
- id: stats
3
- title: Stats API
4
- sidebar_label: Stats
5
- ---
6
-
7
- ## Stats factories
8
-
9
- Stats factories are passed to queues either in queue creation or in backend init, inside *opts.signaller*. Note that the result of the `new` operation is indeed the factory; the result of the `require` is therefore a *metafactory*
10
-
11
- ```javascript
12
- var local_redis_pubsub = require ('keuss/signal/redis-pubsub');
13
-
14
- var local_redis_opts = {
15
- Redis: {
16
- port: 6379,
17
- host: 'localhost',
18
- db: 6
19
- }
20
- };
21
-
22
- var f_opts = {
23
- stats: {
24
- provider: signal_redis_pubsub,
25
- opts: local_redis_opts
26
- }
27
- .
28
- .
29
- .
30
- }
31
-
32
- MQ (f_opts, (err, factory) => {
33
- // queues created by factory here will use a redis-backed stats, hosted at redis at localhost, db 6
34
- })
35
- ```
36
-
37
- Stats objects, as of now, store the number of elements inserted and the number of elements extracted; they are created behind the scenes and tied to queue instances, and the stats-related interface is in fact part of the queues' interface.
@@ -1,51 +0,0 @@
1
- ---
2
- id: changelog
3
- title: Changelog
4
- sidebar_label: Changelog
5
- ---
6
- * v1.6.10
7
- * updated deps
8
- * add 'deadletter' to stats, for elements moved to deadletter queue
9
- * v1.6.9
10
- * fix glitch in remove item on tape mongo (ps-mongo)
11
- * v1.6.8
12
- * added remove-by-id support
13
- * v1.6.7
14
- * small fix on deadetter signalling
15
- * v1.6.6
16
- * added reserve, commit, rollback counters to stats
17
- * fixed mongo-driver deprecation
18
- * v1.6.5
19
- * dependencies updated
20
- * v1.6.4
21
- * dependencies updated
22
- * v1.6.3
23
- * added support for headers (along with payload)
24
- * v1.6.2
25
- * payload can be of type object, string, number of buffer
26
- * v1.6.1
27
- * added Docusaurus based documentation
28
- * fixed deps' vulnerabilities
29
- * v1.6.0
30
- * added sane defaults for stats and signal for mongodb-based backends (using mongo stats and signal)
31
- * added pipeline builder
32
- * added ability to create a full pipeline from text (making it trivial to be stored in file)
33
- * v1.5.12
34
- * corrected small pipeline-related issues
35
- * v1.5.11 (void)
36
- * v1.5.10
37
- * pipelines overhaul
38
- * mubsub change to @nodebb/mubsub
39
- * v1.5.9:
40
- * added some complete, meaningful examples
41
- * v1.5.8
42
- * added deadletter support
43
- * v1.5.7
44
- * added resvSize support
45
- * v1.5.4:
46
- * added pause support
47
- * deps updated
48
- * v1.5.3:
49
- * use mongodb driver v3.2 (was v2.2)
50
- * v1.5.2
51
- * added bucket-based backends: 2 backends using buckets/buffering on top of mongodb
@@ -1,116 +0,0 @@
1
- ---
2
- id: concepts
3
- title: Concepts
4
- sidebar_label: Concepts
5
- ---
6
-
7
- ## Queue
8
-
9
- A **Queue** is more of an interface, a definition of what it can do. Keuss queues are capable of:
10
-
11
- * Insert one element.
12
- * Schedule an element: insert one element with a not-before datetime; this means, the element will be affectively inserted in the queue, but any operation on the queue ofter that will not take that element into account before the not-before datetime.
13
- * Get an element, and block for some specified time if no element is available.
14
- * Reserve an element, and block for some specified time if no element is available.
15
- * Commit (remove) or rollback (return back) a previously reserved element.
16
- * Remove an element by its id (which was returned in the insertion)
17
- * Get element count (it will not include the elements scheduled in the future).
18
- * Get element count whose not-before datetime is in the future (scheduled elements).
19
- * Get usage stats: elements inserted, elements extracted.
20
-
21
- *Element* here translates to any js object, js array, string, number or `Buffer`. Optionally, a set of headers (in the form of a js object with string, number or boolean values) can be added.
22
-
23
- ## Bucket
24
-
25
- The initial idea for Keuss Queues, transtated the elements inserted in the queue into rows of the backed storage. This makes it easy to inspect the elements values directly in the backend, which is pretty useful when you need to debug things up. Buckets came later, as a way to pack more than one message into a single row of the backend to gain performance. See [Bucked-based backends](usage/buckets).
26
-
27
- ## Pipeline
28
-
29
- A **[pipeline](usage/pipelines/about)** is an enhanced queue that provides an extra operation: pass an element to another queue **atomically**. In an scenario where processors are linked with queues, it is usually a good feature to allow the *'commit element in incoming queue, insert element in the next queue'* to be atomic. This removes chances for race conditions, or message losses.
30
-
31
- The pipeline concept is, indeed, an extension of the reserve-commit model; it is so far implemented only atop mongodb, and it is anyway considered as a 'low-level' feature, best used by means of specialized classes to encapsulate the aforementioned processors.
32
-
33
- ## Processor
34
-
35
- A **processor** is an object tied to one or more queues, that controls the flow of messages between them. They are used mainly to define [**pipelines**](usage/pipelines/about). Currently there are 4 specialized classes of processors defined:
36
-
37
- * [BaseLink](usage/pipelines/processors#baselink): This is really more of a base definition for the rest of the specialized processors.
38
- * [DirectLink](usage/pipelines/processors#directlink) (one queue to another).
39
- * [ChoiceLink](usage/pipelines/processors#choicelink) (one queue to one or more queues).
40
- * [Sink](usage/pipelines/processors#sink) (endpoint, one queue to none).
41
-
42
- ## Storage
43
-
44
- The **Storage** or **Backend** provides almost-complete queue primitives, fully functional and already usable as is. Keuss comes with 7 backends, with various levels of features and performance:
45
-
46
- * *`mongo`*, a mongodb-based backend that provides the full set of queue features, still with decent performance.
47
- * *`redis-oq`*, backed using an ordered queue on top of redis (made in turn with a sorted set, a hash and some lua). Provides all queue features including reserve-commit-rollback. Noticeable faster than mongodb.
48
- * *`redis-list`*, backed using a redis list. Does not offer reserve-commit-rollback nor the ability to schedule, but is much faster than redis-oq
49
- * *`pl-mongo`*, a version of the *`mongo`* backend that provides pipelining capabilities (the queues it produces are also pipelines).
50
- * *`ps-mongo`*, a version of the *`mongo`* backend where elements are not physically deleted from the collection when extracted; instead, they are just marked as processed and later deleted automatically using a mongodb TTL index.
51
- * *`bucket-mongo`*, a first attepmt on storing more than one element on each mongodb record in order to break past mongodb I/O limitations. It is very simple, lacking schedule and reserve support. However, it has staggering throughput on a reasonable durability.
52
- * *`bucket-mongo-safe`*, an evolution of *`bucket-mongo`*, provides both scheduling and reserve support with a performance only a bit below *`bucket-mongo`*.
53
-
54
- As mentioned before, persistence and High Availability (HA) depends exclusively on the underliying system: mongodb provides production-grade HA and persistence while using potentially gigantic queues, and with redis one can balance performance and simplicity over reliability and durability, by using standalone redis, redis sentinel or redis cluster. Keuss uses [ioredis](https://github.com/luin/ioredis) as redis driver, which supports all 3 cases.
55
-
56
- The following table shows the capabilities of each backend:
57
-
58
- backend | delay/schedule | reserve/commit | pipelining | history | remove | throughput |
59
- ------------------|:--------------:|:--------------:|:----------:|:-------:|:------:|:----------:|
60
- redis-list | - | - | - | - | - | ++++
61
- redis-oq | x | x | - | - | x | +++
62
- mongo | x | x | - | - | x | ++
63
- pl-mongo | x | x | x | - | x | +
64
- ps-mongo | x | x | - | x | x | ++
65
- bucket-mongo | - | - | - | - | - | +++++
66
- bucket-mongo-safe | x | x | - | - | x | +++++
67
-
68
- ## Signaller
69
-
70
- **Signaller** provides a bus interconnecting all keuss clients, so events can be shared. Keuss provides 3 signallers:
71
-
72
- * *`local`* : provides in-proccess messaging, useful only for simple cases or testing
73
- * *`redis-pubsub`*: uses the pubsub subsystem provided by redis
74
- * *`mongo-capped`*: uses pubsub on top of a mongodb capped collection, using [@nodebb/mubsub](https://www.npmjs.com/package/@nodebb/mubsub)
75
-
76
- So far, the only events published by keuss are:
77
-
78
- * *element inserted in queue X*, which allows other clients waiting for elements to be available to wake up and retry. A client will not fire an event if
79
- another one of the same type (same client, same queue) was already fired less than 50ms ago.
80
- * *queue X paused/resumed*.
81
-
82
- The use of a signaller provider different from `local` allows the formation of a cluster of clients: all those clients sharing the same signaller object
83
- (with the same configuration, obviously) will see and share the same set of events and therefore can collaborate (for example, all consumers of a given
84
- queue *on every machine* will be awaken when an insertion happens *on any machine*)
85
-
86
- ## Stats
87
-
88
- **Stats** provides counters and metrics on queues, shared among keuss clients. The supported stats are:
89
-
90
- * Elements put
91
- * Elements got
92
- * Elements reserved
93
- * Elements committed
94
- * Elements rolled back
95
- * Paused status
96
-
97
- Three options are provided to store the stats:
98
-
99
- * *`mem`*: very simple in-process, memory based.
100
- * *`redis`*: backed by redis hashes. Modifications are buffered in memory and flushed every 100ms.
101
- * *`mongo`*: backed by mongodb using one object per queue inside a single collection. Modifications are buffered in memory and flushed every 100ms.
102
-
103
- The use of a stats provider different from `mem` allows for a shared view of a cluster of clients: all those clients sharing the same stats object
104
- (with the same configuration, obviously) will see a coherent, aggregated view of the stats (all clients will update the stats)
105
-
106
- The stats can also be used as a queue discovery source: existing queues can be recreated from the information stored (in fact, extra information
107
- needed to ensure this is also stored alongside the actual stats). Keuss does not, at this point, provide any actual *recreate* functionality on
108
- top of this
109
-
110
- ## How all fits together
111
-
112
- * *`Queues`*, or rather clients to individual queues, are created using a *backend* as factory.
113
- * *`Backends`* need to be initialized before being used. Exact initialization details depend on each backend.
114
- * When creating a *`queue`*, a *`signaller`* and a *`stats`* are assigned to it. The actual class/type to be used can be specified at the queue's creation moment, or at the backend initialization moment. By default *`local`* and *`mem`*, respectively, are used for redis-based backends; for mongodb-based backends, *`mongo-capped`* and *`mongo`* are used intead as defaults
115
- * *`Queues`* are created on-demand, and are never destroyed as far as Keuss is concerned. They do exist as long as the underlying backend kepts them in existence: for example, redis queues dissapear as such when they become empty.
116
- * *`Pipelines`* are, strictly speaking, just enhanced queues; as such they behave and can be used as a queue. More info on pipelines [here](usage/pipelines/about)
@@ -1,10 +0,0 @@
1
- ---
2
- id: examples
3
- title: Examples
4
- sidebar_label: Examples
5
- ---
6
-
7
- A set of funcioning examples can be found inside the *examples* directory:
8
-
9
- * [webhooks](https://github.com/pepmartinez/keuss/tree/master/examples/webhooks): A small but functionally complete webhook dispatcher sporting retries, reserve-commit, persistence and deadletter
10
- * [snippets](https://github.com/pepmartinez/keuss/tree/master/examples/snippets): A set of assorted code snippets for various tasks