Skip to content

Commit

Permalink
Merge branch 'master' into expire
Browse files Browse the repository at this point in the history
  • Loading branch information
QuChen88 authored Aug 27, 2023
2 parents c9f5526 + 12ba3dd commit ed57a77
Show file tree
Hide file tree
Showing 71 changed files with 7,226 additions and 464 deletions.
34 changes: 26 additions & 8 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ commands:
- run:
name: Setup automation
command: |
export HOMEBREW_NO_AUTO_UPDATE=1
git submodule update --init deps/readies
if [[ $(uname -s) == Darwin ]]; then rm -f /usr/local/bin/python3; fi
./deps/readies/bin/getpy3
- run:
name: Setup automation (part 2)
shell: /bin/bash -l -eo pipefail
command: |
ls -l /usr/local/bin/python* || true
echo "python3: $(command -v python3)"
python3 --version
python3 -m pip list
install-prerequisites:
parameters:
redis_version:
type: string
default: "6"
default: "7.2-rc1"
getredis_params:
type: string
default: ""
Expand All @@ -79,6 +87,7 @@ commands:
name: Install Redis
shell: /bin/bash -l -eo pipefail
command: |
export HOMEBREW_NO_AUTO_UPDATE=1
./deps/readies/bin/getredis -v '<<parameters.redis_version>>' --force <<parameters.getredis_params>>
redis-server --version
Expand All @@ -92,7 +101,7 @@ commands:
default: ""
redis_version:
type: string
default: "6"
default: "7.2-rc1"
getredis_params:
type: string
default: ""
Expand Down Expand Up @@ -192,13 +201,20 @@ jobs:
- vm-build-platforms-steps:
platform: <<parameters.platform>>

build-macos:
build-macos-x64:
macos:
xcode: 12.5.1
xcode: 13.2.1
resource_class: macos.x86.medium.gen2
steps:
- build-steps

build-macos-m1:
macos:
xcode: 14.2.0
resource_class: macos.m1.large.gen1
steps:
- build-steps

#----------------------------------------------------------------------------------------------------------------------------------

on-any-branch: &on-any-branch
Expand Down Expand Up @@ -288,12 +304,14 @@ workflows:
context: common
matrix:
parameters:
platform: [jammy, focal, bionic, xenial, rocky8, centos7, bullseye]
platform: [jammy, focal, bionic, xenial, rocky8, centos7, bullseye, amzn2]
- build-arm-platforms:
<<: *on-integ-and-version-tags
context: common
matrix:
parameters:
platform: [jammy, bionic, focal]
- build-macos:
<<: *on-any-branch
- build-macos-x64:
<<: *always
- build-macos-m1:
<<: *on-integ-and-version-tags
40 changes: 38 additions & 2 deletions .github/workflows/cratesio-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,43 @@ jobs:
key: "package.version"
value: "${{ steps.get_version.outputs.VERSION }}"

- uses: katyo/publish-crates@v1
- name: Set the version for redismodule-rs-macros-internals
uses: ciiiii/toml-editor@1.0.0
with:
file: "Cargo.toml"
key: "dependencies.redis-module-macros-internals"
value: "${{ steps.get_version.outputs.VERSION }}"

- name: Set the version for publishing on macros crate
uses: ciiiii/toml-editor@1.0.0
with:
file: "redismodule-rs-macros/Cargo.toml"
key: "package.version"
value: "${{ steps.get_version.outputs.VERSION }}"

- name: Set the version for publishing on internal macros crate
uses: ciiiii/toml-editor@1.0.0
with:
file: "redismodule-rs-macros-internals/Cargo.toml"
key: "package.version"
value: "${{ steps.get_version.outputs.VERSION }}"

- name: Publishing redismodule-rs-macros-internals
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
path: './redismodule-rs-macros-internals'
args: --allow-dirty

- name: Publishing redismodule-rs
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: --allow-dirty

- name: Publishing redismodule-rs-macros
uses: katyo/publish-crates@v1
with:
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
args: --allow-dirty
path: './redismodule-rs-macros'
args: --allow-dirty
2 changes: 1 addition & 1 deletion .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ jobs:
sh rustup.sh -y
. $HOME/.cargo/env
rustup target add i686-unknown-freebsd
cargo build --all --all-targets --verbose --target i686-unknown-freebsd
cargo build --all --all-targets --verbose --no-default-features --target i686-unknown-freebsd
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Cargo
# will have compiled files and executables
/target/
**/target/

# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Expand All @@ -15,3 +15,9 @@ src/redisraw/bindings.rs

# VS Code
.vscode

# Redis database
dump.rdb

# Debugger-related files:
.gdb_history
79 changes: 60 additions & 19 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ crate-type = ["cdylib"]
name = "string"
crate-type = ["cdylib"]

[[example]]
name = "configuration"
crate-type = ["cdylib"]

[[example]]
name = "proc_macro_commands"
crate-type = ["cdylib"]

[[example]]
name = "acl"
crate-type = ["cdylib"]

[[example]]
name = "call"
crate-type = ["cdylib"]
required-features = ["min-redis-compatibility-version-7-2"]

[[example]]
name = "keys_pos"
Expand All @@ -34,17 +47,14 @@ crate-type = ["cdylib"]
[[example]]
name = "timer"
crate-type = ["cdylib"]
required-features = ["experimental-api"]

[[example]]
name = "threads"
crate-type = ["cdylib"]
required-features = ["experimental-api"]

[[example]]
name = "block"
crate-type = ["cdylib"]
required-features = ["experimental-api"]

[[example]]
name = "data_type"
Expand All @@ -54,20 +64,41 @@ crate-type = ["cdylib"]
name = "load_unload"
crate-type = ["cdylib"]

[[example]]
name = "ctx_flags"
crate-type = ["cdylib"]

[[example]]
name = "server_events"
crate-type = ["cdylib"]

[[example]]
name = "events"
crate-type = ["cdylib"]
required-features = ["experimental-api"]

[[example]]
name = "test_helper"
crate-type = ["cdylib"]
required-features = ["test","experimental-api"]

[[example]]
name = "info_handler_macro"
crate-type = ["cdylib"]

[[example]]
name = "info_handler_builder"
crate-type = ["cdylib"]

[[example]]
name = "info_handler_struct"
crate-type = ["cdylib"]

[[example]]
name = "info_handler_multiple_sections"
crate-type = ["cdylib"]

[[example]]
name = "info"
crate-type = ["cdylib"]
required-features = []

[[example]]
name = "scan_keys"
Expand All @@ -77,29 +108,39 @@ crate-type = ["cdylib"]
name = "stream"
crate-type = ["cdylib"]

[[example]]
name = "response"
crate-type = ["cdylib"]

[dependencies]
bitflags = "1.2"
bitflags = "2"
libc = "0.2"
enum-primitive-derive = "^0.1"
num-traits = "^0.2"
regex = "1"
strum_macros = "0.24"
#failure = "0.1"
backtrace = "0.3"
linkme = "0.3"
serde = { version = "1", features = ["derive"] }
nix = "0.26"
cfg-if = "1"
redis-module-macros-internals = { path = "./redismodule-rs-macros-internals" }
log = "0.4"

[dev-dependencies]
anyhow = "1.0.38"
redis = "0.22.1"
anyhow = "1"
redis = "0.23"
lazy_static = "1"
redis-module-macros = { path = "./redismodule-rs-macros"}
redis-module = { path = "./", default-features = false, features = ["min-redis-compatibility-version-7-2"] }

[build-dependencies]
bindgen = "0.63"
cc = "1.0"
bindgen = "0.66"
cc = "1"

[features]
default = []
experimental-api = []

# Workaround to allow cfg(feature = "test") in dependencies:
# https://github.com/rust-lang/rust/issues/59168#issuecomment-472653680
# This requires running the tests with `--features test`
test = []
default = ["min-redis-compatibility-version-6-0"]
min-redis-compatibility-version-7-2 = []
min-redis-compatibility-version-7-0 = []
min-redis-compatibility-version-6-2 = []
min-redis-compatibility-version-6-0 = []
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# BUILD redisfab/redismodule-rs:${VERSION}-${ARCH}-${OSNICK}

ARG REDIS_VER=6.2.7
ARG REDIS_VER=7.2-rc1

# bullseye|bionic|xenial|centos8|centos7
ARG OSNICK=bullseye
Expand Down
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ RUST_SOEXT.freebsd=so
RUST_SOEXT.macos=dylib

build:
cargo build --features experimental-api,test --all --all-targets $(CARGO_FLAGS)
cargo build --all --all-targets --no-default-features $(CARGO_FLAGS)
# cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)

clean:
Expand All @@ -74,7 +74,8 @@ endif
test: cargo_test

cargo_test:
cargo test --all-targets --features test,experimental-api $(CARGO_FLAGS)
cargo test --workspace --no-default-features $(CARGO_FLAGS)
cargo test --doc --workspace --no-default-features $(CARGO_FLAGS)

.PHONY: test cargo_test

Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
[![license](https://img.shields.io/github/license/RedisLabsModules/redismodule-rs.svg)](https://github.com/RedisLabsModules/redismodule-rs/blob/master/LICENSE)
[![GitHub issues](https://img.shields.io/github/release/RedisLabsModules/redismodule-rs.svg)](https://github.com/RedisLabsModules/redismodule-rs/releases/latest)
[![CircleCI](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master.svg?style=svg)](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master)
[![Releases](https://img.shields.io/github/release/RedisLabsModules/redismodule-rs.svg)](https://github.com/RedisLabsModules/redismodule-rs/releases/latest)
[![crates.io](https://img.shields.io/crates/v/redis-module.svg)](https://crates.io/crates/redis-module)
[![docs](https://docs.rs/redis-module/badge.svg)](https://docs.rs/redis-module)
[![CircleCI](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master.svg?style=svg)](https://circleci.com/gh/RedisLabsModules/redismodule-rs/tree/master)

# redismodule-rs

This crate provides an idiomatic Rust API for the [Redis Modules API](https://redis.io/topics/modules-intro).
It allows writing Redis modules in Rust, without needing to use raw pointers or unsafe code.
It allows writing Redis modules in Rust, without needing to use raw pointers or unsafe code. See [here](https://docs.rs/redis-module/latest) for the most recent API documentation.

# Running the example module

Expand All @@ -31,5 +32,6 @@ The following are some modules that are built on this crate:

- [RedisJSON](https://github.com/RedisJSON/RedisJSON)
- [Rust API for RediSearch](https://github.com/RediSearch/redisearch-api-rs)
- [RedisStateMachine](https://github.com/RedisLabsModules/redis-state-machine)

Several member of the community have written their own modules based on this.
19 changes: 4 additions & 15 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,18 @@ fn main() {

const EXPERIMENTAL_API: &str = "REDISMODULE_EXPERIMENTAL_API";

// Determine if the `experimental-api` feature is enabled
fn experimental_api() -> bool {
std::env::var_os("CARGO_FEATURE_EXPERIMENTAL_API").is_some()
}

let mut build = cc::Build::new();

if experimental_api() {
build.define(EXPERIMENTAL_API, None);
}

build
.define(EXPERIMENTAL_API, None)
.file("src/redismodule.c")
.include("src/include/")
.compile("redismodule");

let mut build = bindgen::Builder::default();

if experimental_api() {
build = build.clang_arg(format!("-D{}", EXPERIMENTAL_API).as_str());
}
let bindings_generator = bindgen::Builder::default();

let bindings = build
let bindings = bindings_generator
.clang_arg(format!("-D{EXPERIMENTAL_API}"))
.header("src/include/redismodule.h")
.allowlist_var("(REDIS|Redis).*")
.blocklist_type("__darwin_.*")
Expand Down
2 changes: 1 addition & 1 deletion build/docker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include $(ROOT)/deps/readies/mk/main

REPO=redismodule-rs

REDIS_VERSION=6.2.7
REDIS_VERSION=7.2-rc1

OSNICK.official=bullseye

Expand Down
Loading

0 comments on commit ed57a77

Please sign in to comment.