Skip to content

Commit 7388b66

Browse files
author
Mikhail
committed
Updating document with diagram
1 parent 92fc144 commit 7388b66

File tree

3 files changed

+1800
-30
lines changed

3 files changed

+1800
-30
lines changed

README.md

Lines changed: 39 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,40 +15,19 @@ The Pop-up store demo is using [Redis Streams](https://redis.io/topics/streams-i
1515

1616
![Pop-up](https://github.com/mikhailredis/redis-pop-up-store/blob/master/images/pop-up.gif)
1717

18-
## What is displayed on Grafana dashboard
19-
20-
- `Product Available` - the value of `product` key
21-
- `Customers Ordering` - length of `queue:customers`
22-
- `Orders Processing` - length of `queue:orders`
23-
- `Orders Completed` - length of `queue:complete`
24-
- `Customers Overflow` - the difference between customer submitted orders and orders completed
25-
- `Customers Ordering` - change of `queue:customers` length
26-
- `Orders In Queue` - change of `queue:orders` length
27-
- `Completed Flow` - how many orders processed
28-
29-
## Requirements
18+
## How it works
3019

31-
- [Docker](https://docker.com) to start Redis and Grafana.
32-
- [Node.js](https://nodejs.org) to run simulation script.
33-
34-
## Start Redis with RedisTimeSeries and RedisGears modules installed and Grafana
35-
36-
For detailed instructions please take a look at [redismod - a Docker image with select Redis Labs modules](https://hub.docker.com/r/redislabs/redismod).
20+
![Diagram](https://github.com/mikhailredis/redis-pop-up-store/blob/master/images/pop-up.png)
3721

38-
```
39-
npm start:docker
40-
```
41-
42-
## RedisGears scripts
43-
44-
- Visualize queues using RedisTimeSeries
22+
- Node.js script add random data to Customers and Orders streams
23+
- RedisGears is using `StreamReader` watching all `queue:` keys and adding Time-Series samples
4524

4625
```
4726
# Add Time-Series
4827
def tsAdd(x):
49-
xlen = execute('XLEN', x['key'])
50-
execute('TS.ADD', 'ts:len:'+x['key'], '*', xlen)
51-
execute('TS.ADD', 'ts:enqueue:' + x['key'], '*', x['value'])
28+
xlen = execute('XLEN', x['key'])
29+
execute('TS.ADD', 'ts:len:'+x['key'], '*', xlen)
30+
execute('TS.ADD', 'ts:enqueue:' + x['key'], '*', x['value'])
5231
5332
5433
# Stream Reader for any Queue
@@ -57,7 +36,11 @@ gb.countby(lambda x: x['key']).map(tsAdd)
5736
gb.register(prefix='queue:*', duration=5000, batch=10000, trimStream=False)
5837
```
5938

60-
- Complete orders using `queue:complete` stream
39+
- Another RedisGears script completes orders
40+
- adding data to `queue:complete` stream
41+
- deleting client's ordering
42+
- decreasing product amount
43+
- trimming Orders queue
6144

6245
```
6346
# Complete order
@@ -74,7 +57,33 @@ gb.map(complete)
7457
gb.register(prefix='queue:orders', batch=3, trimStream=True)
7558
```
7659

77-
### Register [StreamReaders](https://oss.redislabs.com/redisgears/readers.html#streamreader)
60+
- Grafana query streams and Time-Series keys every 5 seconds to display samples using Grafana Redis Datasource.
61+
62+
## What is displayed on Grafana dashboard
63+
64+
- `Product Available` - the value of `product` key
65+
- `Customers Ordering` - length of `queue:customers`
66+
- `Orders Processing` - length of `queue:orders`
67+
- `Orders Completed` - length of `queue:complete`
68+
- `Customers Overflow` - the difference between customer submitted orders and orders completed
69+
- `Customers Ordering` - change of `queue:customers` length
70+
- `Orders In Queue` - change of `queue:orders` length
71+
- `Completed Flow` - how many orders processed
72+
73+
## Requirements
74+
75+
- [Docker](https://docker.com) to start Redis and Grafana.
76+
- [Node.js](https://nodejs.org) to run simulation script.
77+
78+
## Start Redis with RedisTimeSeries and RedisGears modules installed and Grafana
79+
80+
For detailed instructions please take a look at [redismod - a Docker image with select Redis Labs modules](https://hub.docker.com/r/redislabs/redismod).
81+
82+
```
83+
npm start:docker
84+
```
85+
86+
## Register [StreamReaders](https://oss.redislabs.com/redisgears/readers.html#streamreader)
7887

7988
Install Readers to add Time-Series and complete orders
8089

0 commit comments

Comments
 (0)