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,195 +0,0 @@
1
- ---
2
- id: quickstart
3
- title: Quickstart
4
- sidebar_label: Quickstart
5
- ---
6
-
7
- ## Package Install
8
-
9
- `keuss` is installed in the regular way for any npm package:
10
-
11
- ```bash
12
- npm install keuss
13
- ```
14
-
15
- ## Basic usage (with regular MongoDB backend)
16
-
17
- Here's a minimal example of how keuss works. [async](https://www.npmjs.com/package/async) is used to implement asynchronous flows in a much readable manner
18
-
19
- ```javascript
20
- const async = require ('async');
21
- const MQ = require ('keuss/backends/mongo');
22
-
23
- MQ ({
24
- url: 'mongodb://localhost/keuss_test'
25
- }, (err, factory) => {
26
- if (err) return console.error(err);
27
-
28
- // factory ready, create one queue
29
- const q = factory.queue ('test_queue', {});
30
-
31
- async.series([
32
- cb => q.push (
33
- {elem: 1, headline: 'something something', tags: {a: 1, b: 2}}, // this is the payload
34
- {
35
- hdrs: {h1: 'aaa', h2: 12, h3: false} // let's add some headers too
36
- },
37
- cb
38
- ),
39
- cb => q.pop ('consumer-1', cb)
40
- ], (err, res) => {
41
- if (err) {
42
- console.error (err);
43
- }
44
- else {
45
- console.log (res[1]);
46
- // this should print something like:
47
- // {
48
- // _id: <some id>,
49
- // mature: <some date>,
50
- // payload: { elem: 1, headline: 'something something', tags: { a: 1, b: 2 } },
51
- // tries: 0,
52
- // hdrs: {h1: 'aaa', h2: 12, h3: false}
53
- // }
54
- }
55
-
56
- factory.close ();
57
- });
58
- });
59
- ```
60
-
61
- This small test creates a queue named `test_queue` backed by mongodb in the mongoDB collection at `mongodb://localhost/keuss_test`. Then, a single element is first inserted in the queue, then read from it and printed
62
-
63
- ## Backend interchangeability
64
-
65
- This example works with any available definition of `MQ`; you just need to specify the chosen backend. For example, to use the `redis-list` backend:
66
-
67
- ```js
68
- const MQ = require ('keuss/backends/redis-list');
69
- ```
70
-
71
- ## reserve-commit-rollback
72
-
73
- ```javascript
74
- const async = require ('async');
75
- const MQ = require ('keuss/backends/mongo');
76
-
77
- MQ ({
78
- url: 'mongodb://localhost/keuss_test'
79
- }, (err, factory) => {
80
- if (err) return console.error(err);
81
-
82
- // factory ready, create one queue
83
- const q = factory.queue ('test_queue', {});
84
-
85
- async.waterfall ([
86
- cb => q.push ({elem: 1, headline: 'something something', tags: {a: 1, b: 2}}, cb), // (1)
87
- (item_id, cb) => q.pop ('consumer-1', {reserve: true}, cb), // (2)
88
- (item, cb) => {
89
- console.log ('%s: got %o', new Date().toString (), item); // (3)
90
- const next_t = new Date().getTime () + 1500;
91
- q.ko (item, next_t, cb); // (4)
92
- },
93
- (ko_res, cb) => q.pop ('consumer-1', {reserve: true}, cb), // (5)
94
- (item, cb) => {
95
- console.log ('%s: got %o', new Date().toString (), item); // (6)
96
- q.ok (item, cb); // (7)
97
- },
98
- ], (err, res) => {
99
- if (err) console.error (err);
100
- factory.close ();
101
- });
102
- });
103
- ```
104
-
105
- 1. An element is inserted.
106
- 2. An element is reserved. It reserves the element previously inserted, and returns it.
107
- 3. This should print the element reserved.
108
- 4. The element reserved is rejected, indicating that it should not be made available until `now + 1500` millisecs.
109
- 5. A second attempt at a reserve, this should return an element after 1500 millisecs.
110
- 6. The same element should be printed here, except for the `tries` that should be `1` instead of `0`.
111
- 7. The element is committed and thus removed from the queue.
112
-
113
- ## Backend interchangeability
114
-
115
- This example works with any definition of `MQ` that supports reserve/commit (that is, any except `redis-list` and `bucket-mongo`); you just need to specify the chosen backend. For example, to use the `bucket-mongo-safe` backend:
116
-
117
- ```js
118
- const MQ = require ('keuss/backends/bucket-mongo-safe');
119
- ```
120
-
121
- ## Full producer and consumer loops
122
-
123
- This is a more convoluted example: a set of producers inserting messages, and another set of consumers consumig them, all in parallel. The queue stats (elements pushed, elements popped) are shown every second.
124
-
125
- Try and change the uncommented `const MQ = require('keuss/backends/...');` to see the performance differences between backends.
126
-
127
- Also, notice that, when, running with any mongodb-based backend, stats figures are cumulative across different executions: if you run it several times, you'll see the stats' figures also include data from previous executions.
128
-
129
- ```js
130
- const async = require ('async');
131
-
132
- // choice of backend
133
- const MQ = require ('keuss/backends/bucket-mongo-safe');
134
- //const MQ = require ('keuss/backends/redis-oq');
135
- //const MQ = require ('keuss/backends/mongo');
136
- //const MQ = require ('keuss/backends/ps-mongo');
137
-
138
- MQ ({
139
- url: 'mongodb://localhost/keuss_test'
140
- }, (err, factory) => {
141
- if (err) return console.error(err);
142
-
143
- const consumers = 3;
144
- const producers = 3;
145
- const msgs = 100000;
146
-
147
- // factory ready, create one queue
148
- const q = factory.queue ('test_queue', {});
149
-
150
- // show stats every sec
151
- const timer = setInterval (() => {
152
- q.stats ((err, res) => console.log (' --> stats now: %o', res));
153
- }, 1000);
154
-
155
- async.parallel ([
156
- // producers' loop
157
- cb => async.timesLimit (msgs, producers, (n, next) => {
158
- q.push ({elem: n, headline: 'something something', tags: {a: 1, b: 2}}, next);
159
- }, err => {
160
- console.log ('producer loop ended');
161
- cb (err);
162
- }),
163
- // consumers' loop
164
- cb => async.timesLimit (msgs, consumers, (n, next) => {
165
- q.pop ('theconsumer', {reserve: true}, (err, item) => {
166
- if (err) return cb (err);
167
- q.ok (item, next);
168
- });
169
- }, err => {
170
- console.log ('consumer loop ended');
171
- cb (err);
172
- })
173
- ], err => {
174
- if (err) return console.error (err);
175
-
176
- clearInterval (timer);
177
-
178
- // all loops completed, cleanup & show stats
179
- async.series ([
180
- cb => q.drain (cb),
181
- cb => q.stats (cb),
182
- cb => setTimeout (cb, 1000),
183
- cb => q.stats (cb),
184
- ], (err, res) => {
185
- if (err) console.error (err);
186
- else {
187
- console.log ('stats right after drain: %o', res[1]);
188
- console.log ('stats once dust settled: %o', res[3]);
189
- }
190
-
191
- factory.close ();
192
- });
193
- });
194
- });
195
- ```
@@ -1,202 +0,0 @@
1
- ---
2
- id: doc1
3
- title: Style Guide
4
- sidebar_label: Style Guide
5
- ---
6
-
7
- You can write content using [GitHub-flavored Markdown syntax](https://github.github.com/gfm/).
8
-
9
- ## Markdown Syntax
10
-
11
- To serve as an example page when styling markdown based Docusaurus sites.
12
-
13
- ## Headers
14
-
15
- # H1 - Create the best documentation
16
-
17
- ## H2 - Create the best documentation
18
-
19
- ### H3 - Create the best documentation
20
-
21
- #### H4 - Create the best documentation
22
-
23
- ##### H5 - Create the best documentation
24
-
25
- ###### H6 - Create the best documentation
26
-
27
- ---
28
-
29
- ## Emphasis
30
-
31
- Emphasis, aka italics, with *asterisks* or _underscores_.
32
-
33
- Strong emphasis, aka bold, with **asterisks** or __underscores__.
34
-
35
- Combined emphasis with **asterisks and _underscores_**.
36
-
37
- Strikethrough uses two tildes. ~~Scratch this.~~
38
-
39
- ---
40
-
41
- ## Lists
42
-
43
- 1. First ordered list item
44
- 1. Another item
45
- - Unordered sub-list.
46
- 1. Actual numbers don't matter, just that it's a number
47
- 1. Ordered sub-list
48
- 1. And another item.
49
-
50
- * Unordered list can use asterisks
51
-
52
- - Or minuses
53
-
54
- + Or pluses
55
-
56
- ---
57
-
58
- ## Links
59
-
60
- [I'm an inline-style link](https://www.google.com/)
61
-
62
- [I'm an inline-style link with title](https://www.google.com/ "Google's Homepage")
63
-
64
- [I'm a reference-style link][arbitrary case-insensitive reference text]
65
-
66
- [You can use numbers for reference-style link definitions][1]
67
-
68
- Or leave it empty and use the [link text itself].
69
-
70
- URLs and URLs in angle brackets will automatically get turned into links. http://www.example.com/ or <http://www.example.com/> and sometimes example.com (but not on GitHub, for example).
71
-
72
- Some text to show that the reference links can follow later.
73
-
74
- [arbitrary case-insensitive reference text]: https://www.mozilla.org/
75
- [1]: http://slashdot.org/
76
- [link text itself]: http://www.reddit.com/
77
-
78
- ---
79
-
80
- ## Images
81
-
82
- Here's our logo (hover to see the title text):
83
-
84
- Inline-style: ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 'Logo Title Text 1')
85
-
86
- Reference-style: ![alt text][logo]
87
-
88
- [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png 'Logo Title Text 2'
89
-
90
- Images from any folder can be used by providing path to file. Path should be relative to markdown file.
91
-
92
- ![img](../static/img/logo.svg)
93
-
94
- ---
95
-
96
- ## Code
97
-
98
- ```javascript
99
- var s = 'JavaScript syntax highlighting';
100
- alert(s);
101
- ```
102
-
103
- ```python
104
- s = "Python syntax highlighting"
105
- print(s)
106
- ```
107
-
108
- ```
109
- No language indicated, so no syntax highlighting.
110
- But let's throw in a <b>tag</b>.
111
- ```
112
-
113
- ```js {2}
114
- function highlightMe() {
115
- console.log('This line can be highlighted!');
116
- }
117
- ```
118
-
119
- ---
120
-
121
- ## Tables
122
-
123
- Colons can be used to align columns.
124
-
125
- | Tables | Are | Cool |
126
- | ------------- | :-----------: | -----: |
127
- | col 3 is | right-aligned | \$1600 |
128
- | col 2 is | centered | \$12 |
129
- | zebra stripes | are neat | \$1 |
130
-
131
- There must be at least 3 dashes separating each header cell. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
132
-
133
- | Markdown | Less | Pretty |
134
- | -------- | --------- | ---------- |
135
- | _Still_ | `renders` | **nicely** |
136
- | 1 | 2 | 3 |
137
-
138
- ---
139
-
140
- ## Blockquotes
141
-
142
- > Blockquotes are very handy in email to emulate reply text. This line is part of the same quote.
143
-
144
- Quote break.
145
-
146
- > This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote.
147
-
148
- ---
149
-
150
- ## Inline HTML
151
-
152
- <dl>
153
- <dt>Definition list</dt>
154
- <dd>Is something people use sometimes.</dd>
155
-
156
- <dt>Markdown in HTML</dt>
157
- <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
158
- </dl>
159
-
160
- ---
161
-
162
- ## Line Breaks
163
-
164
- Here's a line for us to start with.
165
-
166
- This line is separated from the one above by two newlines, so it will be a _separate paragraph_.
167
-
168
- This line is also a separate paragraph, but... This line is only separated by a single newline, so it's a separate line in the _same paragraph_.
169
-
170
- ---
171
-
172
- ## Admonitions
173
-
174
- :::note
175
-
176
- This is a note
177
-
178
- :::
179
-
180
- :::tip
181
-
182
- This is a tip
183
-
184
- :::
185
-
186
- :::important
187
-
188
- This is important
189
-
190
- :::
191
-
192
- :::caution
193
-
194
- This is a caution
195
-
196
- :::
197
-
198
- :::warning
199
-
200
- This is a warning
201
-
202
- :::
@@ -1,43 +0,0 @@
1
- ---
2
- id: buckets
3
- title: Bucket-based backends
4
- sidebar_label: Bucket-based backends
5
- ---
6
-
7
- Up to version 1.4.X all backends worked in the same way, one element at a time: pushing and popping elements fired one or more operations per element on the underlying storage. This means the bottleneck would end up being the storage's I/O; redis and mongo both allow quite high I/O rates, enough to work at thousands of operations per second. Still, the limit was there.
8
-
9
- Starting with v1.5.2 keuss includes 2 backends that do not share this limitation: they work by packing many elements inside a single 'storage unit'. Sure enough, this adds some complexity and extra risks, but the throughput improvement is staggering: on mongodb it goes from 3-4 Ktps to 35-40Ktps, and the bottleneck shifted from mongod to the client's cpu, busy serializing and deserializing payloads.
10
-
11
- Two bucked-based backends were added, both based on mongodb: [bucket-mongo](#bucket-mongo) and [bucket-mongo-safe](#bucket-mongo-safe). Both are usable, but there is little gain on using fhe first over the second: `bucket-mongo` was used as a prototyping area, and although perfectly usable, it turned out `bucket-mongo-safe` is better in almost every aspect: it provides better guarantees and more features, at about the same performance.
12
-
13
- ### bucket-mongo-safe
14
-
15
- In addition to the general options, the factory accepts the following extra options:
16
-
17
- * `bucket_max_size`: maximum number of elements in a bucket, defaults to 1024
18
- * `bucket_max_wait`: milliseconds to wait before flushing a push bucket: pushes are buffered in a push bucket, which are flushed when they're full (reach `bucket_max_size` elements). If this amount of millisecs go by and the push bucket is not yet full, it is flushed as is. Defaults to 500.
19
- * `reserve_delay`: number of seconds a bucket keeps its 'reserved' status when read from mongodb. Defaults to 30.
20
- * `state_flush_period`: changes in state on each active/read bucket are flushed to mongodb every those milliseconds. Defaults to 500.
21
- * `reject_delta_base`, `reject_delta_factor`: if no call to `ko` provide a `next_t`, the backend will set one using a simple grade-1 polynom, in the form of `reject_delta_factor * tries + reject_delta_base`, in millisecs. They default to `10000` and `((reserve_delay * 1000) || 30000)` respectively
22
- * `reject_timeout_grace`: number of seconds to wait since a bucket is reserved/read until it is considered timed out; after this, what is left of the bucket is rejected/retried. Defaults to (`reserve_delay` * `0.8`)
23
- * `state_flush_period`: flush intermediate state changes in each active read bucked every this amount of millisecs
24
-
25
- Bucket-mongo-safe works by packing many payloads in a single mongodb object:
26
-
27
- * At `push()` time, objects are buffered in memory and pushed (inserted) only when bucket_max_size has been reached or when a bucket has been getting filled for longer than bucket_max_wait millisecs.
28
- * At `pop/reserve` time full objects are read into mem, and then individual payloads returned from there. Both commits and pops are just marked in memory and then flushed every state_flush_period millisecs, or when the bucked is exhausted.
29
- * Buckets remain unmodified since they are created in terms of the payloads they contain: a `pop()` or `ko/ok` would only mark payloads inside buckets as read/not-anymore-available, but buckets are never splitted nor merged.
30
-
31
- Thus, it is important to call `drain()` on queues of this backend: this call ensures all pending write buckets are interted in mongodb, and also ensures all in-memory buckets left are completely read (served through pop/reserve).
32
-
33
- Also, there is little difference in performance and I/O between `pop` and `reserve/commit`; performance is no longer a reason to prefer one over the other.
34
-
35
- :::note
36
- Scheduling on `bucket-mongo-safe` is perfectly possible, but with a twist: the effective `mature_t` of a message will be the oldest in the whole bucket it resides in. This applies to both insert and rollback/ko. In practice this is usually not a big deal, since anyway the `mature_t` is a 'not before' time, and that's all Keuss (or any other queuing middleware) would guarantee.
37
- :::
38
-
39
- ### bucket-mongo
40
-
41
- This is a simpler version of buckets-on-mongodb, and for all purposes `bucket-mongo-safe` should be preferred; it does not provide reserve, nor schedule. It is however a tad faster and lighter on I/O.
42
-
43
- It is provided only for historical and educational purposes.
@@ -1,16 +0,0 @@
1
- ---
2
- id: no-signaller
3
- title: Using no signaller
4
- sidebar_label: Using no signaller
5
- ---
6
-
7
- Even when using signallers, `pop` operations on queue never block or wait forever; waiting `pop` operations are anyway terminated after 15000 millisecs
8
- or whatever specified in the `pollInterval` parameter) and silently re-initiated. That is, a `pop()` on an empty queue will appear blocked forever to
9
- the caller, but behind the scenes it'll work pretty much as if it were doing a poll every 15 secs
10
-
11
- If a signaller is used (or if a signaller other than `local` is used, if `push()` and `pop()` happen on different machines) the `pop()` will be awaken almost
12
- immediately after the `push()`; if no signaller is used (or `local`is used, but the action happens in separated machines) `pop()` will behave exactly as if
13
- it were doing a poll() internally;
14
-
15
- Another way to put it is, `pop()` operations would have a maximum latency of `pollInterval` millisecs, but also provides a safe backup in the event of
16
- signalling loss.
@@ -1,128 +0,0 @@
1
- ---
2
- id: about
3
- title: About
4
- sidebar_label: About
5
- ---
6
-
7
- `Pipelines` is a Keuss extension for building [ETL](https://en.wikipedia.org/wiki/Extract,_transform,_load) processing graphs with ease while guaranteeing atomicity in the processing: whatever happens at the processing of an element, the element is guaranteed to be in either the source or in the destination queue; never in both, never in none.
8
-
9
- Keuss pipelines are build upon Keuss Queues with *pipeline* capacity, which means Pipelines inherit all their advantages in terms of HA, durability and performance. So far, Keuss offers only one Queue backend with pipeline capacity, `pl-mongo`
10
-
11
- Queues are linked together with processing units named *Processors*, which glue together a source queue with zero or more destination queues. Each processor encapsulates a loop that could be described -in its simplest form- as follows:
12
-
13
- ```javascript
14
- forever do
15
- src_queue.reserve () -> element # reserve an element from entry queue
16
- process (element) -> err, res # process the element
17
-
18
- if (err) then
19
- if (err.drop) do # error tells processor to drop/ignore the element
20
- src_queue.commit (element)
21
- else do
22
- src_queue.rollback (element) # regular error, rollback. It would be retried
23
- end
24
- else
25
- if (res.drop) do # processed ok, but drop the item anyway
26
- src_queue.commit (element)
27
- else do
28
- # commit on entry queue and insert into the exit queue, all in one atomic operation
29
- # modifications in the payload are conserved
30
- move_to_next_queue (element, src_queue)
31
- end
32
- end
33
-
34
- next_loop
35
- end
36
- ```
37
-
38
- * The `process()` part is user-provided, passed as a function on the initialization of the processor
39
- * The exact semantics of `move_to_next_queue()` vary depending on the specific type of Processor chosen
40
-
41
- ## Real, simple example
42
-
43
- Here is the simplest possible example: 2 queues connected with a very simple processor. Elements in the source queue are taken, a `passed: true` is added to them and moved to the next queue:
44
-
45
- ```javascript
46
- const MQ = require ('keuss/backends/pl-mongo');
47
- const PDL = require ('keuss/Pipeline/DirectLink');
48
- const async = require ('async');
49
-
50
- const factory_opts = {
51
- url: 'mongodb://localhost/qeus'
52
- };
53
-
54
- // initialize factory
55
- MQ (factory_opts, (err, factory) => {
56
- if (err) return console.error (err);
57
-
58
- // factory ready, create 2 queues on default pipeline
59
- const q_opts = {};
60
- const q1 = factory.queue ('test_pl_1', q_opts);
61
- const q2 = factory.queue ('test_pl_2', q_opts);
62
-
63
- // tie them up, q1 -> q2
64
- const pdl = new PDL (q1, q2);
65
-
66
- pdl.start ((elem, done) => {
67
- // pass element to next queue, set payload.passed to true
68
- done (null, {
69
- update: {
70
- $set: {passed: true}
71
- }
72
- });
73
- });
74
-
75
- // insert elements in the entry queue
76
- async.timesLimit (111, 3, (n, next) => q1.push ({a:n, b:'see it spin...'}, next));
77
-
78
- // read elements at the outer end
79
- async.timesLimit (111, 3, (n, next) => q2.pop ('exit', (err, res) => {
80
- console.log ('end point get', res);
81
- next ();
82
- }));
83
- });
84
- ```
85
-
86
- just run this example and you'll see 111 elements being inserted at q1, being processed at the pdl processor, and then popped from q2
87
-
88
- ## Pipeline-aware Queues
89
-
90
- As stated before only one Keuss Queue backed -`pl-mongo`- is compatible with pipelines. Those are the pipeline-related options available at the backend:
91
-
92
- * `pipeline`: specifies the pipeline name for this queue. Only queues within the same pipeline (that is, same mongodb url and same pipeline name) can actually work together in a pipeline. Defaults to `default`
93
-
94
- In the above example both queues q1 and q2 are created in a pipeline named 'default'. To use a different one you just change the code into:
95
-
96
- ```javascript
97
- const q_opts = {pipeline: 'some_other_pipeline'};
98
- const q1 = factory.queue ('test_pl_1', q_opts);
99
- const q2 = factory.queue ('test_pl_2', q_opts);
100
- ```
101
-
102
- Also, pipeline-aware queues provide a new operation:
103
-
104
- ```javascript
105
- pl_step (id, next_queue, opts, callback)
106
- ```
107
-
108
- * `id` is a previously reserved Id
109
- * `next_queue` is the queue to (atomically) move the item to
110
- * `opts` are extra options for the operation:
111
- * `mature`: Date instance with the not-before timestamp for the item, to be used when inserted into `next_queue`. Defaults to `now()`
112
- * `tries`: number of tries for the item, to be used when inserted into next_queue. Defaults to `0`
113
- * `payload`: if specified, use this as item's payload when moving to next_queue. This totally substitutes the previous payload
114
- * `update`: Optional object containing [mongodb update operations](https://docs.mongodb.com/manual/reference/operator/update/). Those are mapped to be applied to the message's `payload`. For example, in the example above:
115
-
116
- ```javascript
117
- done (null, {
118
- update: {
119
- $set: {passed: true}
120
- }
121
- });
122
- ```
123
-
124
- the '`update` parameter of the second argument to `done()` is passed internally to `pl_step()` as `opts.update`: this would cause the message's `payload.passed` to be set to `true` even if there's no explicit mention of `payload`
125
-
126
- The whole `pl_step()` operation is guaranteed to be atomic; this includes applying of `opts.payload` or `opts.update` if present
127
-
128
- Also, `opts.payload` takes precedence over `opts.update`: if both are specified only the former is taken into account, and the latter is totally ignored