File tree Expand file tree Collapse file tree 8 files changed +97
-13
lines changed
Expand file tree Collapse file tree 8 files changed +97
-13
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " redis_ts"
3- version = " 0.4.0 "
3+ version = " 0.4.1 "
44authors = [" protom <office@protom.eu>" ]
55keywords = [" redis" , " database" ]
66description = " API for Redis time series types."
@@ -13,7 +13,7 @@ edition = "2018"
1313exclude = [" docker" ]
1414
1515[dependencies ]
16- redis = { version = " ^0.20 .0" , optional = true }
16+ redis = { version = " ^0.21 .0" , optional = true }
1717
1818[features ]
1919default = [' redis' ]
Original file line number Diff line number Diff line change 11# redis_ts
22
3- [ ![ crates.io] ( https://img.shields.io/badge/crates.io-v0.4.0 -orange )] ( https://crates.io/crates/redis_ts )
3+ [ ![ crates.io] ( https://img.shields.io/badge/crates.io-v0.4.1 -orange )] ( https://crates.io/crates/redis_ts )
44![ Continuous integration] ( https://github.com/tompro/redis_ts/workflows/Continuous%20integration/badge.svg )
55
66redis_ts provides a small trait with extension functions for the
@@ -10,13 +10,13 @@ a [redis module](https://oss.redislabs.com/redistimeseries). Time
1010series commands are available as synchronous and asynchronous versions.
1111
1212The crate is called ` redis_ts ` and you can depend on it via cargo. You will
13- also need redis in your dependencies. It has been tested agains redis 0.20 .0
13+ also need redis in your dependencies. It has been tested agains redis 0.21 .0
1414but should work with versions higher than that.
1515
1616 ``` ini
1717 [dependencies]
18- redis = " 0.20 .0"
19- redis_ts = " 0.4.0 "
18+ redis = " 0.21 .0"
19+ redis_ts = " 0.4.1 "
2020 ```
2121
2222 Or via git:
@@ -29,8 +29,8 @@ but should work with versions higher than that.
2929With async feature inherited from the [ redis] ( https://docs.rs/redis ) crate (either: 'async-std-comp' or 'tokio-comp):
3030``` ini
3131 [dependencies]
32- redis = " 0.20 .0"
33- redis_ts = { version = " 0.4.0 " , features = [' tokio-comp' ] }
32+ redis = " 0.21 .0"
33+ redis_ts = { version = " 0.4.1 " , features = [' tokio-comp' ] }
3434```
3535
3636 ## Synchronous usage
Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ pub trait AsyncTsCommands: ConnectionLike + Send + Sized {
4040 } )
4141 }
4242
43+ /// Modifies an existing redis time series configuration.
44+ fn ts_alter < ' a , K : ToRedisArgs + Send + Sync + ' a , RV : FromRedisValue > (
45+ & ' a mut self ,
46+ key : K ,
47+ options : TsOptions ,
48+ ) -> RedisFuture < RV > {
49+ Box :: pin ( async move {
50+ cmd ( "TS.ALTER" )
51+ . arg ( key)
52+ . arg ( options. uncompressed ( false ) )
53+ . query_async ( self )
54+ . await
55+ } )
56+ }
57+
4358 /// Adds a single time series value with a timestamp to an existing redis time series.
4459 fn ts_add <
4560 ' a ,
Original file line number Diff line number Diff line change 55//! series commands are available as synchronous and asynchronous versions.
66//!
77//! The crate is called `redis_ts` and you can depend on it via cargo. You will
8- //! also need redis in your dependencies. It has been tested agains redis 0.20 .0
8+ //! also need redis in your dependencies. It has been tested agains redis 0.21 .0
99//! but should work with versions higher than that.
1010//!
1111//! ```ini
1212//! [dependencies]
13- //! redis = "0.20 .0"
14- //! redis_ts = "0.4.0 "
13+ //! redis = "0.21 .0"
14+ //! redis_ts = "0.4.1 "
1515//! ```
1616//!
1717//! Or via git:
2525//! crate (either: 'async-std-comp' or 'tokio-comp):
2626//! ```ini
2727//! [dependencies]
28- //! redis = "0.20 .0"
29- //! redis_ts = { version = "0.4.0 ", features = ['tokio-comp'] }
28+ //! redis = "0.21 .0"
29+ //! redis_ts = { version = "0.4.1 ", features = ['tokio-comp'] }
3030//! ```
3131//!
3232//! # Synchronous usage
Original file line number Diff line number Diff line change @@ -309,6 +309,37 @@ pub async fn ts_get_ts_info(name: &str) {
309309 assert_eq ! ( info. labels, vec![ ( "a" . to_string( ) , "b" . to_string( ) ) ] ) ;
310310}
311311
312+ pub async fn ts_alter ( name : & str ) {
313+ let mut con = get_con ( ) . await ;
314+ let _: ( ) = con. del ( name) . await . unwrap ( ) ;
315+ let _: ( ) = con
316+ . ts_create (
317+ name,
318+ TsOptions :: default ( )
319+ . label ( "a" , "b" )
320+ . duplicate_policy ( TsDuplicatePolicy :: Block )
321+ . chunk_size ( 4096 * 2 ) ,
322+ )
323+ . await
324+ . unwrap ( ) ;
325+ let _: ( ) = con. ts_add ( name, "1234" , 2.0 ) . await . unwrap ( ) ;
326+ let info: TsInfo = con. ts_info ( name) . await . unwrap ( ) ;
327+ assert_eq ! ( info. chunk_count, 1 ) ;
328+ assert_eq ! ( info. chunk_size, 4096 * 2 ) ;
329+ assert_eq ! ( info. labels, vec![ ( "a" . to_string( ) , "b" . to_string( ) ) ] ) ;
330+
331+ let _: ( ) = con
332+ . ts_alter (
333+ name,
334+ TsOptions :: default ( ) . chunk_size ( 4096 * 4 ) . label ( "c" , "d" ) ,
335+ )
336+ . await
337+ . unwrap ( ) ;
338+ let info2: TsInfo = con. ts_info ( name) . await . unwrap ( ) ;
339+ assert_eq ! ( info2. chunk_size, 4096 * 4 ) ;
340+ assert_eq ! ( info2. labels, vec![ ( "c" . to_string( ) , "d" . to_string( ) ) ] ) ;
341+ }
342+
312343pub async fn ts_range ( name : & str ) {
313344 let name2 = & format ! ( "{:}2" , name) ;
314345 let mut con = prepare_ts ( name) . await ;
Original file line number Diff line number Diff line change @@ -96,6 +96,11 @@ fn test_ts_get_ts_info() {
9696 let _: ( ) = block_on ( ts_get_ts_info ( "async_test_ts_get_ts_info_std" ) ) ;
9797}
9898
99+ #[ test]
100+ fn test_ts_alter ( ) {
101+ let _: ( ) = block_on ( ts_alter ( "async_test_ts_alter_std" ) ) ;
102+ }
103+
99104#[ test]
100105fn test_ts_range ( ) {
101106 let _: ( ) = block_on ( ts_range ( "async_test_ts_range_std" ) ) ;
Original file line number Diff line number Diff line change @@ -97,6 +97,11 @@ fn test_ts_get_ts_info() {
9797 let _: ( ) = block_on ( ts_get_ts_info ( "async_test_ts_get_ts_info_tokio" ) ) ;
9898}
9999
100+ #[ test]
101+ fn test_ts_alter ( ) {
102+ let _: ( ) = block_on ( ts_alter ( "async_test_ts_alter_tokio" ) ) ;
103+ }
104+
100105#[ test]
101106fn test_ts_range ( ) {
102107 let _: ( ) = block_on ( ts_range ( "async_test_ts_range_tokio" ) ) ;
Original file line number Diff line number Diff line change @@ -363,6 +363,34 @@ fn test_ts_get_ts_info() {
363363 assert_eq ! ( info. labels, vec![ ( "a" . to_string( ) , "b" . to_string( ) ) ] ) ;
364364}
365365
366+ #[ test]
367+ fn test_ts_alter ( ) {
368+ let _: ( ) = get_con ( ) . del ( "test_ts_alter" ) . unwrap ( ) ;
369+ let _: Value = get_con ( )
370+ . ts_create (
371+ "test_ts_alter" ,
372+ default_settings ( )
373+ . duplicate_policy ( TsDuplicatePolicy :: Last )
374+ . chunk_size ( 4096 * 2 ) ,
375+ )
376+ . unwrap ( ) ;
377+ let _: ( ) = get_con ( ) . ts_add ( "test_ts_alter" , "1234" , 2.0 ) . unwrap ( ) ;
378+ let info: TsInfo = get_con ( ) . ts_info ( "test_ts_alter" ) . unwrap ( ) ;
379+ assert_eq ! ( info. chunk_count, 1 ) ;
380+ assert_eq ! ( info. chunk_size, 4096 * 2 ) ;
381+ assert_eq ! ( info. labels, vec![ ( "a" . to_string( ) , "b" . to_string( ) ) ] ) ;
382+
383+ let _: Value = get_con ( )
384+ . ts_alter (
385+ "test_ts_alter" ,
386+ TsOptions :: default ( ) . chunk_size ( 4096 * 4 ) . label ( "c" , "d" ) ,
387+ )
388+ . unwrap ( ) ;
389+ let info2: TsInfo = get_con ( ) . ts_info ( "test_ts_alter" ) . unwrap ( ) ;
390+ assert_eq ! ( info2. chunk_size, 4096 * 4 ) ;
391+ assert_eq ! ( info2. labels, vec![ ( "c" . to_string( ) , "d" . to_string( ) ) ] ) ;
392+ }
393+
366394#[ test]
367395fn test_ts_range ( ) {
368396 let _: ( ) = get_con ( ) . del ( "test_ts_range" ) . unwrap ( ) ;
You can’t perform that action at this time.
0 commit comments