Skip to content

Commit bb54ae8

Browse files
authored
Merge branch 'master' into add-cargo-deny
2 parents a85f8df + 90ba302 commit bb54ae8

File tree

18 files changed

+239
-82
lines changed

18 files changed

+239
-82
lines changed

.circleci/config.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ parameters:
44
run_default_flow:
55
default: true
66
type: boolean
7+
run_nightly_twice_a_week_flow_label:
8+
default: false
9+
type: boolean
710

811
commands:
912
early-returns:
@@ -78,7 +81,7 @@ commands:
7881
parameters:
7982
redis_version:
8083
type: string
81-
default: "7"
84+
default: "7.2"
8285
getredis_params:
8386
type: string
8487
default: ""
@@ -575,6 +578,17 @@ workflows:
575578
parameters:
576579
redis_version: ["7", "unstable"]
577580

581+
nightly-twice-a-week-by-param:
582+
when:
583+
<< pipeline.parameters.run_nightly_twice_a_week_flow_label >>
584+
jobs:
585+
- build-macos-x64:
586+
context: common
587+
upload: "yes"
588+
- build-macos-m1:
589+
context: common
590+
upload: "yes"
591+
578592
nightly-twice-a-week:
579593
triggers:
580594
- schedule:

.github/workflows/backport_pr.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Backport merged pull request
2+
on:
3+
pull_request_target:
4+
types: [closed]
5+
issue_comment:
6+
types: [created]
7+
permissions:
8+
contents: write # so it can comment
9+
pull-requests: write # so it can create pull requests
10+
jobs:
11+
backport:
12+
name: Backport pull request
13+
runs-on: ubuntu-latest
14+
15+
# Only run when pull request is merged
16+
# or when a comment containing `/backport` is created by someone other than the
17+
# https://github.com/backport-action bot user (user id: 97796249). Note that if you use your
18+
# own PAT as `github_token`, that you should replace this id with yours.
19+
if: >
20+
(
21+
github.event.pull_request.merged
22+
) || (
23+
github.event_name == 'issue_comment' &&
24+
github.event.issue.pull_request &&
25+
github.event.comment.user.id != 97796249 &&
26+
contains(github.event.comment.body, '/backport')
27+
)
28+
steps:
29+
- uses: actions/checkout@v3
30+
- name: Create backport pull requests
31+
uses: korthout/backport-action@v1
32+
with:
33+
pull_title: '[${target_branch}] ${pull_title}'
34+
merge_commits: 'skip'

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@
3333
.settings/
3434

3535
wordlist.dic
36+
37+
venv/

Cargo.lock

Lines changed: 35 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@ ifeq ($(PROFILE),1)
105105
RUST_FLAGS += -g -C force-frame-pointers=yes
106106
endif
107107

108-
ifeq ($(OS),macos)
109-
ifeq ($(ARCH),x64)
110-
CARGO_TOOLCHAIN = +1.66.1
111-
endif
112-
endif
113-
114108
ifeq ($(NIGHTLY),1)
115109
TARGET_DIR=$(BINDIR)/target/$(RUST_TARGET)/debug
116110

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,20 @@ docker run -p 6379:6379 --name redis-stack redis/redis-stack:latest
3333

3434
Read the docs at <http://redisjson.io>
3535

36+
### How do I Redis?
37+
38+
[Learn for free at Redis University](https://university.redis.com/)
39+
40+
[Build faster with the Redis Launchpad](https://launchpad.redis.com/)
41+
42+
[Try the Redis Cloud](https://redis.com/try-free/)
43+
44+
[Dive in developer tutorials](https://developer.redis.com/)
45+
46+
[Join the Redis community](https://redis.com/community/)
47+
48+
[Work at Redis](https://redis.com/company/careers/jobs/)
49+
3650
## Build
3751

3852
Make sure you have Rust installed:

redis_json/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ ijson.workspace = true
2525
serde_json.workspace = true
2626
serde.workspace = true
2727
libc = "0.2"
28-
redis-module = "2.0"
28+
redis-module ={ version = "^2.0.7", default-features = false, features = ["min-redis-compatibility-version-7-2"] }
29+
redis-module-macros = "^2.0.7"
2930
itertools = "0.10"
3031
json_path = {path="../json_path"}
32+
linkme = "0.3"
3133

3234
[features]
3335
as-library = []

redis_json/src/c_api.rs

Lines changed: 57 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::key_value::KeyValue;
1818
use json_path::select_value::{SelectValue, SelectValueType};
1919
use json_path::{compile, create};
2020
use redis_module::raw as rawmod;
21-
use redis_module::{Context, RedisString, Status};
21+
use redis_module::{key::KeyFlags, Context, RedisString, Status};
2222

2323
use crate::manager::{Manager, ReadHolder};
2424

@@ -78,6 +78,21 @@ pub fn json_api_open_key_internal<M: Manager>(
7878
null()
7979
}
8080

81+
pub fn json_api_open_key_with_flags_internal<M: Manager>(
82+
manager: M,
83+
ctx: *mut rawmod::RedisModuleCtx,
84+
key: RedisString,
85+
flags: KeyFlags,
86+
) -> *const M::V {
87+
let ctx: Context = Context::new(ctx);
88+
if let Ok(h) = manager.open_key_read_with_flags(&ctx, &key, flags) {
89+
if let Ok(Some(v)) = h.get_value() {
90+
return v;
91+
}
92+
}
93+
null()
94+
}
95+
8196
pub fn json_api_get_at<M: Manager>(_: M, json: *const c_void, index: size_t) -> *const c_void {
8297
let json = unsafe { &*(json.cast::<M::V>()) };
8398
match json.get_type() {
@@ -326,6 +341,26 @@ macro_rules! redis_json_module_export_shared_api {
326341
)
327342
}
328343

344+
#[no_mangle]
345+
pub extern "C" fn JSONAPI_openKey_withFlags(
346+
ctx: *mut rawmod::RedisModuleCtx,
347+
key_str: *mut rawmod::RedisModuleString,
348+
flags: c_int,
349+
) -> *mut c_void {
350+
run_on_manager!(
351+
pre_command: ||$pre_command_function_expr(&get_llapi_ctx(), &Vec::new()),
352+
get_mngr: $get_manager_expr,
353+
run: |mngr| {
354+
json_api_open_key_with_flags_internal(
355+
mngr,
356+
ctx,
357+
RedisString::new(NonNull::new(ctx), key_str),
358+
KeyFlags::from_bits_truncate(flags as i32),
359+
) as *mut c_void
360+
},
361+
)
362+
}
363+
329364
#[no_mangle]
330365
#[allow(clippy::not_unsafe_ptr_arg_deref)]
331366
pub extern "C" fn JSONAPI_openKeyFromStr(
@@ -543,39 +578,24 @@ macro_rules! redis_json_module_export_shared_api {
543578
)
544579
}
545580

546-
static REDISJSON_GETAPI_V1: &str = concat!("RedisJSON_V1", "\0");
547-
static REDISJSON_GETAPI_V2: &str = concat!("RedisJSON_V2", "\0");
548-
static REDISJSON_GETAPI_V3: &str = concat!("RedisJSON_V3", "\0");
549-
static REDISJSON_GETAPI_V4: &str = concat!("RedisJSON_V4", "\0");
581+
// The apiname argument of export_shared_api should be a string literal with static lifetime
582+
static mut VEC_EXPORT_SHARED_API_NAME : Vec<CString> = Vec::new();
550583

551584
pub fn export_shared_api(ctx: &Context) {
552585
unsafe {
553586
LLAPI_CTX = Some(rawmod::RedisModule_GetThreadSafeContext.unwrap()(
554587
std::ptr::null_mut(),
555588
));
556-
ctx.export_shared_api(
557-
(&JSONAPI_CURRENT as *const RedisJSONAPI_CURRENT).cast::<c_void>(),
558-
REDISJSON_GETAPI_V1.as_ptr().cast::<c_char>(),
559-
);
560-
ctx.log_notice("Exported RedisJSON_V1 API");
561-
562-
ctx.export_shared_api(
563-
(&JSONAPI_CURRENT as *const RedisJSONAPI_CURRENT).cast::<c_void>(),
564-
REDISJSON_GETAPI_V2.as_ptr().cast::<c_char>(),
565-
);
566-
ctx.log_notice("Exported RedisJSON_V2 API");
567-
568-
ctx.export_shared_api(
569-
(&JSONAPI_CURRENT as *const RedisJSONAPI_CURRENT).cast::<c_void>(),
570-
REDISJSON_GETAPI_V3.as_ptr().cast::<c_char>(),
571-
);
572-
ctx.log_notice("Exported RedisJSON_V3 API");
573-
574-
ctx.export_shared_api(
575-
(&JSONAPI_CURRENT as *const RedisJSONAPI_CURRENT).cast::<c_void>(),
576-
REDISJSON_GETAPI_V4.as_ptr().cast::<c_char>(),
577-
);
578-
ctx.log_notice("Exported RedisJSON_V4 API");
589+
590+
for v in 1..6 {
591+
let version = format!("RedisJSON_V{}", v);
592+
VEC_EXPORT_SHARED_API_NAME.push(CString::new(version.as_str()).unwrap());
593+
ctx.export_shared_api(
594+
(&JSONAPI_CURRENT as *const RedisJSONAPI_CURRENT).cast::<c_void>(),
595+
VEC_EXPORT_SHARED_API_NAME[v-1].as_ptr().cast::<c_char>(),
596+
);
597+
ctx.log_notice(&format!("Exported {} API", version));
598+
}
579599
};
580600
}
581601

@@ -608,6 +628,8 @@ macro_rules! redis_json_module_export_shared_api {
608628
getKeyValues: JSONAPI_getKeyValues,
609629
nextKeyValue: JSONAPI_nextKeyValue,
610630
freeKeyValuesIter: JSONAPI_freeKeyValuesIter,
631+
// V5 entries
632+
openKeyWithFlags: JSONAPI_openKey_withFlags,
611633
};
612634

613635
#[repr(C)]
@@ -657,6 +679,13 @@ macro_rules! redis_json_module_export_shared_api {
657679
str: *mut *mut rawmod::RedisModuleString
658680
) -> *const c_void,
659681
pub freeKeyValuesIter: extern "C" fn(iter: *mut c_void),
682+
// V5
683+
pub openKeyWithFlags: extern "C" fn(
684+
ctx: *mut rawmod::RedisModuleCtx,
685+
key_str: *mut rawmod::RedisModuleString,
686+
flags: c_int,
687+
) -> *mut c_void,
688+
660689
}
661690
};
662691
}

redis_json/src/include/rejson_api.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,15 @@ typedef struct RedisJSONAPI {
115115
// Free the iterator
116116
void (*freeKeyValuesIter)(JSONKeyValuesIterator iter);
117117

118+
////////////////
119+
// V5 entries //
120+
////////////////
121+
122+
RedisJSON (*openKeyWithFlags)(RedisModuleCtx *ctx, RedisModuleString *key_name, int flags);
123+
118124
} RedisJSONAPI;
119125

126+
#define RedisJSONAPI_LATEST_API_VER 5
120127
#ifdef __cplusplus
121128
}
122129
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy