Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

Commit 8d696b6

Browse files
committed
add VERSION command and moving to 2018 version
1 parent a552f02 commit 8d696b6

6 files changed

Lines changed: 36 additions & 12 deletions

File tree

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "rediSQL"
33
version = "1.0.3-rc02"
44
authors = ["Simone Mosciatti <simone@redbeardlab.tech>"]
5+
edition = "2018"
56

67
[lib]
78
name = "redis_sql"

redisql_lib/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "redisql_lib"
33
version = "0.5.5-rc02"
44
authors = ["Simone Mosciatti <mweb.sim@gmail.com>"]
5+
edition = "2015"
56

67
[build-dependencies]
78
bindgen = "0.47.1"

src/commands.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use sync_engine::Replicate;
1717

1818
use redisql_lib::statistics::STATISTICS;
1919

20+
const REDISQL_VERSION: Option<&'static str> =
21+
option_env!("CARGO_PKG_VERSION");
22+
2023
extern "C" fn reply_exec(
2124
ctx: *mut r::rm::ffi::RedisModuleCtx,
2225
_argv: *mut *mut r::rm::ffi::RedisModuleString,
@@ -854,7 +857,7 @@ pub extern "C" fn CreateDB(
854857
vtab::register_modules(&rc)
855858
}) {
856859
Err(e) => e.reply(&context),
857-
Ok(mut vtab_context) => {
860+
Ok(vtab_context) => {
858861
let (tx, rx) = channel();
859862
let db = r::DBKey::new_from_arc(
860863
tx,
@@ -1096,3 +1099,16 @@ pub extern "C" fn GetStatistics(
10961099

10971100
r::rm::ffi::REDISMODULE_OK
10981101
}
1102+
1103+
#[allow(non_snake_case)]
1104+
pub extern "C" fn RediSQLVersion(
1105+
ctx: *mut r::rm::ffi::RedisModuleCtx,
1106+
_argv: *mut *mut r::rm::ffi::RedisModuleString,
1107+
_argc: ::std::os::raw::c_int,
1108+
) -> i32 {
1109+
let context = r::rm::Context::new(ctx);
1110+
let version = REDISQL_VERSION.unwrap_or("unknown");
1111+
r::rm::ReplyWithStringBuffer(&context, version.as_bytes());
1112+
1113+
r::rm::ffi::REDISMODULE_OK
1114+
}

src/lib.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@
22

33
mod commands;
44

5-
extern crate env_logger;
6-
75
#[macro_use]
86
extern crate log;
9-
extern crate redisql_lib;
10-
extern crate uuid;
117

128
use env_logger::{Builder as logBuilder, Target as logTarget};
139
use redisql_lib::redis as r;
@@ -26,13 +22,12 @@ use std::sync::{Arc, Mutex};
2622
use std::thread;
2723
use uuid::Uuid;
2824

29-
extern crate sync_engine;
3025
use sync_engine::{register, WriteAOF};
3126

3227
use commands::{
3328
CreateDB, CreateStatement, DeleteStatement, Exec, ExecStatement,
3429
GetStatistics, MakeCopy, Query, QueryInto, QueryStatement,
35-
QueryStatementInto, UpdateStatement,
30+
QueryStatementInto, RediSQLVersion, UpdateStatement,
3631
};
3732

3833
#[cfg(not(feature = "pro"))]
@@ -339,6 +334,16 @@ pub extern "C" fn RedisModule_OnLoad(
339334
Err(e) => return e,
340335
}
341336

337+
match register_function(
338+
&ctx,
339+
"REDISQL.VERSION",
340+
"readonly",
341+
RediSQLVersion,
342+
) {
343+
Ok(()) => (),
344+
Err(e) => return e,
345+
}
346+
342347
match register(ctx) {
343348
Ok(()) => (),
344349
Err(e) => return e,

sync_engine/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
name = "sync_engine"
33
version = "0.5.1-rc01"
44
authors = ["Simone Mosciatti <mweb.sim@gmail.com>"]
5+
edition = "2018"
56

67
[build-dependencies]
78
cc = {version = "1.0.3", features = ["parallel"]}

0 commit comments

Comments
 (0)