├── .dockerignore ├── .github ├── release-drafter-config.yml ├── scripts │ ├── amzn2.sh │ ├── bullseye.sh │ ├── macos-x86_64.sh │ ├── rhel7.sh │ └── rhel8.sh └── workflows │ ├── amazonlinux2.yml │ ├── bullseye.yml │ ├── docker.yml │ ├── lint.yml │ ├── release-drafter.yml │ ├── rhel7.yml │ ├── rhel8.yml │ ├── ubuntu_bionic.yml │ ├── ubuntu_focal.yml │ └── ubuntu_jammy.yml ├── .gitignore ├── .python-version ├── CONTRIBUTING.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── LICENSE.txt ├── Makefile ├── README.md ├── SECURITY.md ├── build.rs ├── commands.json ├── licenses ├── RSALv2.txt └── SSPLv1.txt ├── ramp.yml ├── src ├── function_get.rs ├── function_set.rs ├── function_state.rs ├── lib.rs ├── rdb.rs └── types.rs └── tests ├── conftest.py ├── requirements.txt ├── test_commands.py ├── test_module_basics.py └── test_rdb.py /.dockerignore: -------------------------------------------------------------------------------- 1 | redis 2 | -------------------------------------------------------------------------------- /.github/release-drafter-config.yml: -------------------------------------------------------------------------------- 1 | name-template: '$NEXT_MINOR_VERSION' 2 | tag-template: 'v$NEXT_MINOR_VERSION' 3 | autolabeler: 4 | - label: 'maintenance' 5 | files: 6 | - '*.md' 7 | - '.github/*' 8 | - label: 'bug' 9 | branch: 10 | - '/bug-.+' 11 | - label: 'maintenance' 12 | branch: 13 | - '/maintenance-.+' 14 | - label: 'feature' 15 | branch: 16 | - '/feature-.+' 17 | categories: 18 | - title: 'Breaking Changes' 19 | labels: 20 | - 'breakingchange' 21 | - title: '🧪 Experimental Features' 22 | labels: 23 | - 'experimental' 24 | - title: '🚀 New Features' 25 | labels: 26 | - 'feature' 27 | - 'enhancement' 28 | - title: '🐛 Bug Fixes' 29 | labels: 30 | - 'fix' 31 | - 'bugfix' 32 | - 'bug' 33 | - 'BUG' 34 | - title: '🧰 Maintenance' 35 | label: 'maintenance' 36 | change-template: '- $TITLE (#$NUMBER)' 37 | exclude-labels: 38 | - 'skip-changelog' 39 | template: | 40 | # Changes 41 | 42 | $CHANGES 43 | 44 | ## Contributors 45 | We'd like to thank all the contributors who worked on this release! 46 | 47 | $CONTRIBUTORS 48 | 49 | -------------------------------------------------------------------------------- /.github/scripts/amzn2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | amazon-linux-extras install -y epel 6 | yum groupinstall -yqq 'Development Tools' 7 | yum install -yqq curl openssl-devel yum-utils 8 | yum -y install http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-rh-2-3.el7.centos.noarch.rpm 9 | yum -y install http://mirror.centos.org/centos/7/extras/x86_64/Packages/centos-release-scl-2-3.el7.centos.noarch.rpm 10 | yum -y install http://mirror.centos.org/centos/7/sclo/x86_64/rh/Packages/l/llvm-toolset-7-clang-4.0.1-1.el7.x86_64.rpm 11 | yum install -yqq rh-python38-python rh-python38-python-pip -------------------------------------------------------------------------------- /.github/scripts/bullseye.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | apt-get update -qq 6 | apt-get install -yqq curl python3 python3-pip clang make git libssl-dev -------------------------------------------------------------------------------- /.github/scripts/macos-x86_64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | brew install curl openssl@3 -------------------------------------------------------------------------------- /.github/scripts/rhel7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | yum groupinstall -yqq 'Development Tools' 6 | yum install -yqq curl centos-release-scl centos-release-scl-rh 7 | yum install -yqq devtoolset-9 llvm-toolset-7 8 | yum install -yqq rh-python38-python rh-python38-python-pip openssl-devel 9 | -------------------------------------------------------------------------------- /.github/scripts/rhel8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | yum groupinstall -yqq 'Development Tools' 5 | yum install -yqq python38-pip python38-devel python38 curl clang clang-devel openssl-devel compat-openssl10 git 6 | -------------------------------------------------------------------------------- /.github/workflows/amazonlinux2.yml: -------------------------------------------------------------------------------- 1 | name: AmazonLinux2 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | container: amazonlinux:2 17 | env: 18 | osnick: amzn2 19 | arch: x86_64 20 | os: Linux 21 | steps: 22 | - run: yum install -y git 23 | - uses: actions/checkout@v3 24 | - run: sh .github/scripts/${{env.osnick}}.sh 25 | - uses: ATiltedTree/setup-rust@v1 26 | with: 27 | rust-version: stable 28 | - name: install test deps 29 | run: | 30 | export PATH=/opt/rh/rh-python38/root/usr/local/bin:/opt/rh/rh-python38/root/usr/bin:$PATH 31 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 32 | 33 | - name: build debug 34 | run: | 35 | . scl_source enable llvm-toolset-7 || true 36 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 37 | 38 | - name: build release 39 | run: | 40 | . scl_source enable llvm-toolset-7 || true 41 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 42 | 43 | - name: run tests 44 | run: | 45 | . scl_source enable llvm-toolset-7 || true 46 | export PATH=/opt/rh/rh-python38/root/usr/local/bin:$PATH 47 | make bgtest 48 | 49 | - name: dist ramp to s3 50 | run: | 51 | . scl_source enable llvm-toolset-7 || true 52 | export PATH=`pwd`/redis:/opt/rh/rh-python38/root/usr/bin:/opt/rh/rh-python38/root/usr/local/bin:$PATH 53 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 54 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 55 | AWS_REGION=${{secrets.AWS_REGION}} \ 56 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 57 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/bullseye.yml: -------------------------------------------------------------------------------- 1 | name: Bullseye 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | container: debian:bullseye 17 | env: 18 | osnick: bullseye 19 | arch: x86_64 20 | os: Linux 21 | steps: 22 | - run: apt update && apt install -y git wget 23 | - uses: actions/checkout@v3 24 | - run: sh .github/scripts/${{env.osnick}}.sh 25 | - uses: ATiltedTree/setup-rust@v1 26 | with: 27 | rust-version: stable 28 | - name: install test deps 29 | run: | 30 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 31 | 32 | - name: build debug 33 | run: 34 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 35 | 36 | - name: build release 37 | run: 38 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 39 | 40 | - name: run tests 41 | run: | 42 | make bgtest 43 | 44 | - name: dist ramp to s3 45 | run: | 46 | export PATH=`pwd`/redis:$PATH 47 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 48 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 49 | AWS_REGION=${{secrets.AWS_REGION}} \ 50 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 51 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Build Docker 4 | 5 | on: 6 | push: 7 | branches: 8 | - 'main' 9 | - 'master' 10 | 11 | env: 12 | dockerorg: redislabs 13 | dockerrepo: redisstatemachine 14 | 15 | jobs: 16 | docker: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v3 20 | - name: set up qemu 21 | uses: docker/setup-qemu-action@v2 22 | 23 | - name: set up buildx 24 | uses: docker/setup-buildx-action@v2 25 | 26 | - name: dockerhub login 27 | uses: docker/login-action@v2 28 | with: 29 | username: ${{ secrets.DOCKERHUB_USERNAME }} 30 | password: ${{ secrets.DOCKERHUB_PASSWORD}} 31 | 32 | - name: Build and push 33 | uses: docker/build-push-action@v4 34 | with: 35 | push: true 36 | tags: ${{env.dockerorg}}/${{env.dockerrepo}}:edge 37 | 38 | - name: Update readme and description 39 | uses: christian-korneck/update-container-description-action@v1 40 | env: 41 | DOCKER_USER: ${{ secrets.DOCKERHUB_USERNAME }} 42 | DOCKER_PASS: ${{ secrets.DOCKERHUB_PASSWORD }} 43 | with: 44 | destination_container_repo: ${{env.dockerorg}}/${{env.dockerrepo}} 45 | provider: dockerhub 46 | short_description: 'A state machine capability for Redis' 47 | readme_file: 'README.md' -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | - main 8 | - '[0-9].[0-9]' 9 | 10 | pull_request: 11 | branches: 12 | - master 13 | - main 14 | - '[0-9].[0-9]' 15 | 16 | jobs: 17 | lint: 18 | runs-on: ubuntu-latest 19 | steps: 20 | - uses: actions/checkout@v3 21 | - uses: ATiltedTree/setup-rust@v1 22 | with: 23 | rust-version: stable 24 | - run: cargo fmt -- --check -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | name: Release Drafter 2 | 3 | on: 4 | push: 5 | # branches to consider in the event; optional, defaults to all 6 | branches: 7 | - master 8 | 9 | permissions: {} 10 | jobs: 11 | update_release_draft: 12 | permissions: 13 | pull-requests: write # to add label to PR (release-drafter/release-drafter) 14 | contents: write # to create a github release (release-drafter/release-drafter) 15 | 16 | runs-on: ubuntu-latest 17 | steps: 18 | # Drafts your next Release notes as Pull Requests are merged into "master" 19 | - uses: release-drafter/release-drafter@v5 20 | with: 21 | # (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml 22 | config-name: release-drafter-config.yml 23 | env: 24 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 25 | -------------------------------------------------------------------------------- /.github/workflows/rhel7.yml: -------------------------------------------------------------------------------- 1 | name: RHEL7 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | container: centos:7 17 | env: 18 | osnick: rhel7 19 | arch: x86_64 20 | os: Linux 21 | steps: 22 | - run: yum install -y git 23 | - uses: actions/checkout@v3 24 | - run: sh .github/scripts/${{env.osnick}}.sh 25 | - uses: ATiltedTree/setup-rust@v1 26 | with: 27 | rust-version: stable 28 | - name: install test deps 29 | run: | 30 | export PATH=/opt/rh/rh-python38/root/usr/local/bin:/opt/rh/rh-python38/root/usr/bin:$PATH 31 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 32 | 33 | - name: build debug 34 | run: | 35 | . scl_source enable devtoolset-9 || true 36 | . scl_source enable llvm-toolset-7 || true 37 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 38 | 39 | - name: build release 40 | run: | 41 | . scl_source enable devtoolset-9 || true 42 | . scl_source enable llvm-toolset-7 || true 43 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 44 | 45 | - name: run tests 46 | run: | 47 | . scl_source enable llvm-toolset-7 || true 48 | export PATH=/opt/rh/rh-python38/root/usr/local/bin:$PATH 49 | make bgtest 50 | 51 | - name: dist ramp to s3 52 | run: | 53 | . scl_source enable llvm-toolset-7 || true 54 | export PATH=`pwd`/redis:/opt/rh/rh-python38/root/usr/bin:/opt/rh/rh-python38/root/usr/local/bin:$PATH 55 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 56 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 57 | AWS_REGION=${{secrets.AWS_REGION}} \ 58 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 59 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/rhel8.yml: -------------------------------------------------------------------------------- 1 | name: RHEL8 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | container: rockylinux:8 17 | env: 18 | osnick: rhel8 19 | arch: x86_64 20 | os: Linux 21 | steps: 22 | - uses: actions/checkout@v3 23 | - run: sh .github/scripts/${{env.osnick}}.sh 24 | 25 | - uses: ATiltedTree/setup-rust@v1 26 | with: 27 | rust-version: stable 28 | - name: install test deps 29 | run: | 30 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 31 | 32 | - name: build debug 33 | run: 34 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 35 | 36 | - name: build release 37 | run: 38 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 39 | 40 | - name: run tests 41 | run: | 42 | make bgtest 43 | 44 | - name: dist ramp to s3 45 | run: | 46 | export PATH=`pwd`/redis:$PATH 47 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 48 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 49 | AWS_REGION=${{secrets.AWS_REGION}} \ 50 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 51 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/ubuntu_bionic.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 18.04 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | env: 17 | osnick: ubuntu18.04 18 | arch: x86_64 19 | os: Linux 20 | steps: 21 | - uses: actions/checkout@v3 22 | - uses: ATiltedTree/setup-rust@v1 23 | with: 24 | rust-version: stable 25 | - uses: actions/setup-python@v4 26 | with: 27 | cache: 'pip' 28 | - name: install test deps 29 | run: | 30 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 31 | 32 | - name: build debug 33 | run: 34 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 35 | 36 | - name: build release 37 | run: 38 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 39 | 40 | - name: run tests 41 | run: | 42 | make bgtest 43 | 44 | - name: dist ramp to s3 45 | run: | 46 | export PATH=`pwd`/redis:$PATH 47 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 48 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 49 | AWS_REGION=${{secrets.AWS_REGION}} \ 50 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 51 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/ubuntu_focal.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 20.04 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | env: 17 | osnick: ubuntu20.04 18 | arch: x86_64 19 | os: Linux 20 | steps: 21 | - uses: actions/checkout@v3 22 | - uses: ATiltedTree/setup-rust@v1 23 | with: 24 | rust-version: stable 25 | - uses: actions/setup-python@v4 26 | with: 27 | cache: 'pip' 28 | - name: install test deps 29 | run: | 30 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 31 | 32 | - name: build debug 33 | run: 34 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 35 | 36 | - name: build release 37 | run: 38 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 39 | 40 | - name: run tests 41 | run: | 42 | make bgtest 43 | 44 | - name: dist ramp to s3 45 | run: | 46 | export PATH=`pwd`/redis:$PATH 47 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 48 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 49 | AWS_REGION=${{secrets.AWS_REGION}} \ 50 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 51 | PUBLISH=1 -------------------------------------------------------------------------------- /.github/workflows/ubuntu_jammy.yml: -------------------------------------------------------------------------------- 1 | name: Ubuntu 22.04 2 | 3 | on: 4 | push: 5 | branches: [master] 6 | pull_request: 7 | branches: [master] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | 14 | build: 15 | runs-on: ubuntu-latest 16 | env: 17 | osnick: ubuntu22.04 18 | arch: x86_64 19 | os: Linux 20 | steps: 21 | - uses: actions/checkout@v3 22 | - uses: ATiltedTree/setup-rust@v1 23 | with: 24 | rust-version: stable 25 | - uses: actions/setup-python@v4 26 | with: 27 | cache: 'pip' 28 | - name: install test deps 29 | run: | 30 | make deps ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 31 | 32 | - name: build debug 33 | run: 34 | make ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 35 | 36 | - name: build release 37 | run: 38 | make RELEASE=1 ARCH=${{env.arch}} OS=${{env.os}} OSNICK=${{env.osnick}} 39 | 40 | - name: run tests 41 | run: | 42 | make bgtest 43 | 44 | - name: dist ramp to s3 45 | run: | 46 | export PATH=`pwd`/redis:$PATH 47 | make pack AWS_ACCESS_KEY_ID=${{secrets.AWS_ACCESS_KEY_ID}} \ 48 | AWS_SECRET_ACCESS_KEY=${{secrets.AWS_SECRET_ACCESS_KEY}} \ 49 | AWS_REGION=${{secrets.AWS_REGION}} \ 50 | OS=${{env.os}} OSNICK=${{env.osnick}} ARCH=${{env.arch}} \ 51 | PUBLISH=1 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | dump.rdb 2 | target 3 | .idea 4 | .venv* 5 | .vscode 6 | *.rdb 7 | *.pyc 8 | libredis_state.so 9 | libredis_state.Linux-ubuntu20.04-x86_64.1.0.1.zip 10 | results.xml 11 | redis 12 | -------------------------------------------------------------------------------- /.python-version: -------------------------------------------------------------------------------- 1 | 3.10.5 2 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Note: by contributing code to this project in any form, including sending 2 | a pull request via GitHub, a code fragment or patch via private email or 3 | public discussion groups, you agree to release your code under the terms 4 | of the [LICENSEs](license.txt). 5 | 6 | # IMPORTANT: HOW TO USE REDIS GITHUB ISSUES 7 | 8 | GitHub issues SHOULD ONLY BE USED to report bugs, and for DETAILED feature 9 | requests. 10 | 11 | If you are reporting a security bug or vulnerability, see [SECURITY.md](SECURITY.md). 12 | 13 | # How to provide a patch for a new feature 14 | 15 | 1. If it is a major feature or a semantical change, please don't start coding 16 | straight away: if your feature is not a conceptual fit you'll lose a lot of 17 | time writing the code without any reason. Start by posting in a GitHub issue issue at Github with the description of, exactly, what you want 18 | to accomplish and why. Use cases are important for features to be accepted. 19 | 20 | 2. If in step 1 you get an acknowledgment from the project leaders, use the 21 | following procedure to submit a patch: 22 | 23 | a. [Fork](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) Redis Stack on github. 24 | b. Create a topic branch (git checkout -b my_branch) 25 | c. Push to your branch (git push origin my_branch) 26 | d. Initiate a [pull request](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request) on this repository. 27 | e. Done :) 28 | 29 | Thanks! 30 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "addr2line" 7 | version = "0.17.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" 10 | dependencies = [ 11 | "gimli", 12 | ] 13 | 14 | [[package]] 15 | name = "adler" 16 | version = "1.0.2" 17 | source = "registry+https://github.com/rust-lang/crates.io-index" 18 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 19 | 20 | [[package]] 21 | name = "aho-corasick" 22 | version = "0.7.20" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" 25 | dependencies = [ 26 | "memchr", 27 | ] 28 | 29 | [[package]] 30 | name = "ansi_term" 31 | version = "0.12.1" 32 | source = "registry+https://github.com/rust-lang/crates.io-index" 33 | checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" 34 | dependencies = [ 35 | "winapi", 36 | ] 37 | 38 | [[package]] 39 | name = "atty" 40 | version = "0.2.14" 41 | source = "registry+https://github.com/rust-lang/crates.io-index" 42 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 43 | dependencies = [ 44 | "hermit-abi", 45 | "libc", 46 | "winapi", 47 | ] 48 | 49 | [[package]] 50 | name = "autocfg" 51 | version = "1.1.0" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 54 | 55 | [[package]] 56 | name = "backtrace" 57 | version = "0.3.66" 58 | source = "registry+https://github.com/rust-lang/crates.io-index" 59 | checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" 60 | dependencies = [ 61 | "addr2line", 62 | "cc", 63 | "cfg-if", 64 | "libc", 65 | "miniz_oxide", 66 | "object", 67 | "rustc-demangle", 68 | ] 69 | 70 | [[package]] 71 | name = "bindgen" 72 | version = "0.59.2" 73 | source = "registry+https://github.com/rust-lang/crates.io-index" 74 | checksum = "2bd2a9a458e8f4304c52c43ebb0cfbd520289f8379a52e329a38afda99bf8eb8" 75 | dependencies = [ 76 | "bitflags", 77 | "cexpr", 78 | "clang-sys", 79 | "clap", 80 | "env_logger", 81 | "lazy_static", 82 | "lazycell", 83 | "log", 84 | "peeking_take_while", 85 | "proc-macro2", 86 | "quote 1.0.21", 87 | "regex", 88 | "rustc-hash", 89 | "shlex", 90 | "which", 91 | ] 92 | 93 | [[package]] 94 | name = "bitflags" 95 | version = "1.3.2" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 98 | 99 | [[package]] 100 | name = "cc" 101 | version = "1.0.77" 102 | source = "registry+https://github.com/rust-lang/crates.io-index" 103 | checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" 104 | 105 | [[package]] 106 | name = "cexpr" 107 | version = "0.6.0" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" 110 | dependencies = [ 111 | "nom", 112 | ] 113 | 114 | [[package]] 115 | name = "cfg-if" 116 | version = "1.0.0" 117 | source = "registry+https://github.com/rust-lang/crates.io-index" 118 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 119 | 120 | [[package]] 121 | name = "clang-sys" 122 | version = "1.4.0" 123 | source = "registry+https://github.com/rust-lang/crates.io-index" 124 | checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" 125 | dependencies = [ 126 | "glob", 127 | "libc", 128 | "libloading", 129 | ] 130 | 131 | [[package]] 132 | name = "clap" 133 | version = "2.34.0" 134 | source = "registry+https://github.com/rust-lang/crates.io-index" 135 | checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" 136 | dependencies = [ 137 | "ansi_term", 138 | "atty", 139 | "bitflags", 140 | "strsim", 141 | "textwrap", 142 | "unicode-width", 143 | "vec_map", 144 | ] 145 | 146 | [[package]] 147 | name = "either" 148 | version = "1.8.0" 149 | source = "registry+https://github.com/rust-lang/crates.io-index" 150 | checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" 151 | 152 | [[package]] 153 | name = "enum-primitive-derive" 154 | version = "0.1.2" 155 | source = "registry+https://github.com/rust-lang/crates.io-index" 156 | checksum = "e2b90e520ec62c1864c8c78d637acbfe8baf5f63240f2fb8165b8325c07812dd" 157 | dependencies = [ 158 | "num-traits 0.1.43", 159 | "quote 0.3.15", 160 | "syn 0.11.11", 161 | ] 162 | 163 | [[package]] 164 | name = "env_logger" 165 | version = "0.9.3" 166 | source = "registry+https://github.com/rust-lang/crates.io-index" 167 | checksum = "a12e6657c4c97ebab115a42dcee77225f7f482cdd841cf7088c657a42e9e00e7" 168 | dependencies = [ 169 | "atty", 170 | "humantime", 171 | "log", 172 | "regex", 173 | "termcolor", 174 | ] 175 | 176 | [[package]] 177 | name = "gimli" 178 | version = "0.26.2" 179 | source = "registry+https://github.com/rust-lang/crates.io-index" 180 | checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" 181 | 182 | [[package]] 183 | name = "glob" 184 | version = "0.3.0" 185 | source = "registry+https://github.com/rust-lang/crates.io-index" 186 | checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 187 | 188 | [[package]] 189 | name = "heck" 190 | version = "0.4.0" 191 | source = "registry+https://github.com/rust-lang/crates.io-index" 192 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 193 | 194 | [[package]] 195 | name = "hermit-abi" 196 | version = "0.1.19" 197 | source = "registry+https://github.com/rust-lang/crates.io-index" 198 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 199 | dependencies = [ 200 | "libc", 201 | ] 202 | 203 | [[package]] 204 | name = "humantime" 205 | version = "2.1.0" 206 | source = "registry+https://github.com/rust-lang/crates.io-index" 207 | checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" 208 | 209 | [[package]] 210 | name = "itoa" 211 | version = "1.0.4" 212 | source = "registry+https://github.com/rust-lang/crates.io-index" 213 | checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" 214 | 215 | [[package]] 216 | name = "lazy_static" 217 | version = "1.4.0" 218 | source = "registry+https://github.com/rust-lang/crates.io-index" 219 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 220 | 221 | [[package]] 222 | name = "lazycell" 223 | version = "1.3.0" 224 | source = "registry+https://github.com/rust-lang/crates.io-index" 225 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" 226 | 227 | [[package]] 228 | name = "libc" 229 | version = "0.2.137" 230 | source = "registry+https://github.com/rust-lang/crates.io-index" 231 | checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" 232 | 233 | [[package]] 234 | name = "libloading" 235 | version = "0.7.4" 236 | source = "registry+https://github.com/rust-lang/crates.io-index" 237 | checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" 238 | dependencies = [ 239 | "cfg-if", 240 | "winapi", 241 | ] 242 | 243 | [[package]] 244 | name = "log" 245 | version = "0.4.17" 246 | source = "registry+https://github.com/rust-lang/crates.io-index" 247 | checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" 248 | dependencies = [ 249 | "cfg-if", 250 | ] 251 | 252 | [[package]] 253 | name = "memchr" 254 | version = "2.5.0" 255 | source = "registry+https://github.com/rust-lang/crates.io-index" 256 | checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" 257 | 258 | [[package]] 259 | name = "minimal-lexical" 260 | version = "0.2.1" 261 | source = "registry+https://github.com/rust-lang/crates.io-index" 262 | checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" 263 | 264 | [[package]] 265 | name = "miniz_oxide" 266 | version = "0.5.4" 267 | source = "registry+https://github.com/rust-lang/crates.io-index" 268 | checksum = "96590ba8f175222643a85693f33d26e9c8a015f599c216509b1a6894af675d34" 269 | dependencies = [ 270 | "adler", 271 | ] 272 | 273 | [[package]] 274 | name = "nom" 275 | version = "7.1.1" 276 | source = "registry+https://github.com/rust-lang/crates.io-index" 277 | checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" 278 | dependencies = [ 279 | "memchr", 280 | "minimal-lexical", 281 | ] 282 | 283 | [[package]] 284 | name = "num-traits" 285 | version = "0.1.43" 286 | source = "registry+https://github.com/rust-lang/crates.io-index" 287 | checksum = "92e5113e9fd4cc14ded8e499429f396a20f98c772a47cc8622a736e1ec843c31" 288 | dependencies = [ 289 | "num-traits 0.2.15", 290 | ] 291 | 292 | [[package]] 293 | name = "num-traits" 294 | version = "0.2.15" 295 | source = "registry+https://github.com/rust-lang/crates.io-index" 296 | checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" 297 | dependencies = [ 298 | "autocfg", 299 | ] 300 | 301 | [[package]] 302 | name = "object" 303 | version = "0.29.0" 304 | source = "registry+https://github.com/rust-lang/crates.io-index" 305 | checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" 306 | dependencies = [ 307 | "memchr", 308 | ] 309 | 310 | [[package]] 311 | name = "once_cell" 312 | version = "1.16.0" 313 | source = "registry+https://github.com/rust-lang/crates.io-index" 314 | checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" 315 | 316 | [[package]] 317 | name = "os_info" 318 | version = "3.5.1" 319 | source = "registry+https://github.com/rust-lang/crates.io-index" 320 | checksum = "c4750134fb6a5d49afc80777394ad5d95b04bc12068c6abb92fae8f43817270f" 321 | dependencies = [ 322 | "log", 323 | "winapi", 324 | ] 325 | 326 | [[package]] 327 | name = "peeking_take_while" 328 | version = "0.1.2" 329 | source = "registry+https://github.com/rust-lang/crates.io-index" 330 | checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" 331 | 332 | [[package]] 333 | name = "proc-macro2" 334 | version = "1.0.47" 335 | source = "registry+https://github.com/rust-lang/crates.io-index" 336 | checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" 337 | dependencies = [ 338 | "unicode-ident", 339 | ] 340 | 341 | [[package]] 342 | name = "quote" 343 | version = "0.3.15" 344 | source = "registry+https://github.com/rust-lang/crates.io-index" 345 | checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" 346 | 347 | [[package]] 348 | name = "quote" 349 | version = "1.0.21" 350 | source = "registry+https://github.com/rust-lang/crates.io-index" 351 | checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" 352 | dependencies = [ 353 | "proc-macro2", 354 | ] 355 | 356 | [[package]] 357 | name = "redis-module" 358 | version = "1.0.1" 359 | source = "registry+https://github.com/rust-lang/crates.io-index" 360 | checksum = "04133364fe1a1fce0d9e3b6baf2877bec48c01c9cfea1ed3f76b862b0ac09032" 361 | dependencies = [ 362 | "backtrace", 363 | "bindgen", 364 | "bitflags", 365 | "cc", 366 | "enum-primitive-derive", 367 | "libc", 368 | "num-traits 0.2.15", 369 | "regex", 370 | "strum_macros", 371 | ] 372 | 373 | [[package]] 374 | name = "redis-state-machine" 375 | version = "99.99.99" 376 | dependencies = [ 377 | "clap", 378 | "os_info", 379 | "redis-module", 380 | "regex", 381 | "serde", 382 | "serde_json", 383 | "use", 384 | ] 385 | 386 | [[package]] 387 | name = "regex" 388 | version = "1.7.0" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" 391 | dependencies = [ 392 | "aho-corasick", 393 | "memchr", 394 | "regex-syntax", 395 | ] 396 | 397 | [[package]] 398 | name = "regex-syntax" 399 | version = "0.6.28" 400 | source = "registry+https://github.com/rust-lang/crates.io-index" 401 | checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" 402 | 403 | [[package]] 404 | name = "rustc-demangle" 405 | version = "0.1.21" 406 | source = "registry+https://github.com/rust-lang/crates.io-index" 407 | checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" 408 | 409 | [[package]] 410 | name = "rustc-hash" 411 | version = "1.1.0" 412 | source = "registry+https://github.com/rust-lang/crates.io-index" 413 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 414 | 415 | [[package]] 416 | name = "rustversion" 417 | version = "1.0.9" 418 | source = "registry+https://github.com/rust-lang/crates.io-index" 419 | checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" 420 | 421 | [[package]] 422 | name = "ryu" 423 | version = "1.0.11" 424 | source = "registry+https://github.com/rust-lang/crates.io-index" 425 | checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" 426 | 427 | [[package]] 428 | name = "serde" 429 | version = "1.0.152" 430 | source = "registry+https://github.com/rust-lang/crates.io-index" 431 | checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb" 432 | dependencies = [ 433 | "serde_derive", 434 | ] 435 | 436 | [[package]] 437 | name = "serde_derive" 438 | version = "1.0.152" 439 | source = "registry+https://github.com/rust-lang/crates.io-index" 440 | checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e" 441 | dependencies = [ 442 | "proc-macro2", 443 | "quote 1.0.21", 444 | "syn 1.0.107", 445 | ] 446 | 447 | [[package]] 448 | name = "serde_json" 449 | version = "1.0.93" 450 | source = "registry+https://github.com/rust-lang/crates.io-index" 451 | checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76" 452 | dependencies = [ 453 | "itoa", 454 | "ryu", 455 | "serde", 456 | ] 457 | 458 | [[package]] 459 | name = "shlex" 460 | version = "1.1.0" 461 | source = "registry+https://github.com/rust-lang/crates.io-index" 462 | checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" 463 | 464 | [[package]] 465 | name = "strsim" 466 | version = "0.8.0" 467 | source = "registry+https://github.com/rust-lang/crates.io-index" 468 | checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" 469 | 470 | [[package]] 471 | name = "strum_macros" 472 | version = "0.24.3" 473 | source = "registry+https://github.com/rust-lang/crates.io-index" 474 | checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" 475 | dependencies = [ 476 | "heck", 477 | "proc-macro2", 478 | "quote 1.0.21", 479 | "rustversion", 480 | "syn 1.0.107", 481 | ] 482 | 483 | [[package]] 484 | name = "syn" 485 | version = "0.11.11" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "d3b891b9015c88c576343b9b3e41c2c11a51c219ef067b264bd9c8aa9b441dad" 488 | dependencies = [ 489 | "quote 0.3.15", 490 | "synom", 491 | "unicode-xid", 492 | ] 493 | 494 | [[package]] 495 | name = "syn" 496 | version = "1.0.107" 497 | source = "registry+https://github.com/rust-lang/crates.io-index" 498 | checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5" 499 | dependencies = [ 500 | "proc-macro2", 501 | "quote 1.0.21", 502 | "unicode-ident", 503 | ] 504 | 505 | [[package]] 506 | name = "synom" 507 | version = "0.11.3" 508 | source = "registry+https://github.com/rust-lang/crates.io-index" 509 | checksum = "a393066ed9010ebaed60b9eafa373d4b1baac186dd7e008555b0f702b51945b6" 510 | dependencies = [ 511 | "unicode-xid", 512 | ] 513 | 514 | [[package]] 515 | name = "termcolor" 516 | version = "1.1.3" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 519 | dependencies = [ 520 | "winapi-util", 521 | ] 522 | 523 | [[package]] 524 | name = "textwrap" 525 | version = "0.11.0" 526 | source = "registry+https://github.com/rust-lang/crates.io-index" 527 | checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" 528 | dependencies = [ 529 | "unicode-width", 530 | ] 531 | 532 | [[package]] 533 | name = "unicode-ident" 534 | version = "1.0.5" 535 | source = "registry+https://github.com/rust-lang/crates.io-index" 536 | checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" 537 | 538 | [[package]] 539 | name = "unicode-width" 540 | version = "0.1.10" 541 | source = "registry+https://github.com/rust-lang/crates.io-index" 542 | checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" 543 | 544 | [[package]] 545 | name = "unicode-xid" 546 | version = "0.0.4" 547 | source = "registry+https://github.com/rust-lang/crates.io-index" 548 | checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" 549 | 550 | [[package]] 551 | name = "use" 552 | version = "0.0.0" 553 | source = "registry+https://github.com/rust-lang/crates.io-index" 554 | checksum = "89452352a9cec4cf2d44c40f96d3696e09866e922b1fa28bccfe77b803055e66" 555 | 556 | [[package]] 557 | name = "vec_map" 558 | version = "0.8.2" 559 | source = "registry+https://github.com/rust-lang/crates.io-index" 560 | checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" 561 | 562 | [[package]] 563 | name = "which" 564 | version = "4.3.0" 565 | source = "registry+https://github.com/rust-lang/crates.io-index" 566 | checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" 567 | dependencies = [ 568 | "either", 569 | "libc", 570 | "once_cell", 571 | ] 572 | 573 | [[package]] 574 | name = "winapi" 575 | version = "0.3.9" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 578 | dependencies = [ 579 | "winapi-i686-pc-windows-gnu", 580 | "winapi-x86_64-pc-windows-gnu", 581 | ] 582 | 583 | [[package]] 584 | name = "winapi-i686-pc-windows-gnu" 585 | version = "0.4.0" 586 | source = "registry+https://github.com/rust-lang/crates.io-index" 587 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 588 | 589 | [[package]] 590 | name = "winapi-util" 591 | version = "0.1.5" 592 | source = "registry+https://github.com/rust-lang/crates.io-index" 593 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 594 | dependencies = [ 595 | "winapi", 596 | ] 597 | 598 | [[package]] 599 | name = "winapi-x86_64-pc-windows-gnu" 600 | version = "0.4.0" 601 | source = "registry+https://github.com/rust-lang/crates.io-index" 602 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 603 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "redis-state-machine" 3 | description = "A state machine modules for Redis" 4 | authors = ["Redis OSS "] 5 | license = "Redis Source Available License 2.0 (RSALv2) or the Server Side Public License v1 (SSPLv1)" 6 | version = "99.99.99" 7 | edition = "2021" 8 | keywords = ["redis", "state-machine", "plugin"] 9 | categories = ["database-implementations"] 10 | 11 | [lib] 12 | crate-type = ["cdylib", "rlib"] 13 | name = "redis_state" 14 | 15 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 16 | 17 | [dependencies] 18 | redis-module = "1.0.1" 19 | serde = {version = "1.0", features = ["derive"]} 20 | serde_json = "1.0.93" 21 | use = "0.0.0" 22 | 23 | 24 | [build-dependencies] 25 | regex = "1" 26 | clap = "~2" 27 | os_info = { version = "3", default-features = false } 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM redis:7.0 as redis 2 | FROM rust:bullseye as builder 3 | 4 | ADD . /build 5 | WORKDIR /build 6 | RUN apt update -qq && apt install -yqq python3 python3-pip clang 7 | RUN make RELEASE=1 8 | 9 | FROM debian:bullseye 10 | RUN apt update -qq && apt install -yqq libssl-dev 11 | RUN rm -rf /var/cache/apt/* 12 | COPY --from=redis /usr/local/bin/redis-* /usr/bin/ 13 | COPY --from=builder /build/target/release/libredis_state.so /usr/lib/libredis_state.so 14 | EXPOSE 6379 15 | CMD ["redis-server", "--protected-mode", "no", "--loadmodule", "/usr/lib/libredis_state.so"] 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Except as otherwise specified in the source code headers for specific files, the source code in this repository is made available to you under your choice of 2 | (i) Redis Source Available License 2.0 (RSALv2) or (ii) the Server Side Public License v1 (SSPLv1) 3 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: all run 2 | 3 | module_name=libredis_state.so 4 | 5 | # override 6 | OSNICK?=ubuntu22.04 7 | ARCH?=x86_64 8 | OS?=Linux 9 | REDISVERSION?=7.0.9-1 10 | VERSION?=99.99.99 11 | REDIS_SERVER_PATH?=redis/redis-server 12 | 13 | TARGETBASEDIR=target 14 | ifdef RELEASE 15 | RELEASEFLAGS=--release 16 | TARGETDIR=${TARGETBASEDIR}/release 17 | S3TARGET=s3://redismodules/redisstatemachine 18 | else 19 | TARGETDIR=${TARGETBASEDIR}/debug 20 | S3TARGET=s3://redismodules/redisstatemachine/snapshots 21 | endif 22 | module_dest=${TARGETDIR}/${module_name} 23 | 24 | all:: 25 | cargo build ${RELEASEFLAGS} 26 | 27 | run: all 28 | redis-server --loadmodule ${module_dest} 29 | 30 | bgtest: all 31 | $(REDIS_SERVER_PATH) --daemonize yes --loadmodule ${module_dest} 32 | pytest --junit-xml=results.xml 33 | redis/redis-cli shutdown 34 | 35 | clean: 36 | rm -rf ${module_dest} dump.rdb 37 | 38 | distclean: 39 | rm -rf ${TARGETBASEDIR} dump.rdb redis *.zip 40 | 41 | deps: 42 | pip3 install -r tests/requirements.txt 43 | curl -s https://redismodules.s3.amazonaws.com/redis-stack/dependencies/redis-${REDISVERSION}-${OS}-${OSNICK}-${ARCH}.tgz --output redis.tgz 44 | tar -xpf redis.tgz 45 | rm *.tgz 46 | mv redis* redis 47 | chmod a+x redis/* 48 | 49 | pack: 50 | ramp pack -m ramp.yml target/release/libredis_state.so -o libredis_state.Linux-${OSNICK}-${ARCH}.${VERSION}.zip 51 | ifdef PUBLISH 52 | s3cmd --access_key=${AWS_ACCESS_KEY_ID} \ 53 | --secret_key=${AWS_SECRET_ACCESS_KEY} \ 54 | --region=${AWS_REGION} \ 55 | put -P *.zip \ 56 | ${S3TARGET} 57 | endif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # redis-state-machine 2 | 3 | [![Latest Release](https://img.shields.io/github/v/release/redislabsmodules/redis-state-machine?label=latest)](https://github.com/redislabsmodules/redis-state-machine/releases/latest) 4 | [![Dockerhub](https://img.shields.io/badge/dockerhub-redislabs/redisstatemachine-blue)](https://hub.docker.com/r/redislabs/redisstatemachine/tags/) 5 | 6 | A [Redis module](https://redis.io/docs/modules) that maintains a state machine on the server side. 7 | 8 | ** Notice, this is experimental, and under active development. ** 9 | 10 | ## Installation 11 | 12 | The easiest way to investigate this capability, is to pull the latest docker. The following runs a redis instance on the default port, complete with a state machine. 13 | 14 | ```docker run -p 6379:6379 -it redislabs/redisstatemachine:edge``` 15 | 16 | ## Basic Usage 17 | 18 | A state machine is a JSON document containing key value pairs for machine state transitions. Let's look at the state machine template, via the ```SM.TEMPLATE``` command. 19 | 20 | ```bash 21 | redis-cli 22 | SM.TEMPLATE 23 | ``` 24 | 25 | A state machine contains a map of states, a current state, and an initial state. 26 | ```"{\"current\":\"\",\"map\":{},\"initial\":\"\"}"``` 27 | 28 | Create a simple machine 29 | 30 | ```bash 31 | redis-cli 32 | SM.SET mymachine "{\"current\":\"\",\"map\":{},\"initial\":\"foo\"}" 33 | ``` 34 | 35 | Examine the machine via ```SM.GET```. 36 | 37 | ```bash 38 | redis-cli 39 | SM.GET mymachine 40 | ``` 41 | 42 | As we didn't specify a current state, the initial state is assumed: 43 | 44 | ```"{\"current\":\"foo\",\"map\":{},\"initial\":\"foo\"}"``` 45 | 46 | ## A practical example 47 | 48 | Let's create and interact with a complete state machine, using python, and [redis-py](https://github.com/redis/redis-py). First, let's load the state machine template: 49 | 50 | ```python 51 | 52 | import redis 53 | import json 54 | 55 | r = redis.Redis(decode_responses=True) 56 | tmpl = json.loads(r.execute_command("SM.TEMPLATE")) 57 | ``` 58 | 59 | Let's create a simple machine named *mystatemachine*. The default state will be foo, and we'll support states named ```bar```, ```blee```, and ```boo```. In our state machine, ```bar``` will be able to move to states ```blee``` and ```boo```, but only ```boo``` will be able to return to blee. 60 | 61 | ```python 62 | 63 | tmpl['initial'] = 'bar' 64 | tmpl['map'] = {"bar": ["blee", "boo"], "boo": ["blee"]} 65 | r.execute_command("SM.SET", "mystatemachine", json.dumps(tmpl)) 66 | ``` 67 | 68 | 69 | 70 | If we try to change our statemachine to an invalid state, Redis returns a nil. 71 | 72 | ```python 73 | x = r.execute_command("SM.MUTATE", "mystatemachine", "notastate") 74 | print(x) 75 | >>> None 76 | ``` 77 | 78 | If we try to change states to a valid state, we receive an ok. 79 | 80 | ```python 81 | x = r.execute_command("SM.MUTATE", "mystatemachine", "blee") 82 | print(x) 83 | >>> OK 84 | ``` 85 | 86 | Example the state machine, using the redis-cli we can example the machine using ```SM.GET```. 87 | 88 | ```python 89 | r.execute_command("SM.GET", "mystatemachine") 90 | ``` 91 | 92 | Notice the structure - we now have a map of states and transitions. 93 | ```'{"current":"blee","map":{"bar":["blee","boo"],"boo":["blee"]},"initial":"bar"}'``` 94 | 95 | As this is currently evolving, the canonical command set is available in the [commands.json](./commands.json) file, with usage tests available in the [tests directory](./tests/test_commands.py). 96 | 97 | ---- 98 | 99 | ## Building and contributing 100 | 101 | ### Tooling 102 | 103 | * [Rust](https://www.rust-lang.org) 104 | 105 | * GNU Make 106 | 107 | * Python >= [this file](.python-version) 108 | 109 | * Redis 110 | 111 | **Build and run** 112 | 113 | ```bash 114 | make run 115 | ``` 116 | 117 | ### Testing 118 | 119 | Module testing is currently integration based - and done with pytest, and python. 120 | 121 | Set up a virtual environment, with your test dependencies 122 | 123 | ``` 124 | python -m venv .venv 125 | source .venv/bin/activate 126 | pip install -r tests/requirements.txt 127 | ``` 128 | 129 | Run the tests 130 | ``` 131 | pytest 132 | ``` 133 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Reporting a Vulnerability 4 | 5 | If you believe you’ve discovered a serious vulnerability, please contact the 6 | Redis Team at oss@redis.com. We will evaluate your report and if 7 | necessary issue a fix and an advisory. If the issue was previously undisclosed, 8 | we’ll also mention your name in the credits. 9 | 10 | ## Responsible Disclosure 11 | 12 | In some cases, we may apply a responsible disclosure process to reported or 13 | otherwise discovered vulnerabilities. We will usually do that for a critical 14 | vulnerability, and only if we have a good reason to believe information about 15 | it is not yet public. 16 | 17 | This process involves providing an early notification about the vulnerability, 18 | its impact and mitigations to a short list of vendors under a time-limited 19 | embargo on public disclosure. 20 | 21 | Vendors on the list are individuals or organizations that maintain Redis 22 | distributions or provide Redis as a service, who have third party users who 23 | will benefit from the vendor’s ability to prepare for a new version or deploy a 24 | fix early. 25 | 26 | If you believe you should be on the list, please contact us and we will 27 | consider your request based on the above criteria. 28 | -------------------------------------------------------------------------------- /build.rs: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Redis Ltd. 2018 - present 3 | * Licensed under your choice of the Redis Source Available License 2.0 (RSALv2) or 4 | * the Server Side Public License v1 (SSPLv1). 5 | */ 6 | 7 | extern crate clap; 8 | 9 | use regex::Regex; 10 | use std::process::Command; 11 | 12 | fn main() { 13 | // Expose GIT_SHA env var 14 | let git_sha = Command::new("git").args(["rev-parse", "HEAD"]).output(); 15 | if let Ok(sha) = git_sha { 16 | let sha = String::from_utf8(sha.stdout).unwrap(); 17 | println!("cargo:rustc-env=GIT_SHA={}", sha); 18 | } 19 | // Expose GIT_BRANCH env var 20 | let git_branch = Command::new("git") 21 | .args(["rev-parse", "--abbrev-ref", "HEAD"]) 22 | .output(); 23 | if let Ok(branch) = git_branch { 24 | let branch = String::from_utf8(branch.stdout).unwrap(); 25 | println!("cargo:rustc-env=GIT_BRANCH={}", branch); 26 | } 27 | 28 | let version_str = String::from(clap::crate_version!()); 29 | println!("cargo:rustc-env=VERSION_STR={}", version_str); 30 | 31 | let mut version_num = 0; 32 | let re = Regex::new(r"(\d+).(\d+).(\d+)").unwrap(); 33 | for cap in re.captures_iter(&version_str) { 34 | let major = (cap[1]).parse::().unwrap(); 35 | let minor = (cap[2]).parse::().unwrap(); 36 | let patch = (cap[3]).parse::().unwrap(); 37 | version_num = major * 10000 + minor * 100 + patch; 38 | } 39 | println!("cargo:rustc-env=VERSION_NUM={}", version_num); 40 | 41 | let info = os_info::get(); 42 | 43 | println!( 44 | "cargo:rustc-env=BUILD_OS={}", 45 | std::env::consts::OS.to_string().to_lowercase() 46 | ); 47 | println!( 48 | "cargo:rustc-env=BUILD_OS_TYPE={}", 49 | info.os_type().to_string().to_lowercase() 50 | ); 51 | println!("cargo:rustc-env=BUILD_OS_VERSION={}", info.version()); 52 | println!("cargo:rustc-env=BUILD_OS_ARCH={}", std::env::consts::ARCH); 53 | println!( 54 | "cargo:rustc-env=BUILD_TYPE={}", 55 | std::env::var("PROFILE").expect("Can not get PROFILE env var") 56 | ); 57 | } 58 | -------------------------------------------------------------------------------- /commands.json: -------------------------------------------------------------------------------- 1 | { 2 | "SM.GET": { 3 | "summary": "Gets a state machine, or the stored reason for the state transition", 4 | "since": "0.1.0", 5 | "complexity": "O(N)", 6 | "group": "statemachine", 7 | "arguments": [ 8 | { 9 | "name": "key", 10 | "type": "key" 11 | }, 12 | { 13 | "name": "codition", 14 | "type": "string", 15 | "optional": true, 16 | "arguments": [ 17 | { 18 | "name": "reason", 19 | "type": "pure-token", 20 | "token": "reason" 21 | } 22 | ] 23 | } 24 | 25 | ] 26 | }, 27 | "SM.SET": { 28 | "summary": "Imports a state machine from a json blob", 29 | "since": "0.1.0", 30 | "complexity": "O(N)", 31 | "group": "statemachine", 32 | "arguments": [ 33 | { 34 | "name": "key", 35 | "type": "key" 36 | }, 37 | { 38 | "name": "value", 39 | "type": "string" 40 | } 41 | ] 42 | }, 43 | "SM.RESET": { 44 | "summary": "Resets a state machine to its initial state", 45 | "since": "0.1.0", 46 | "complexity": "O(N)", 47 | "group": "statemachine", 48 | "arguments": [ 49 | { 50 | "name": "key", 51 | "type": "key" 52 | } 53 | ] 54 | }, 55 | "SM.STATE": { 56 | "summary": "Retrieves the current state machine state", 57 | "since": "0.1.0", 58 | "complexity": "O(N)", 59 | "group": "statemachine", 60 | "arguments": [ 61 | { 62 | "name": "key", 63 | "type": "key" 64 | }, 65 | { 66 | "name": "codition", 67 | "type": "string", 68 | "optional": true, 69 | "arguments": [ 70 | { 71 | "name": "list", 72 | "type": "pure-token", 73 | "token": "LIST" 74 | } 75 | ] 76 | } 77 | 78 | ] 79 | }, 80 | "SM.CREATE": { 81 | "summary": "Creates a blank state machine and stores it in the named key", 82 | "since": "0.1.0", 83 | "complexity": "O(N)", 84 | "group": "statemachine", 85 | "arity": 2, 86 | "arguments": [ 87 | { 88 | "name": "key", 89 | "type": "key" 90 | } 91 | ] 92 | }, 93 | "SM.TEMPLATE": { 94 | "summary": "Return the json template used for constructing a state machine", 95 | "since": "0.1.0", 96 | "complexity": "O(1)", 97 | "group": "statemachine", 98 | "arity": 1 99 | }, 100 | "SM.MUTATE": { 101 | "summary": "Transition the state machine to the specific state", 102 | "since": "0.1.0", 103 | "complexity": "O(1)", 104 | "group": "statemachine", 105 | "arguments": [ 106 | { 107 | "name": "key", 108 | "type": "key" 109 | }, 110 | { 111 | "name": "state", 112 | "type": "string" 113 | }, 114 | { 115 | "name": "condition", 116 | "type": "string", 117 | "optional": true, 118 | "arguments": [ 119 | { 120 | "name": "reason", 121 | "type": "string" 122 | }, 123 | { 124 | "name": "force", 125 | "type": "pure-token", 126 | "token": "FORCE" 127 | } 128 | ] 129 | } 130 | ] 131 | } 132 | } -------------------------------------------------------------------------------- /licenses/RSALv2.txt: -------------------------------------------------------------------------------- 1 | Redis Source Available License 2.0 dated November 15, 2022 2 | 3 | ## Acceptance 4 | 5 | By using the software, you agree to all of the terms and conditions below. 6 | 7 | ## Copyright License 8 | 9 | The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below. 10 | 11 | ## Limitations 12 | 13 | You may not make the functionality of the software or a modified version available to third parties as a service, or distribute the software or a modified version in a manner that makes the functionality of the software available to third parties. 14 | Making the functionality of the software or modified version available to third parties includes, without limitation, enabling third parties to interact with the functionality of the software or modified version in distributed form or remotely through a computer network, offering a product or service the value of which entirely or primarily derives from the value of the software or modified version, or offering a product or service that accomplishes for users the primary purpose of the software or modified version. 15 | 16 | You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law. 17 | 18 | ## Patents 19 | 20 | The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company. 21 | 22 | ## Notices 23 | 24 | You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms. 25 | If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software. 26 | 27 | ## No Other Rights 28 | 29 | These terms do not imply any licenses other than those expressly granted in these terms. 30 | Termination 31 | 32 | If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violations of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently. 33 | 34 | ## No Liability 35 | 36 | As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim. 37 | 38 | ## Definitions 39 | 40 | The licensor is the entity offering these terms, and the software is the software the licensor makes available under these terms, including any portion of it. 41 | 42 | To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission other than making an exact copy. The resulting work is called a modified version of the earlier work. 43 | 44 | you refers to the individual or entity agreeing to these terms. 45 | 46 | your company is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. control means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect. 47 | 48 | your licenses are all the licenses granted to you for the software under these terms. 49 | 50 | use means anything you do with the software requiring one of your licenses. 51 | 52 | trademark means trademarks, service marks, and similar rights. 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /licenses/SSPLv1.txt: -------------------------------------------------------------------------------- 1 | Server Side Public License 2 | VERSION 1, OCTOBER 16, 2018 3 | 4 | Copyright © 2018 MongoDB, Inc. 5 | 6 | Everyone is permitted to copy and distribute verbatim copies of this 7 | license document, but changing it is not allowed. 8 | 9 | TERMS AND CONDITIONS 10 | 11 | 0. Definitions. 12 | 13 | “This License” refers to Server Side Public License. 14 | 15 | “Copyright” also means copyright-like laws that apply to other kinds of 16 | works, such as semiconductor masks. 17 | 18 | “The Program” refers to any copyrightable work licensed under this 19 | License. Each licensee is addressed as “you”. “Licensees” and 20 | “recipients” may be individuals or organizations. 21 | 22 | To “modify” a work means to copy from or adapt all or part of the work in 23 | a fashion requiring copyright permission, other than the making of an 24 | exact copy. The resulting work is called a “modified version” of the 25 | earlier work or a work “based on” the earlier work. 26 | 27 | A “covered work” means either the unmodified Program or a work based on 28 | the Program. 29 | 30 | To “propagate” a work means to do anything with it that, without 31 | permission, would make you directly or secondarily liable for 32 | infringement under applicable copyright law, except executing it on a 33 | computer or modifying a private copy. Propagation includes copying, 34 | distribution (with or without modification), making available to the 35 | public, and in some countries other activities as well. 36 | 37 | To “convey” a work means any kind of propagation that enables other 38 | parties to make or receive copies. Mere interaction with a user through a 39 | computer network, with no transfer of a copy, is not conveying. 40 | 41 | An interactive user interface displays “Appropriate Legal Notices” to the 42 | extent that it includes a convenient and prominently visible feature that 43 | (1) displays an appropriate copyright notice, and (2) tells the user that 44 | there is no warranty for the work (except to the extent that warranties 45 | are provided), that licensees may convey the work under this License, and 46 | how to view a copy of this License. If the interface presents a list of 47 | user commands or options, such as a menu, a prominent item in the list 48 | meets this criterion. 49 | 50 | 1. Source Code. 51 | 52 | The “source code” for a work means the preferred form of the work for 53 | making modifications to it. “Object code” means any non-source form of a 54 | work. 55 | 56 | A “Standard Interface” means an interface that either is an official 57 | standard defined by a recognized standards body, or, in the case of 58 | interfaces specified for a particular programming language, one that is 59 | widely used among developers working in that language. The “System 60 | Libraries” of an executable work include anything, other than the work as 61 | a whole, that (a) is included in the normal form of packaging a Major 62 | Component, but which is not part of that Major Component, and (b) serves 63 | only to enable use of the work with that Major Component, or to implement 64 | a Standard Interface for which an implementation is available to the 65 | public in source code form. A “Major Component”, in this context, means a 66 | major essential component (kernel, window system, and so on) of the 67 | specific operating system (if any) on which the executable work runs, or 68 | a compiler used to produce the work, or an object code interpreter used 69 | to run it. 70 | 71 | The “Corresponding Source” for a work in object code form means all the 72 | source code needed to generate, install, and (for an executable work) run 73 | the object code and to modify the work, including scripts to control 74 | those activities. However, it does not include the work's System 75 | Libraries, or general-purpose tools or generally available free programs 76 | which are used unmodified in performing those activities but which are 77 | not part of the work. For example, Corresponding Source includes 78 | interface definition files associated with source files for the work, and 79 | the source code for shared libraries and dynamically linked subprograms 80 | that the work is specifically designed to require, such as by intimate 81 | data communication or control flow between those subprograms and other 82 | parts of the work. 83 | 84 | The Corresponding Source need not include anything that users can 85 | regenerate automatically from other parts of the Corresponding Source. 86 | 87 | The Corresponding Source for a work in source code form is that same work. 88 | 89 | 2. Basic Permissions. 90 | 91 | All rights granted under this License are granted for the term of 92 | copyright on the Program, and are irrevocable provided the stated 93 | conditions are met. This License explicitly affirms your unlimited 94 | permission to run the unmodified Program, subject to section 13. The 95 | output from running a covered work is covered by this License only if the 96 | output, given its content, constitutes a covered work. This License 97 | acknowledges your rights of fair use or other equivalent, as provided by 98 | copyright law. Subject to section 13, you may make, run and propagate 99 | covered works that you do not convey, without conditions so long as your 100 | license otherwise remains in force. You may convey covered works to 101 | others for the sole purpose of having them make modifications exclusively 102 | for you, or provide you with facilities for running those works, provided 103 | that you comply with the terms of this License in conveying all 104 | material for which you do not control copyright. Those thus making or 105 | running the covered works for you must do so exclusively on your 106 | behalf, under your direction and control, on terms that prohibit them 107 | from making any copies of your copyrighted material outside their 108 | relationship with you. 109 | 110 | Conveying under any other circumstances is permitted solely under the 111 | conditions stated below. Sublicensing is not allowed; section 10 makes it 112 | unnecessary. 113 | 114 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 115 | 116 | No covered work shall be deemed part of an effective technological 117 | measure under any applicable law fulfilling obligations under article 11 118 | of the WIPO copyright treaty adopted on 20 December 1996, or similar laws 119 | prohibiting or restricting circumvention of such measures. 120 | 121 | When you convey a covered work, you waive any legal power to forbid 122 | circumvention of technological measures to the extent such circumvention is 123 | effected by exercising rights under this License with respect to the 124 | covered work, and you disclaim any intention to limit operation or 125 | modification of the work as a means of enforcing, against the work's users, 126 | your or third parties' legal rights to forbid circumvention of 127 | technological measures. 128 | 129 | 4. Conveying Verbatim Copies. 130 | 131 | You may convey verbatim copies of the Program's source code as you 132 | receive it, in any medium, provided that you conspicuously and 133 | appropriately publish on each copy an appropriate copyright notice; keep 134 | intact all notices stating that this License and any non-permissive terms 135 | added in accord with section 7 apply to the code; keep intact all notices 136 | of the absence of any warranty; and give all recipients a copy of this 137 | License along with the Program. You may charge any price or no price for 138 | each copy that you convey, and you may offer support or warranty 139 | protection for a fee. 140 | 141 | 5. Conveying Modified Source Versions. 142 | 143 | You may convey a work based on the Program, or the modifications to 144 | produce it from the Program, in the form of source code under the terms 145 | of section 4, provided that you also meet all of these conditions: 146 | 147 | a) The work must carry prominent notices stating that you modified it, 148 | and giving a relevant date. 149 | 150 | b) The work must carry prominent notices stating that it is released 151 | under this License and any conditions added under section 7. This 152 | requirement modifies the requirement in section 4 to “keep intact all 153 | notices”. 154 | 155 | c) You must license the entire work, as a whole, under this License to 156 | anyone who comes into possession of a copy. This License will therefore 157 | apply, along with any applicable section 7 additional terms, to the 158 | whole of the work, and all its parts, regardless of how they are 159 | packaged. This License gives no permission to license the work in any 160 | other way, but it does not invalidate such permission if you have 161 | separately received it. 162 | 163 | d) If the work has interactive user interfaces, each must display 164 | Appropriate Legal Notices; however, if the Program has interactive 165 | interfaces that do not display Appropriate Legal Notices, your work 166 | need not make them do so. 167 | 168 | A compilation of a covered work with other separate and independent 169 | works, which are not by their nature extensions of the covered work, and 170 | which are not combined with it such as to form a larger program, in or on 171 | a volume of a storage or distribution medium, is called an “aggregate” if 172 | the compilation and its resulting copyright are not used to limit the 173 | access or legal rights of the compilation's users beyond what the 174 | individual works permit. Inclusion of a covered work in an aggregate does 175 | not cause this License to apply to the other parts of the aggregate. 176 | 177 | 6. Conveying Non-Source Forms. 178 | 179 | You may convey a covered work in object code form under the terms of 180 | sections 4 and 5, provided that you also convey the machine-readable 181 | Corresponding Source under the terms of this License, in one of these 182 | ways: 183 | 184 | a) Convey the object code in, or embodied in, a physical product 185 | (including a physical distribution medium), accompanied by the 186 | Corresponding Source fixed on a durable physical medium customarily 187 | used for software interchange. 188 | 189 | b) Convey the object code in, or embodied in, a physical product 190 | (including a physical distribution medium), accompanied by a written 191 | offer, valid for at least three years and valid for as long as you 192 | offer spare parts or customer support for that product model, to give 193 | anyone who possesses the object code either (1) a copy of the 194 | Corresponding Source for all the software in the product that is 195 | covered by this License, on a durable physical medium customarily used 196 | for software interchange, for a price no more than your reasonable cost 197 | of physically performing this conveying of source, or (2) access to 198 | copy the Corresponding Source from a network server at no charge. 199 | 200 | c) Convey individual copies of the object code with a copy of the 201 | written offer to provide the Corresponding Source. This alternative is 202 | allowed only occasionally and noncommercially, and only if you received 203 | the object code with such an offer, in accord with subsection 6b. 204 | 205 | d) Convey the object code by offering access from a designated place 206 | (gratis or for a charge), and offer equivalent access to the 207 | Corresponding Source in the same way through the same place at no 208 | further charge. You need not require recipients to copy the 209 | Corresponding Source along with the object code. If the place to copy 210 | the object code is a network server, the Corresponding Source may be on 211 | a different server (operated by you or a third party) that supports 212 | equivalent copying facilities, provided you maintain clear directions 213 | next to the object code saying where to find the Corresponding Source. 214 | Regardless of what server hosts the Corresponding Source, you remain 215 | obligated to ensure that it is available for as long as needed to 216 | satisfy these requirements. 217 | 218 | e) Convey the object code using peer-to-peer transmission, provided you 219 | inform other peers where the object code and Corresponding Source of 220 | the work are being offered to the general public at no charge under 221 | subsection 6d. 222 | 223 | A separable portion of the object code, whose source code is excluded 224 | from the Corresponding Source as a System Library, need not be included 225 | in conveying the object code work. 226 | 227 | A “User Product” is either (1) a “consumer product”, which means any 228 | tangible personal property which is normally used for personal, family, 229 | or household purposes, or (2) anything designed or sold for incorporation 230 | into a dwelling. In determining whether a product is a consumer product, 231 | doubtful cases shall be resolved in favor of coverage. For a particular 232 | product received by a particular user, “normally used” refers to a 233 | typical or common use of that class of product, regardless of the status 234 | of the particular user or of the way in which the particular user 235 | actually uses, or expects or is expected to use, the product. A product 236 | is a consumer product regardless of whether the product has substantial 237 | commercial, industrial or non-consumer uses, unless such uses represent 238 | the only significant mode of use of the product. 239 | 240 | “Installation Information” for a User Product means any methods, 241 | procedures, authorization keys, or other information required to install 242 | and execute modified versions of a covered work in that User Product from 243 | a modified version of its Corresponding Source. The information must 244 | suffice to ensure that the continued functioning of the modified object 245 | code is in no case prevented or interfered with solely because 246 | modification has been made. 247 | 248 | If you convey an object code work under this section in, or with, or 249 | specifically for use in, a User Product, and the conveying occurs as part 250 | of a transaction in which the right of possession and use of the User 251 | Product is transferred to the recipient in perpetuity or for a fixed term 252 | (regardless of how the transaction is characterized), the Corresponding 253 | Source conveyed under this section must be accompanied by the 254 | Installation Information. But this requirement does not apply if neither 255 | you nor any third party retains the ability to install modified object 256 | code on the User Product (for example, the work has been installed in 257 | ROM). 258 | 259 | The requirement to provide Installation Information does not include a 260 | requirement to continue to provide support service, warranty, or updates 261 | for a work that has been modified or installed by the recipient, or for 262 | the User Product in which it has been modified or installed. Access 263 | to a network may be denied when the modification itself materially 264 | and adversely affects the operation of the network or violates the 265 | rules and protocols for communication across the network. 266 | 267 | Corresponding Source conveyed, and Installation Information provided, in 268 | accord with this section must be in a format that is publicly documented 269 | (and with an implementation available to the public in source code form), 270 | and must require no special password or key for unpacking, reading or 271 | copying. 272 | 273 | 7. Additional Terms. 274 | 275 | “Additional permissions” are terms that supplement the terms of this 276 | License by making exceptions from one or more of its conditions. 277 | Additional permissions that are applicable to the entire Program shall be 278 | treated as though they were included in this License, to the extent that 279 | they are valid under applicable law. If additional permissions apply only 280 | to part of the Program, that part may be used separately under those 281 | permissions, but the entire Program remains governed by this License 282 | without regard to the additional permissions. When you convey a copy of 283 | a covered work, you may at your option remove any additional permissions 284 | from that copy, or from any part of it. (Additional permissions may be 285 | written to require their own removal in certain cases when you modify the 286 | work.) You may place additional permissions on material, added by you to 287 | a covered work, for which you have or can give appropriate copyright 288 | permission. 289 | 290 | Notwithstanding any other provision of this License, for material you add 291 | to a covered work, you may (if authorized by the copyright holders of 292 | that material) supplement the terms of this License with terms: 293 | 294 | a) Disclaiming warranty or limiting liability differently from the 295 | terms of sections 15 and 16 of this License; or 296 | 297 | b) Requiring preservation of specified reasonable legal notices or 298 | author attributions in that material or in the Appropriate Legal 299 | Notices displayed by works containing it; or 300 | 301 | c) Prohibiting misrepresentation of the origin of that material, or 302 | requiring that modified versions of such material be marked in 303 | reasonable ways as different from the original version; or 304 | 305 | d) Limiting the use for publicity purposes of names of licensors or 306 | authors of the material; or 307 | 308 | e) Declining to grant rights under trademark law for use of some trade 309 | names, trademarks, or service marks; or 310 | 311 | f) Requiring indemnification of licensors and authors of that material 312 | by anyone who conveys the material (or modified versions of it) with 313 | contractual assumptions of liability to the recipient, for any 314 | liability that these contractual assumptions directly impose on those 315 | licensors and authors. 316 | 317 | All other non-permissive additional terms are considered “further 318 | restrictions” within the meaning of section 10. If the Program as you 319 | received it, or any part of it, contains a notice stating that it is 320 | governed by this License along with a term that is a further restriction, 321 | you may remove that term. If a license document contains a further 322 | restriction but permits relicensing or conveying under this License, you 323 | may add to a covered work material governed by the terms of that license 324 | document, provided that the further restriction does not survive such 325 | relicensing or conveying. 326 | 327 | If you add terms to a covered work in accord with this section, you must 328 | place, in the relevant source files, a statement of the additional terms 329 | that apply to those files, or a notice indicating where to find the 330 | applicable terms. Additional terms, permissive or non-permissive, may be 331 | stated in the form of a separately written license, or stated as 332 | exceptions; the above requirements apply either way. 333 | 334 | 8. Termination. 335 | 336 | You may not propagate or modify a covered work except as expressly 337 | provided under this License. Any attempt otherwise to propagate or modify 338 | it is void, and will automatically terminate your rights under this 339 | License (including any patent licenses granted under the third paragraph 340 | of section 11). 341 | 342 | However, if you cease all violation of this License, then your license 343 | from a particular copyright holder is reinstated (a) provisionally, 344 | unless and until the copyright holder explicitly and finally terminates 345 | your license, and (b) permanently, if the copyright holder fails to 346 | notify you of the violation by some reasonable means prior to 60 days 347 | after the cessation. 348 | 349 | Moreover, your license from a particular copyright holder is reinstated 350 | permanently if the copyright holder notifies you of the violation by some 351 | reasonable means, this is the first time you have received notice of 352 | violation of this License (for any work) from that copyright holder, and 353 | you cure the violation prior to 30 days after your receipt of the notice. 354 | 355 | Termination of your rights under this section does not terminate the 356 | licenses of parties who have received copies or rights from you under 357 | this License. If your rights have been terminated and not permanently 358 | reinstated, you do not qualify to receive new licenses for the same 359 | material under section 10. 360 | 361 | 9. Acceptance Not Required for Having Copies. 362 | 363 | You are not required to accept this License in order to receive or run a 364 | copy of the Program. Ancillary propagation of a covered work occurring 365 | solely as a consequence of using peer-to-peer transmission to receive a 366 | copy likewise does not require acceptance. However, nothing other than 367 | this License grants you permission to propagate or modify any covered 368 | work. These actions infringe copyright if you do not accept this License. 369 | Therefore, by modifying or propagating a covered work, you indicate your 370 | acceptance of this License to do so. 371 | 372 | 10. Automatic Licensing of Downstream Recipients. 373 | 374 | Each time you convey a covered work, the recipient automatically receives 375 | a license from the original licensors, to run, modify and propagate that 376 | work, subject to this License. You are not responsible for enforcing 377 | compliance by third parties with this License. 378 | 379 | An “entity transaction” is a transaction transferring control of an 380 | organization, or substantially all assets of one, or subdividing an 381 | organization, or merging organizations. If propagation of a covered work 382 | results from an entity transaction, each party to that transaction who 383 | receives a copy of the work also receives whatever licenses to the work 384 | the party's predecessor in interest had or could give under the previous 385 | paragraph, plus a right to possession of the Corresponding Source of the 386 | work from the predecessor in interest, if the predecessor has it or can 387 | get it with reasonable efforts. 388 | 389 | You may not impose any further restrictions on the exercise of the rights 390 | granted or affirmed under this License. For example, you may not impose a 391 | license fee, royalty, or other charge for exercise of rights granted 392 | under this License, and you may not initiate litigation (including a 393 | cross-claim or counterclaim in a lawsuit) alleging that any patent claim 394 | is infringed by making, using, selling, offering for sale, or importing 395 | the Program or any portion of it. 396 | 397 | 11. Patents. 398 | 399 | A “contributor” is a copyright holder who authorizes use under this 400 | License of the Program or a work on which the Program is based. The work 401 | thus licensed is called the contributor's “contributor version”. 402 | 403 | A contributor's “essential patent claims” are all patent claims owned or 404 | controlled by the contributor, whether already acquired or hereafter 405 | acquired, that would be infringed by some manner, permitted by this 406 | License, of making, using, or selling its contributor version, but do not 407 | include claims that would be infringed only as a consequence of further 408 | modification of the contributor version. For purposes of this definition, 409 | “control” includes the right to grant patent sublicenses in a manner 410 | consistent with the requirements of this License. 411 | 412 | Each contributor grants you a non-exclusive, worldwide, royalty-free 413 | patent license under the contributor's essential patent claims, to make, 414 | use, sell, offer for sale, import and otherwise run, modify and propagate 415 | the contents of its contributor version. 416 | 417 | In the following three paragraphs, a “patent license” is any express 418 | agreement or commitment, however denominated, not to enforce a patent 419 | (such as an express permission to practice a patent or covenant not to 420 | sue for patent infringement). To “grant” such a patent license to a party 421 | means to make such an agreement or commitment not to enforce a patent 422 | against the party. 423 | 424 | If you convey a covered work, knowingly relying on a patent license, and 425 | the Corresponding Source of the work is not available for anyone to copy, 426 | free of charge and under the terms of this License, through a publicly 427 | available network server or other readily accessible means, then you must 428 | either (1) cause the Corresponding Source to be so available, or (2) 429 | arrange to deprive yourself of the benefit of the patent license for this 430 | particular work, or (3) arrange, in a manner consistent with the 431 | requirements of this License, to extend the patent license to downstream 432 | recipients. “Knowingly relying” means you have actual knowledge that, but 433 | for the patent license, your conveying the covered work in a country, or 434 | your recipient's use of the covered work in a country, would infringe 435 | one or more identifiable patents in that country that you have reason 436 | to believe are valid. 437 | 438 | If, pursuant to or in connection with a single transaction or 439 | arrangement, you convey, or propagate by procuring conveyance of, a 440 | covered work, and grant a patent license to some of the parties receiving 441 | the covered work authorizing them to use, propagate, modify or convey a 442 | specific copy of the covered work, then the patent license you grant is 443 | automatically extended to all recipients of the covered work and works 444 | based on it. 445 | 446 | A patent license is “discriminatory” if it does not include within the 447 | scope of its coverage, prohibits the exercise of, or is conditioned on 448 | the non-exercise of one or more of the rights that are specifically 449 | granted under this License. You may not convey a covered work if you are 450 | a party to an arrangement with a third party that is in the business of 451 | distributing software, under which you make payment to the third party 452 | based on the extent of your activity of conveying the work, and under 453 | which the third party grants, to any of the parties who would receive the 454 | covered work from you, a discriminatory patent license (a) in connection 455 | with copies of the covered work conveyed by you (or copies made from 456 | those copies), or (b) primarily for and in connection with specific 457 | products or compilations that contain the covered work, unless you 458 | entered into that arrangement, or that patent license was granted, prior 459 | to 28 March 2007. 460 | 461 | Nothing in this License shall be construed as excluding or limiting any 462 | implied license or other defenses to infringement that may otherwise be 463 | available to you under applicable patent law. 464 | 465 | 12. No Surrender of Others' Freedom. 466 | 467 | If conditions are imposed on you (whether by court order, agreement or 468 | otherwise) that contradict the conditions of this License, they do not 469 | excuse you from the conditions of this License. If you cannot use, 470 | propagate or convey a covered work so as to satisfy simultaneously your 471 | obligations under this License and any other pertinent obligations, then 472 | as a consequence you may not use, propagate or convey it at all. For 473 | example, if you agree to terms that obligate you to collect a royalty for 474 | further conveying from those to whom you convey the Program, the only way 475 | you could satisfy both those terms and this License would be to refrain 476 | entirely from conveying the Program. 477 | 478 | 13. Offering the Program as a Service. 479 | 480 | If you make the functionality of the Program or a modified version 481 | available to third parties as a service, you must make the Service Source 482 | Code available via network download to everyone at no charge, under the 483 | terms of this License. Making the functionality of the Program or 484 | modified version available to third parties as a service includes, 485 | without limitation, enabling third parties to interact with the 486 | functionality of the Program or modified version remotely through a 487 | computer network, offering a service the value of which entirely or 488 | primarily derives from the value of the Program or modified version, or 489 | offering a service that accomplishes for users the primary purpose of the 490 | Program or modified version. 491 | 492 | “Service Source Code” means the Corresponding Source for the Program or 493 | the modified version, and the Corresponding Source for all programs that 494 | you use to make the Program or modified version available as a service, 495 | including, without limitation, management software, user interfaces, 496 | application program interfaces, automation software, monitoring software, 497 | backup software, storage software and hosting software, all such that a 498 | user could run an instance of the service using the Service Source Code 499 | you make available. 500 | 501 | 14. Revised Versions of this License. 502 | 503 | MongoDB, Inc. may publish revised and/or new versions of the Server Side 504 | Public License from time to time. Such new versions will be similar in 505 | spirit to the present version, but may differ in detail to address new 506 | problems or concerns. 507 | 508 | Each version is given a distinguishing version number. If the Program 509 | specifies that a certain numbered version of the Server Side Public 510 | License “or any later version” applies to it, you have the option of 511 | following the terms and conditions either of that numbered version or of 512 | any later version published by MongoDB, Inc. If the Program does not 513 | specify a version number of the Server Side Public License, you may 514 | choose any version ever published by MongoDB, Inc. 515 | 516 | If the Program specifies that a proxy can decide which future versions of 517 | the Server Side Public License can be used, that proxy's public statement 518 | of acceptance of a version permanently authorizes you to choose that 519 | version for the Program. 520 | 521 | Later license versions may give you additional or different permissions. 522 | However, no additional obligations are imposed on any author or copyright 523 | holder as a result of your choosing to follow a later version. 524 | 525 | 15. Disclaimer of Warranty. 526 | 527 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 528 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 529 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY 530 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 531 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 532 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 533 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 534 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 535 | 536 | 16. Limitation of Liability. 537 | 538 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 539 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 540 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING 541 | ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF 542 | THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO 543 | LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU 544 | OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 545 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 546 | POSSIBILITY OF SUCH DAMAGES. 547 | 548 | 17. Interpretation of Sections 15 and 16. 549 | 550 | If the disclaimer of warranty and limitation of liability provided above 551 | cannot be given local legal effect according to their terms, reviewing 552 | courts shall apply local law that most closely approximates an absolute 553 | waiver of all civil liability in connection with the Program, unless a 554 | warranty or assumption of liability accompanies a copy of the Program in 555 | return for a fee. 556 | 557 | END OF TERMS AND CONDITIONS 558 | 559 | 560 | 561 | 562 | 563 | Elastic License 2.0 564 | 565 | URL: https://www.elastic.co/licensing/elastic-license 566 | 567 | ## Acceptance 568 | 569 | By using the software, you agree to all of the terms and conditions below. 570 | 571 | ## Copyright License 572 | 573 | The licensor grants you a non-exclusive, royalty-free, worldwide, 574 | non-sublicensable, non-transferable license to use, copy, distribute, make 575 | available, and prepare derivative works of the software, in each case subject to 576 | the limitations and conditions below. 577 | 578 | ## Limitations 579 | 580 | You may not provide the software to third parties as a hosted or managed 581 | service, where the service provides users with access to any substantial set of 582 | the features or functionality of the software. 583 | 584 | You may not move, change, disable, or circumvent the license key functionality 585 | in the software, and you may not remove or obscure any functionality in the 586 | software that is protected by the license key. 587 | 588 | You may not alter, remove, or obscure any licensing, copyright, or other notices 589 | of the licensor in the software. Any use of the licensor’s trademarks is subject 590 | to applicable law. 591 | 592 | ## Patents 593 | 594 | The licensor grants you a license, under any patent claims the licensor can 595 | license, or becomes able to license, to make, have made, use, sell, offer for 596 | sale, import and have imported the software, in each case subject to the 597 | limitations and conditions in this license. This license does not cover any 598 | patent claims that you cause to be infringed by modifications or additions to 599 | the software. If you or your company make any written claim that the software 600 | infringes or contributes to infringement of any patent, your patent license for 601 | the software granted under these terms ends immediately. If your company makes 602 | such a claim, your patent license ends immediately for work on behalf of your 603 | company. 604 | 605 | ## Notices 606 | 607 | You must ensure that anyone who gets a copy of any part of the software from you 608 | also gets a copy of these terms. 609 | 610 | If you modify the software, you must include in any modified copies of the 611 | software prominent notices stating that you have modified the software. 612 | 613 | ## No Other Rights 614 | 615 | These terms do not imply any licenses other than those expressly granted in 616 | these terms. 617 | 618 | ## Termination 619 | 620 | If you use the software in violation of these terms, such use is not licensed, 621 | and your licenses will automatically terminate. If the licensor provides you 622 | with a notice of your violation, and you cease all violation of this license no 623 | later than 30 days after you receive that notice, your licenses will be 624 | reinstated retroactively. However, if you violate these terms after such 625 | reinstatement, any additional violation of these terms will cause your licenses 626 | to terminate automatically and permanently. 627 | 628 | ## No Liability 629 | 630 | *As far as the law allows, the software comes as is, without any warranty or 631 | condition, and the licensor will not be liable to you for any damages arising 632 | out of these terms or the use or nature of the software, under any kind of 633 | legal claim.* 634 | 635 | ## Definitions 636 | 637 | The **licensor** is the entity offering these terms, and the **software** is the 638 | software the licensor makes available under these terms, including any portion 639 | of it. 640 | 641 | **you** refers to the individual or entity agreeing to these terms. 642 | 643 | **your company** is any legal entity, sole proprietorship, or other kind of 644 | organization that you work for, plus all organizations that have control over, 645 | are under the control of, or are under common control with that 646 | organization. **control** means ownership of substantially all the assets of an 647 | entity, or the power to direct its management and policies by vote, contract, or 648 | otherwise. Control can be direct or indirect. 649 | 650 | **your licenses** are all the licenses granted to you for the software under 651 | these terms. 652 | 653 | **use** means anything you do with the software requiring one of your licenses. 654 | 655 | **trademark** means trademarks, service marks, and similar rights. 656 | -------------------------------------------------------------------------------- /ramp.yml: -------------------------------------------------------------------------------- 1 | display_name: RedisStateMachine 2 | description: A state machine capability for your services and data 3 | author: RedisLabs 4 | email: oss@redis.com 5 | homepage: 'https://redis.io' 6 | license: Redis Source Available License Agreement 7 | command_line_args: libredis_state.so 8 | min_redis_verison: '7.0.0' 9 | min_redis_pack_version: '6.2.18' 10 | capabilities: 11 | - types 12 | - backup_restore 13 | - ipv6 14 | - intershard_tls 15 | - intershard_tls_pass 16 | - persistence_rdb 17 | - persistence_aof 18 | - failover_migrate 19 | - replica_of 20 | - clustering 21 | -------------------------------------------------------------------------------- /src/function_get.rs: -------------------------------------------------------------------------------- 1 | use crate::types::{new, StateMachine}; 2 | use crate::REDIS_SM_TYPE; 3 | use redis_module::{ 4 | key::RedisKey, Context, NextArg, RedisError, RedisResult, RedisString, RedisValue, 5 | }; 6 | 7 | pub(crate) fn get(ctx: &Context, args: Vec) -> RedisResult { 8 | let mut args = args.into_iter().skip(1); 9 | let key = args.next_arg()?; 10 | let fieldarg = args.next_arg(); 11 | 12 | let rkey = RedisKey::open(ctx.ctx, &key); 13 | 14 | let v = rkey.get_value::(&REDIS_SM_TYPE)?; 15 | 16 | if v.is_none() { 17 | return Ok(RedisValue::Null); 18 | } 19 | 20 | let rval = serde_json::to_string(&v)?; 21 | if fieldarg.is_err() { 22 | Ok(RedisValue::BulkString(rval)) 23 | } else if fieldarg.unwrap().to_string().to_uppercase() == "REASON" { 24 | let sm = v.unwrap(); 25 | Ok(RedisValue::SimpleString(sm.reason().to_string())) 26 | } else { 27 | Ok(RedisValue::Null) 28 | } 29 | } 30 | 31 | pub(crate) fn template(_ctx: &Context, args: Vec) -> RedisResult { 32 | if args.len() != 1 { 33 | return Err(RedisError::WrongArity); 34 | } 35 | let n = new(); 36 | let rval = serde_json::to_string(&n)?; 37 | Ok(RedisValue::BulkString(rval)) 38 | } 39 | -------------------------------------------------------------------------------- /src/function_set.rs: -------------------------------------------------------------------------------- 1 | use crate::rdb::REDIS_SM_TYPE; 2 | use crate::types::{new, new_from_redisstring, StateMachine}; 3 | use redis_module::{ 4 | key::RedisKeyWritable, Context, NextArg, RedisResult, RedisString, RedisValue, REDIS_OK, 5 | }; 6 | 7 | // Load the state machine from a json string 8 | pub(crate) fn set(ctx: &Context, args: Vec) -> RedisResult { 9 | let mut args = args.into_iter().skip(1); 10 | let key = args.next_arg()?; 11 | let val = args.next_arg()?; 12 | 13 | // If the current state is not specified, then use the initial state 14 | let current = args 15 | .next_arg() 16 | .unwrap_or_else(|_| RedisString::create(std::ptr::null_mut(), "")); 17 | 18 | let mut rval: StateMachine = new_from_redisstring(val)?; 19 | 20 | if !current.is_empty() { 21 | rval.set_current(current.to_string()); 22 | } 23 | if rval.current().is_empty() { 24 | rval.set_current(rval.initial().to_string()); 25 | } 26 | 27 | let rkey = RedisKeyWritable::open(ctx.ctx, &key); 28 | rkey.set_value(&REDIS_SM_TYPE, rval)?; 29 | REDIS_OK 30 | } 31 | 32 | pub(crate) fn create(ctx: &Context, args: Vec) -> RedisResult { 33 | let mut args = args.into_iter().skip(1); 34 | let key = args.next_arg()?; 35 | 36 | let sm = new(); 37 | let rkey = RedisKeyWritable::open(ctx.ctx, &key); 38 | rkey.set_value(&REDIS_SM_TYPE, sm)?; 39 | REDIS_OK 40 | } 41 | 42 | // Reset the state machine to the initial state 43 | pub(crate) fn reset(ctx: &Context, args: Vec) -> RedisResult { 44 | let mut args = args.into_iter().skip(1); 45 | let key = args.next_arg()?; 46 | 47 | let rkey = RedisKeyWritable::open(ctx.ctx, &key); 48 | let v = rkey.get_value::(&REDIS_SM_TYPE)?; 49 | 50 | if let Some(rval) = v { 51 | rval.set_current(rval.initial().to_string()); 52 | REDIS_OK 53 | } else { 54 | Ok(RedisValue::Null) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/function_state.rs: -------------------------------------------------------------------------------- 1 | use crate::types::StateMachine; 2 | use crate::REDIS_SM_TYPE; 3 | use redis_module::{ 4 | key::{RedisKey, RedisKeyWritable}, 5 | Context, NextArg, RedisError, RedisResult, RedisString, RedisValue, REDIS_OK, 6 | }; 7 | 8 | pub(crate) fn state(ctx: &Context, args: Vec) -> RedisResult { 9 | let mut args = args.into_iter().skip(1); 10 | 11 | let key = args.next_arg()?; 12 | let list = args.next_arg(); 13 | 14 | let rkey = RedisKey::open(ctx.ctx, &key); 15 | let value = rkey.get_value::(&REDIS_SM_TYPE)?; 16 | 17 | if value.is_none() { 18 | return Ok(RedisValue::Null); 19 | } 20 | 21 | let sm = value.unwrap(); 22 | let mut keys: Vec = Vec::new(); 23 | if list.is_ok() { 24 | for x in sm.map().keys() { 25 | keys.push(RedisValue::SimpleString(x.to_string())); 26 | } 27 | } else { 28 | keys.push(RedisValue::SimpleString(sm.current().to_string())); 29 | } 30 | Ok(RedisValue::Array(keys)) 31 | } 32 | 33 | pub(crate) fn mutate(ctx: &Context, args: Vec) -> RedisResult { 34 | let mut args = args.into_iter().skip(1); 35 | let key = args.next_arg()?; 36 | let target = args.next_arg()?; 37 | 38 | let maybe_reason = args.next_arg(); 39 | let maybe_options = args.next_arg(); 40 | 41 | let rkey = RedisKeyWritable::open(ctx.ctx, &key); 42 | let value = rkey.get_value::(&REDIS_SM_TYPE)?; 43 | 44 | if value.is_none() { 45 | return Ok(RedisValue::Null); 46 | } 47 | 48 | let sm = value.unwrap(); 49 | if !sm.is_valid_state(target.to_string()) { 50 | return Err(RedisError::String("Invaild state transition".to_string())); 51 | } 52 | 53 | let res = sm.can_transition(target.to_string()); 54 | 55 | if let Ok(options) = maybe_options { 56 | if options.to_string().to_uppercase() != "FORCE" { 57 | return Err(RedisError::String("Invaild command option".to_string())); 58 | } 59 | } else if !res { 60 | return Err(RedisError::String("Invaild state transition".to_string())); 61 | } 62 | 63 | sm.set_current(target.to_string()); 64 | if let Ok(value) = maybe_reason { 65 | sm.set_reason(value.to_string()); 66 | } 67 | REDIS_OK 68 | } 69 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | use rdb::REDIS_SM_TYPE; 2 | 3 | #[macro_use] 4 | extern crate redis_module; 5 | 6 | pub const REDIS_SM_TYPE_VERSION: i32 = 1; 7 | pub const MODULE_NAME: &str = "RedisStateMachine"; 8 | pub const MODULE_TYPE: &str = "RedisStateMachine"; 9 | 10 | mod function_get; 11 | mod function_set; 12 | mod function_state; 13 | mod rdb; 14 | mod types; 15 | 16 | redis_module! { 17 | name: "redisstate", 18 | version: 1, 19 | data_types: [REDIS_SM_TYPE], 20 | commands: [ 21 | ["SM.GET", function_get::get, "readonly", 0, 0, 0], 22 | ["SM.SET", function_set::set, "write deny-oom", 1, 1, 1], 23 | ["SM.STATE", function_state::state, "readonly", 0, 0, 0], 24 | // ["SM.STATES", function_state::states, "readonly", 0, 0, 0], 25 | ["SM.CREATE", function_set::create, "write deny-oom", 1, 1, 1], 26 | ["SM.TEMPLATE", function_get::template, "readonly", 0, 0, 0], 27 | ["SM.RESET", function_set::reset, "write deny-oom", 1, 1, 1], 28 | ["SM.MUTATE", function_state::mutate, "write deny-oom", 1, 1, 1], 29 | ], 30 | } 31 | -------------------------------------------------------------------------------- /src/rdb.rs: -------------------------------------------------------------------------------- 1 | use redis_module::{native_types::RedisType, RedisModuleTypeMethods, REDISMODULE_AUX_BEFORE_RDB}; 2 | 3 | use redis_module::raw; 4 | use std::mem; 5 | use std::os::raw::{c_int, c_void}; 6 | use std::ptr::null_mut; 7 | 8 | use crate::types::{new_from_redisstring, StateMachine}; 9 | 10 | pub(crate) static REDIS_SM_VERSION: i32 = 1; 11 | pub(crate) static REDIS_SM_TYPE: RedisType = RedisType::new( 12 | "StateType", 13 | REDIS_SM_VERSION, 14 | RedisModuleTypeMethods { 15 | version: redis_module::TYPE_METHOD_VERSION, 16 | rdb_load: Some(rdb_load), 17 | rdb_save: Some(rdb_save), 18 | aof_rewrite: None, 19 | free: Some(free), 20 | mem_usage: Some(mem_usage), 21 | digest: None, 22 | aux_load: None, 23 | aux_save: None, 24 | aux_save_triggers: REDISMODULE_AUX_BEFORE_RDB as i32, 25 | free_effort: None, 26 | unlink: None, 27 | copy: Some(copy), 28 | defrag: None, 29 | }, 30 | ); 31 | 32 | unsafe extern "C" fn rdb_save(rdb: *mut raw::RedisModuleIO, value: *mut c_void) { 33 | let v = &*value.cast::(); 34 | raw::save_string(rdb, &serde_json::to_string(&v).unwrap()); 35 | } 36 | 37 | unsafe extern "C" fn rdb_load(rdb: *mut raw::RedisModuleIO, _encver: c_int) -> *mut c_void { 38 | let v = raw::load_string(rdb); 39 | if v.is_err() { 40 | return null_mut(); 41 | } 42 | let f = v.unwrap(); 43 | let sm = new_from_redisstring(f); 44 | if sm.is_err() { 45 | return null_mut(); 46 | } 47 | let ff = sm.unwrap(); 48 | let bb = Box::new(ff); 49 | let rawbox = Box::into_raw(bb); 50 | rawbox as *mut c_void 51 | } 52 | 53 | unsafe extern "C" fn mem_usage(value: *const c_void) -> usize { 54 | let sm = unsafe { &*(value as *mut StateMachine) }; 55 | mem::size_of_val(sm) 56 | } 57 | 58 | #[allow(unused)] 59 | unsafe extern "C" fn free(value: *mut c_void) { 60 | if value.is_null() { 61 | return; 62 | } 63 | let sm = value as *mut StateMachine; 64 | Box::from_raw(sm); 65 | } 66 | 67 | #[allow(non_snake_case, unused)] 68 | unsafe extern "C" fn copy( 69 | fromkey: *mut raw::RedisModuleString, 70 | tokey: *mut raw::RedisModuleString, 71 | value: *const c_void, 72 | ) -> *mut c_void { 73 | let sm = &*(value as *mut StateMachine); 74 | let newSm = sm.clone(); 75 | Box::into_raw(Box::new(newSm)).cast::() 76 | } 77 | -------------------------------------------------------------------------------- /src/types.rs: -------------------------------------------------------------------------------- 1 | use redis_module::RedisString; 2 | use serde::{Deserialize, Serialize}; 3 | use serde_json::Error; 4 | use std::collections::HashMap; 5 | 6 | #[derive(Serialize, Deserialize, Debug, Clone)] 7 | pub(crate) struct StateMachine { 8 | current: String, 9 | map: HashMap>, 10 | initial: String, 11 | reason: String, 12 | // TODO store some way for this to never change 13 | } 14 | 15 | pub(crate) fn new_from_redisstring(c: RedisString) -> Result { 16 | serde_json::from_str(&c.to_string()) 17 | } 18 | 19 | pub(crate) fn new() -> StateMachine { 20 | let m: HashMap> = HashMap::new(); 21 | StateMachine { 22 | initial: String::from(""), 23 | current: String::from(""), 24 | map: m, 25 | reason: String::from(""), 26 | } 27 | } 28 | 29 | impl StateMachine { 30 | pub(crate) fn set_current(&mut self, c: String) { 31 | self.current = c; 32 | } 33 | 34 | pub(crate) fn set_reason(&mut self, c: String) { 35 | self.reason = c; 36 | } 37 | 38 | pub(crate) fn can_transition(&self, target: String) -> bool { 39 | let current = String::from(self.current()); 40 | let mapval = self.map.get(¤t); 41 | if mapval.is_none() { 42 | return false; 43 | } 44 | let v = mapval.unwrap(); 45 | v.contains(&target) 46 | } 47 | 48 | pub(crate) fn is_valid_state(&self, target: String) -> bool { 49 | self.map.contains_key(&target) 50 | } 51 | 52 | pub(crate) fn current(&self) -> &str { 53 | &self.current 54 | } 55 | 56 | pub(crate) fn initial(&self) -> &str { 57 | &self.initial 58 | } 59 | 60 | pub(crate) const fn map(&self) -> &HashMap> { 61 | &self.map 62 | } 63 | 64 | pub(crate) fn reason(&self) -> &str { 65 | &self.reason 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /tests/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | import redis 3 | 4 | 5 | redis_url = "redis://localhost:6379/0" 6 | 7 | 8 | def pytest_addoption(parser): 9 | parser.addoption( 10 | "--redis-url", 11 | default=redis_url, 12 | action="store", 13 | help="Redis connection string, defaults to %(default)s", 14 | ) 15 | 16 | 17 | def _get_client( 18 | cls, 19 | request, 20 | flushdb=True, 21 | from_url=None, 22 | ): 23 | if from_url is None: 24 | redis_url = request.config.getoption("--redis-url") 25 | 26 | client = redis.from_url(redis_url, decode_responses=True) 27 | if flushdb: 28 | client.flushdb() 29 | return client 30 | 31 | 32 | @pytest.fixture() 33 | def r(request): 34 | with _get_client(redis.Redis, request) as client: 35 | yield client 36 | -------------------------------------------------------------------------------- /tests/requirements.txt: -------------------------------------------------------------------------------- 1 | pytest 2 | redis 3 | ramp-packer 4 | s3cmd 5 | -------------------------------------------------------------------------------- /tests/test_commands.py: -------------------------------------------------------------------------------- 1 | from redis.exceptions import ResponseError 2 | import pytest 3 | import json 4 | 5 | 6 | def genmap(): 7 | """return a n empty hashmap""" 8 | initial = "begin" 9 | current = "begin" 10 | mapstates = { 11 | "a": ["this", "maps", "states"], 12 | "b": ["this", "too", "maps", "somewhere"], 13 | "begin": ["too", "maps"], 14 | "too": ["b"], 15 | } 16 | 17 | return {"initial": initial, "map": mapstates, "current": current, "reason": ""} 18 | 19 | 20 | def test_invalid_set_get(r): 21 | r.flushdb() 22 | r.set("foo", "bar") 23 | with pytest.raises(ResponseError): 24 | r.execute_command("SM.GET", "foo") 25 | 26 | 27 | def test_set_get(r): 28 | r.flushdb() 29 | 30 | initial = "begin" 31 | current = "somewhere" 32 | mapstates = { 33 | "a": ["this", "maps", "states"], 34 | "b": ["this", "too", "maps", "somewhere"], 35 | } 36 | invalid_mapstates = {"a": "badmap", "b": ["this", "is", "a", "good", "map"]} 37 | invalid_no_current = {"initial": initial, "map": mapstates} 38 | 39 | with pytest.raises(ResponseError): 40 | r.execute_command("SM.SET", "foo", json.dumps(invalid_mapstates)) 41 | r.execute_command( 42 | "SM.SET", "foo", json.dumps({"initial": initial, "map": invalid_mapstates}) 43 | ) 44 | r.execute_command( 45 | "SM.SET", "foo", json.dumps({"current": current, "map": invalid_mapstates}) 46 | ) 47 | r.execute_command( 48 | "SM.SET", "foocurrent", json.dumps(invalid_no_current), current 49 | ) 50 | 51 | sm = genmap() 52 | assert r.execute_command("SM.SET", "bar", json.dumps(sm)) 53 | 54 | bar = json.loads(r.execute_command("SM.GET", "bar")) 55 | assert bar == sm 56 | 57 | 58 | def test_get_current_state(r): 59 | r.flushdb() 60 | assert r.execute_command("SM.SET", "fooforcurrent", json.dumps(genmap())) 61 | assert r.execute_command("SM.STATE", "fooforcurrent") == [genmap()["current"]] 62 | 63 | 64 | def test_get_states(r): 65 | r.flushdb() 66 | sm = genmap() 67 | assert r.execute_command("SM.SET", "foostates", json.dumps(sm)) 68 | states = r.execute_command("SM.STATE", "foostates", "list") 69 | 70 | mapkeys = list(sm["map"].keys()) 71 | mapkeys.sort() 72 | states.sort() 73 | assert mapkeys == states 74 | 75 | 76 | def test_get_reason(r): 77 | r.flushdb() 78 | sm = genmap() 79 | sm["reason"] = "I am the reason just because" 80 | assert r.execute_command("SM.SET", "foostates", json.dumps(sm)) 81 | assert r.execute_command("SM.GET", "foostates", "reason") == sm["reason"] 82 | assert r.execute_command("SM.GET", "foostates", "REASON") == sm["reason"] 83 | 84 | 85 | def test_set_del(r): 86 | r.flushdb() 87 | assert r.execute_command("SM.SET", "foostates", json.dumps(genmap())) 88 | assert r.delete("foostates") 89 | 90 | keys = r.keys() 91 | assert "foostates" not in keys 92 | 93 | 94 | def test_reset(r): 95 | r.flushdb() 96 | sm = genmap() 97 | assert r.execute_command("SM.SET", "foostates", json.dumps(sm)) 98 | r.execute_command("SM.RESET", "foostates") 99 | assert r.execute_command("SM.STATE", "foostates") == [sm["initial"]] 100 | 101 | 102 | def test_create(r): 103 | r.flushdb() 104 | key = "foo" 105 | assert r.execute_command("SM.CREATE", key) 106 | assert r.execute_command("SM.STATE", key) == [""] 107 | res = r.execute_command("SM.GET", key) 108 | val = json.loads(res) 109 | assert val["initial"] == "" 110 | assert val["map"] == {} 111 | assert val["current"] == "" 112 | assert val["reason"] == "" 113 | 114 | 115 | def test_template(r): 116 | res = r.execute_command("SM.TEMPLATE") 117 | val = json.loads(res) 118 | assert val["initial"] == "" 119 | assert val["map"] == {} 120 | assert val["current"] == "" 121 | assert val["reason"] == "" 122 | 123 | 124 | def test_mutate(r): 125 | r.flushdb() 126 | sm = genmap() 127 | assert r.execute_command("SM.SET", "bar", json.dumps(sm)) 128 | 129 | # bad state 130 | with pytest.raises(ResponseError): 131 | assert r.execute_command("SM.MUTATE", "bar", "smurfy") 132 | 133 | # good state 134 | assert r.execute_command("SM.MUTATE", "bar", "too") 135 | assert r.execute_command("SM.MUTATE", "bar", "b", "with a reason!") 136 | assert r.execute_command("SM.GET", "bar", "reason") == "with a reason!" 137 | 138 | r.flushdb() 139 | assert r.execute_command("SM.SET", "bar", json.dumps(sm)) 140 | 141 | # bad forced state 142 | with pytest.raises(ResponseError): 143 | assert r.execute_command("SM.MUTATE", "bar", "smurfy", "FORCE") 144 | assert r.execute_command("SM.MUTATE", "bar", "smurfy", "force") 145 | 146 | # now the force 147 | assert r.execute_command("SM.MUTATE", "bar", "b", "this reason!", "force") 148 | assert r.execute_command("SM.GET", "bar", "reason") == "this reason!" 149 | -------------------------------------------------------------------------------- /tests/test_module_basics.py: -------------------------------------------------------------------------------- 1 | from redis.exceptions import ResponseError 2 | import os 3 | import json 4 | 5 | 6 | def test_check_registered_commands(r): 7 | r.flushdb() 8 | cm = r.info("modules") 9 | found = False 10 | for m in cm.get("modules"): 11 | if m.get("name") == "redisstate": 12 | found = True 13 | break 14 | 15 | assert found 16 | 17 | 18 | def test_commands_registered(r): 19 | r.flushdb() 20 | here = os.path.dirname(__file__) 21 | cmdsjson = os.path.abspath(os.path.join(here, "..", "commands.json")) 22 | cmds = json.load(open(cmdsjson)) 23 | for c in cmds.keys(): 24 | try: 25 | print(f"Testing {c}") 26 | r.execute_command(c) 27 | except ResponseError as e: 28 | assert str(e).find("wrong number of arguments") != -1 29 | -------------------------------------------------------------------------------- /tests/test_rdb.py: -------------------------------------------------------------------------------- 1 | import json 2 | 3 | 4 | def test_memory_usage(r): 5 | r.flushdb() 6 | r.execute_command( 7 | "SM.SET", 8 | "memfoo", 9 | json.dumps( 10 | {"initial": "aval", "map": {"a": ["b", "c"]}, "current": "b", "reason": ""} 11 | ), 12 | ) 13 | assert 150 <= r.memory_usage("memfoo") <= 200 14 | 15 | 16 | def test_copy(r): 17 | r.flushdb() 18 | r.execute_command( 19 | "SM.SET", 20 | "memfoo", 21 | json.dumps( 22 | {"initial": "aval", "map": {"a": ["b", "c"]}, "current": "b", "reason": ""} 23 | ), 24 | ) 25 | assert r.copy("memfoo", "barfoo") 26 | assert r.type("barfoo") == "StateType" 27 | --------------------------------------------------------------------------------