@@ -13,42 +13,11 @@ The Pop-up store is using [Redis Streams](https://redis.io/topics/streams-intro)
1313
1414- Node.js script adds random data to Customers and Orders streams
1515- RedisGears is using ` StreamReader ` to watch all ` queue: ` keys and adding Time-Series samples
16-
17- ```
18- # Add Time-Series
19- def tsAdd(x):
20- xlen = execute('XLEN', x['key'])
21- execute('TS.ADD', 'ts:len:'+x['key'], '*', xlen)
22- execute('TS.ADD', 'ts:enqueue:' + x['key'], '*', x['value'])
23-
24-
25- # Stream Reader for any Queue
26- gb = GearsBuilder('StreamReader')
27- gb.countby(lambda x: x['key']).map(tsAdd)
28- gb.register(prefix='queue:*', duration=5000, batch=10000, trimStream=False)
29- ```
30-
3116- Another RedisGears script completes orders
3217 - adding data to ` queue:complete ` stream
3318 - deleting client's ordering
3419 - decreasing product amount
3520 - trimming Orders queue
36-
37- ```
38- # Complete order
39- def complete(x):
40- execute('XADD', 'queue:complete', '*', 'order', x['id'],
41- 'customer', x['value']['customer'])
42- execute('XDEL', 'queue:customers', x['value']['customer'])
43- execute('DECR', 'product')
44-
45-
46- # Stream Reader for Orders queue
47- gb = GearsBuilder('StreamReader')
48- gb.map(complete)
49- gb.register(prefix='queue:orders', batch=3, trimStream=True)
50- ```
51-
5221- Grafana query streams and Time-Series keys every 5 seconds to display samples using Grafana plugins.
5322
5423## Demo
@@ -63,28 +32,12 @@ Demo is available on [demo.volkovlabs.io](https://demo.volkovlabs.io):
6332- [ Docker] ( https://docker.com ) to start Redis and Grafana.
6433- [ Node.js] ( https://nodejs.org ) to run simulation script.
6534
66- ## Start Redis with RedisTimeSeries, RedisGears modules installed and Grafana
35+ ## Start Redis, Grafana and Application simulation
6736
6837```
6938npm run start
7039```
7140
72- ## Register RedisGears functions
73-
74- Install Readers to add Time-Series and complete orders
75-
76- ```
77- npm run register
78- ```
79-
80- ## Install [ ioredis] ( https://github.com/luin/ioredis ) module and start simulation
81-
82- Script ` pop-up-store.js ` will add customers to stream ` queue:customers ` and their orders to the ` orders ` keys.
83-
84- ```
85- npm run simulation
86- ```
87-
8841## Grafana Dashboards
8942
9043Open Grafana Dashboard using browser http://localhost:3000
0 commit comments