Skip to content

Commit

Permalink
Update script and add demo (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikhail-vl authored Oct 12, 2021
1 parent d70b40b commit 638d934
Show file tree
Hide file tree
Showing 10 changed files with 508 additions and 652 deletions.
26 changes: 11 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Pop-up store demo using RedisTimeSeries, RedisGears and Redis plugins for Grafana</h1>

![Pop-up](https://github.com/RedisTimeSeries/redis-pop-up-store/blob/master/images/pop-up.gif)
![Pop-up](https://github.com/RedisTimeSeries/redis-pop-up-store/blob/master/images/pop-up-dashboard.png)

[![Grafana 8](https://img.shields.io/badge/Grafana-8-orange)](https://www.grafana.com)
[![Redis Data Source](https://img.shields.io/badge/dynamic/json?color=blue&label=Redis%20Data%20Source&query=%24.version&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fredis-datasource)](https://grafana.com/grafana/plugins/redis-datasource) [![Redis Application](https://img.shields.io/badge/dynamic/json?color=blue&label=Redis%20Application&query=%24.version&url=https%3A%2F%2Fgrafana.com%2Fapi%2Fplugins%2Fredis-app)](https://grafana.com/grafana/plugins/redis-app)

The Pop-up store demo is using [Redis Streams](https://redis.io/topics/streams-intro), [RedisTimeSeries](https://oss.redis.com/redistimeseries/), [RedisGears](https://oss.redis.com/redisgears/) and [Redis plugins](https://redisgrafana.github.io) to visualize data pipeline in Grafana.
The Pop-up store is using [Redis Streams](https://redis.io/topics/streams-intro), [RedisTimeSeries](https://oss.redis.com/redistimeseries/), [RedisGears](https://oss.redis.com/redisgears/) and [Redis plugins](https://redisgrafana.github.io) to visualize data pipeline in Grafana.

## How it works

Expand Down Expand Up @@ -51,39 +51,35 @@ gb.register(prefix='queue:orders', batch=3, trimStream=True)

- Grafana query streams and Time-Series keys every 5 seconds to display samples using Grafana plugins.

## What is displayed on Grafana dashboard
## Demo

- `Product Available` - the value of `product` key
- `Customers Ordering` - length of `queue:customers`
- `Orders Processing` - length of `queue:orders`
- `Orders Completed` - length of `queue:complete`
- `Customers Overflow` - the difference between customer submitted orders and orders completed
- `Customers Ordering` - change of `queue:customers` length
- `Orders In Queue` - change of `queue:orders` length
- `Completed Flow` - how many orders processed
Demo is available on [demo.volkovlabs.io](https://demo.volkovlabs.io):

- [Redis Overview dashboard](https://demo.volkovlabs.io/d/TgibHBv7z/redis-overview?orgId=1&refresh=1h)
- [Pop-up Store dashboard](https://demo.volkovlabs.io/d/0LC0Sm7Ml/pop-up-store?orgId=1)

## Requirements

- [Docker](https://docker.com) to start Redis and Grafana.
- [Node.js](https://nodejs.org) to run simulation script.

## Start Redis with RedisTimeSeries and RedisGears modules installed and Grafana
## Start Redis with RedisTimeSeries, RedisGears modules installed and Grafana

```
npm run start
```

## Register [StreamReaders](https://oss.redis.com/redisgears/readers.html#streamreader)
## Register RedisGears functions

Install Readers to add Time-Series and complete orders

```
npm run register
```

## Install [ioredis](https://github.com/luin/ioredis) module and run simulation
## Install [ioredis](https://github.com/luin/ioredis) module and start simulation

Script `pop-up-store.js` will add customers to stream `queue:customers` and their orders to `queue:orders`.
Script `pop-up-store.js` will add customers to stream `queue:customers` and their orders to the `orders` keys.

```
npm run simulation
Expand Down
5 changes: 0 additions & 5 deletions gears-execute.sh

This file was deleted.

6 changes: 5 additions & 1 deletion gears/complete.py → gears/orders.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ def complete(x):
execute('XDEL', 'queue:customers', x['value']['customer'])
execute('DECR', 'product')

product = execute('GET', 'product')
if int(product) < 1000:
execute('SET', 'product', 10000)


# Stream Reader for Orders queue
gb = GearsBuilder('StreamReader')
gb.map(complete)
gb.register(prefix='queue:orders', batch=3, trimStream=True)
gb.register(prefix='orders', batch=3, trimStream=True)
Binary file added images/pop-up-dashboard.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed images/pop-up.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"name": "redis-pop-up-store",
"scripts": {
"redis-cli": "docker exec -it redis redis-cli",
"register": "./gears-execute.sh && docker exec -it redis redis-cli RG.DUMPREGISTRATIONS",
"register": "./register.sh && docker exec -it redis redis-cli RG.DUMPREGISTRATIONS",
"simulation": "npm i; node src/pop-up-store.js",
"start": "docker-compose pull && docker-compose up",
"stop": "docker-compose down",
Expand Down
Loading

0 comments on commit 638d934

Please sign in to comment.