Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add support for GitHub Pages #645

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://github.com/release-drafter/release-drafter#example
name-template: 'redis-shake-v$RESOLVED_VERSION'
tag-template: 'v$RESOLVED_VERSION'
template: |
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
strategy:
matrix:
redis-version: [ "2.8", "3.0", "4.0", "5.0", "6.0", "7.0" ]
container: ubuntu:latest
steps:
- name: Git checkout
uses: actions/checkout@v2
Expand All @@ -19,7 +20,8 @@ jobs:

- name: clone and make redis
run: |
sudo apt-get install git
apt-get update
apt-get install -y --no-install-recommends git build-essential ca-certificates
git clone https://github.com/redis/redis
cd redis
git checkout ${{ matrix.redis-version }}
Expand All @@ -39,5 +41,5 @@ jobs:

- name: test
run: |
pip3 install -r tests/requirements.txt
python -m pip install -r tests/requirements.txt
sh test.sh
74 changes: 52 additions & 22 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Pages

on:
workflow_dispatch: { }
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches:
- main
branches: [ v4 ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
deploy:
# Build job
build:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
node-version: 18
cache: npm
- run: npm ci
- name: Build
run: npm run docs:build
- uses: actions/configure-pages@v2
- uses: actions/upload-pages-artifact@v1
cache-dependency-path: docs/package-lock.json
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install dependencies
run: npm ci # or pnpm install / yarn install
working-directory: docs
- name: Build with VitePress
run: npm run docs:build # or pnpm docs:build / yarn docs:build
working-directory: docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: docs/.vitepress/dist
- name: Deploy

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v2
111 changes: 3 additions & 108 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,17 @@

[![CI](https://RedisShake/actions/workflows/ci.yml/badge.svg?branch=v3)](https://RedisShake/actions/workflows/ci.yml)

- [中文文档](https://RedisShake/wiki)
- [中文文档](https://tair-opensource.github.io/RedisShake/)
- [English Document](https://tair-opensource.github.io/RedisShake/en/)

redis-shake is a tool for Redis data migration and data filtering.

## Feature

* 🚄 High performance
* ✅ Tested on Redis 5.0, Redis 6.0 and Redis 7.0
* ✅ Tested on Redis 2.8, Redis 3.0, Redis 4.0, Redis 5.0, Redis 6.0 and Redis 7.0
* 🤗 Support custom filtering rules
* 💪 Support large instance migration
* 💖 Support `restore` mode, `sync` mode and `scan` mode
* ☁️ Support Aliyun Redis and ElastiCache

For older versions of redis-shake (support codis, twemproxy) please
visit [here](https://RedisShake/tree/develop).

![redis-shake2.PNG](https://s2.loli.net/2022/07/10/OZrSGutknlI8XNp.png)

![image.png](https://s2.loli.net/2022/06/30/vU346lVBrNofKzu.png)

# Document

## Install

### Binary package

Download from Release: [https://RedisShake/releases](https://RedisShake/releases)

### Compile from source

After downloading the source code, run the `sh build.sh` command to compile.

```shell
git clone https://RedisShake
cd RedisShake
sh build.sh
```

## Usage

1. Edit `sync.toml` or `restore.toml`.
2. Start redis-shake.

```shell
./bin/redis-shake redis-shake.toml
# or
./bin/redis-shake restore.toml
```

3. Check data synchronization status.

## Configure

The redis-shake configuration file refers to `sync.toml` or `restore.toml`.

## Data filtering

redis-shake supports custom filtering rules using lua scripts. redis-shake can be started with
the following command:

```shell
./bin/redis-shake sync.toml filter/xxx.lua
```

Some following filter templates are provided in `filter` directory:

1. `filter/print.lua`:print all commands
2. `filter/swap_db.lua`:swap the data of db0 and db1

### Custom filter rules

Refer to `filter/print.lua` to create a new lua script, and implement the filter function in the lua script. The
arguments of the function are:

- id: command id
- is_base: is the command read from the dump.rdb file
- group: command group, see the description file
under [redis/src/commands](https://github.com/redis/redis/tree/unstable/src/commands)
- cmd_name: command name
- keys: keys in command
- slots: slots in command
- db_id: database id
- timestamp_ms: timestamp of the command in milliseconds. The current version does not support it.

The return value is:

- code
- 0: allow this command to pass
- 1: this command is not allowed to pass
- 2: this command should not appear, and let redis-shake exit with an error
- db_id: redirected db_id

# Contribution

## Lua script

Welcome to share more creative lua scripts.

1. Add lua scripts under `filters/`.
2. Add description to `README.md`.
3. Submit a pull request.

## Redis Module support

1. Add code under `internal/rdb/types`.
2. Add a command file under `scripts/commands`, and use the script to generate a `table.go` file and move it to
the `internal/commands` directory.
3. Add test cases under `test/cases`.
4. Submit a pull request.

# 感谢

redis-shake 旧版是阿里云基于豌豆荚开源的 redis-port 进行二次开发的一个支持 Redis 异构集群实时同步的工具。
redis-shake v3 在 redis-shake 旧版的基础上重新组织代码结构,使其更具可维护性的版本。

redis-shake v3 参考借鉴了以下项目:

- https://github.com/HDT3213/rdb
- https://github.com/sripathikrishnan/redis-rdb-tools
28 changes: 14 additions & 14 deletions cmd/redis-shake/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,46 @@ func main() {

// create reader
var theReader reader.Reader
if v.IsSet("SyncStandaloneReader") {
if v.IsSet("sync_standalone_reader") {
opts := new(reader.SyncStandaloneReaderOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("SyncStandaloneReader", opts)
err := v.UnmarshalKey("sync_standalone_reader", opts)
if err != nil {
log.Panicf("failed to read the SyncReader config entry. err: %v", err)
}
theReader = reader.NewSyncStandaloneReader(opts)
log.Infof("create SyncStandaloneReader: %v", opts.Address)
} else if v.IsSet("SyncClusterReader") {
} else if v.IsSet("sync_cluster_reader") {
opts := new(reader.SyncClusterReaderOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("SyncClusterReader", opts)
err := v.UnmarshalKey("sync_cluster_reader", opts)
if err != nil {
log.Panicf("failed to read the SyncReader config entry. err: %v", err)
}
theReader = reader.NewSyncClusterReader(opts)
log.Infof("create SyncClusterReader: %v", opts.Address)
} else if v.IsSet("ScanStandaloneReader") {
} else if v.IsSet("scan_standalone_reader") {
opts := new(reader.ScanStandaloneReaderOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("ScanStandaloneReader", opts)
err := v.UnmarshalKey("scan_standalone_reader", opts)
if err != nil {
log.Panicf("failed to read the ScanReader config entry. err: %v", err)
}
theReader = reader.NewScanStandaloneReader(opts)
log.Infof("create ScanStandaloneReader: %v", opts.Address)
} else if v.IsSet("ScanClusterReader") {
} else if v.IsSet("scan_cluster_reader") {
opts := new(reader.ScanClusterReaderOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("ScanClusterReader", opts)
err := v.UnmarshalKey("scan_cluster_reader", opts)
if err != nil {
log.Panicf("failed to read the ScanReader config entry. err: %v", err)
}
theReader = reader.NewScanClusterReader(opts)
log.Infof("create ScanClusterReader: %v", opts.Address)
} else if v.IsSet("RdbReader") {
} else if v.IsSet("rdb_reader") {
opts := new(reader.RdbReaderOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("RdbReader", opts)
err := v.UnmarshalKey("rdb_reader", opts)
if err != nil {
log.Panicf("failed to read the RdbReader config entry. err: %v", err)
}
Expand All @@ -75,19 +75,19 @@ func main() {

// create writer
var theWriter writer.Writer
if v.IsSet("RedisStandaloneWriter") {
if v.IsSet("redis_standalone_writer") {
opts := new(writer.RedisStandaloneWriterOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("RedisStandaloneWriter", opts)
err := v.UnmarshalKey("redis_standalone_writer", opts)
if err != nil {
log.Panicf("failed to read the RedisStandaloneWriter config entry. err: %v", err)
}
theWriter = writer.NewRedisStandaloneWriter(opts)
log.Infof("create RedisStandaloneWriter: %v", opts.Address)
} else if v.IsSet("RedisClusterWriter") {
} else if v.IsSet("redis_cluster_writer") {
opts := new(writer.RedisClusterWriterOptions)
defaults.SetDefaults(opts)
err := v.UnmarshalKey("RedisClusterWriter", opts)
err := v.UnmarshalKey("redis_cluster_writer", opts)
if err != nil {
log.Panicf("failed to read the RedisClusterWriter config entry. err: %v", err)
}
Expand Down
68 changes: 44 additions & 24 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,48 @@ import { defineConfig } from 'vitepress'

// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "RedisShake",
description: "RedisShake is a tool for processing and migrating Redis data.",

themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: 'Home', link: '/' },
{ text: 'Examples', link: '/markdown-examples' }
],

sidebar: [
{
text: 'Examples',
items: [
{ text: 'Markdown Examples', link: '/markdown-examples' },
{ text: 'Runtime API Examples', link: '/api-examples' }
]
}
],

socialLinks: [
{ icon: 'github', link: 'https://github.com/tair-opensource/RedisShake' }
]
}
base: "/RedisShake/",
title: "RedisShake",
description: "RedisShake is a tool for processing and migrating Redis data.",
srcDir: './src',
locales: {
root: {
label: '中文',
lang: 'zh', // optional, will be added as `lang` attribute on `html` tag
themeConfig: {
// https://vitepress.dev/reference/default-theme-config
nav: [
{ text: '主页', link: '/' },
{ text: '使用文档', link: '/zh/guide/getting-started' },
{ text: '云原生内存数据库 Tair', link: 'https://www.aliyun.com/product/apsaradb/kvstore/tair' }
],
sidebar: [
{
text: '基础教程',
items: [
{ text: 'RedisShake 简介', link: '/zh/guide/getting-started' },
{ text: '快速上手', link: '/zh/guide/getting-started' },
{ text: '配置文件', link: '/zh/guide/config' }
]
},
{
text: '变换/过滤',
items: [
{ text: '上手使用', link: '/zh/transform/getting-started' },
{ text: '样例', link: '/zh/transform/examples' }
]
}
],
}
},
en: {
label: 'English',
lang: 'en',
},
},
themeConfig: {
socialLinks: [
{ icon: 'github', link: 'https://github.com/tair-opensource/RedisShake' }
],
}
})
Loading
Loading