@@ -22,7 +22,7 @@ use testcontainers::core::{Container, Healthcheck, LogStream, RunnableImage, Wai
22
22
use testcontainers:: images:: generic:: GenericImage ;
23
23
use zookeeper_client as zk;
24
24
25
- static ZK_IMAGE_TAG : & ' static str = "3.9.0" ;
25
+ static ZK_IMAGE_TAG : & str = "3.9.0" ;
26
26
static PERSISTENT_OPEN : & zk:: CreateOptions < ' static > = & zk:: CreateMode :: Persistent . with_acls ( zk:: Acls :: anyone_all ( ) ) ;
27
27
static CONTAINER_OPEN : & zk:: CreateOptions < ' static > = & zk:: CreateMode :: Container . with_acls ( zk:: Acls :: anyone_all ( ) ) ;
28
28
@@ -326,20 +326,20 @@ struct ClusterOptions<'a> {
326
326
327
327
impl ClusterOptions < ' _ > {
328
328
fn is_standalone ( & self ) -> bool {
329
- return self . servers . len ( ) <= 1 ;
329
+ self . servers . len ( ) <= 1
330
330
}
331
331
332
332
fn servers ( & self ) -> Vec < ( u32 , String ) > {
333
333
let mut lines = String :: new ( ) ;
334
334
for config in self . configs . iter ( ) {
335
- write ! ( & mut lines, "{} \n " , config ) . unwrap ( ) ;
335
+ writeln ! ( & mut lines, "{config}" ) . unwrap ( ) ;
336
336
}
337
337
let mut servers = vec ! [ ] ;
338
338
for server in self . servers . iter ( ) {
339
339
let mut lines = lines. clone ( ) ;
340
340
lines += "initLimit=5\n " ;
341
341
lines += "syncLimit=2\n " ;
342
- write ! ( & mut lines, "{}\n " , server. 1 . join( "\n " ) ) . unwrap ( ) ;
342
+ writeln ! ( & mut lines, "{}" , server. 1 . join( "\n " ) ) . unwrap ( ) ;
343
343
servers. push ( ( server. 0 , lines) ) ;
344
344
}
345
345
if servers. is_empty ( ) {
@@ -491,14 +491,15 @@ serverCnxnFactory=org.apache.zookeeper.server.NettyServerCnxnFactory
491
491
}
492
492
493
493
if standalone {
494
+ #[ allow( clippy:: missing_transmute_annotations) ]
494
495
let container = unsafe { std:: mem:: transmute ( self . docker . run ( image) ) } ;
495
496
self . containers . push ( ( 1 , container) ) ;
496
497
return ;
497
498
}
498
499
499
500
let data_dir = self . dir . tempdir ( ) . path ( ) . join ( format ! ( "zoo{id}.data" ) ) ;
500
501
std:: fs:: create_dir_all ( data_dir. as_path ( ) ) . unwrap ( ) ;
501
- fs:: write ( & data_dir. as_path ( ) . join ( "myid" ) , format ! ( "{id}\n " ) ) . unwrap ( ) ;
502
+ fs:: write ( data_dir. as_path ( ) . join ( "myid" ) , format ! ( "{id}\n " ) ) . unwrap ( ) ;
502
503
image = image. with_volume ( ( data_dir. to_str ( ) . unwrap ( ) , "/data" ) ) ;
503
504
// image = image.with_env_var(("ZOO_MY_ID", id.to_string()));
504
505
@@ -754,7 +755,7 @@ async fn test_check_writer() {
754
755
let mut results = check_writer. commit ( ) . await . unwrap ( ) ;
755
756
let created_stat = match results. remove ( 0 ) {
756
757
zk:: MultiWriteResult :: Create { stat, .. } => stat,
757
- result => panic ! ( "expect create result, got {:?}" , result ) ,
758
+ result => panic ! ( "expect create result, got {result :?}" ) ,
758
759
} ;
759
760
760
761
let ( data, stat) = client. get_data ( "/a" ) . await . unwrap ( ) ;
@@ -936,7 +937,7 @@ async fn test_data_node() {
936
937
async fn test_create_root ( ) {
937
938
let cluster = Cluster :: new ( ) . await ;
938
939
let client = cluster. client ( None ) . await . chroot ( "/a" ) . unwrap ( ) ;
939
- assert_that ! ( client. create( "/" , & vec! [ ] , PERSISTENT_OPEN ) . await . unwrap_err( ) )
940
+ assert_that ! ( client. create( "/" , & [ ] , PERSISTENT_OPEN ) . await . unwrap_err( ) )
940
941
. is_equal_to ( zk:: Error :: BadArguments ( & "can not create root node" ) ) ;
941
942
assert_that ! ( client. mkdir( "/" , PERSISTENT_OPEN ) . await . unwrap_err( ) )
942
943
. is_equal_to ( zk:: Error :: BadArguments ( & "can not create root node" ) ) ;
@@ -960,8 +961,8 @@ async fn test_create_sequential() {
960
961
961
962
assert ! ( sequence2. into_i64( ) > sequence1. into_i64( ) ) ;
962
963
963
- let path1 = format ! ( "{}{}" , prefix , sequence1 ) ;
964
- let path2 = format ! ( "{}{}" , prefix , sequence2 ) ;
964
+ let path1 = format ! ( "{prefix}{sequence1}" ) ;
965
+ let path2 = format ! ( "{prefix}{sequence2}" ) ;
965
966
assert_eq ! ( ( data. clone( ) , stat1) , client. get_data( & path1) . await . unwrap( ) ) ;
966
967
assert_eq ! ( ( data, stat2) , client. get_data( & path2) . await . unwrap( ) ) ;
967
968
}
@@ -976,8 +977,8 @@ async fn test_create_ttl() {
976
977
let client = cluster. client ( None ) . await ;
977
978
978
979
let ttl_options = PERSISTENT_OPEN . clone ( ) . with_ttl ( Duration :: from_millis ( 500 ) ) ;
979
- client. create ( "/ttl" , & vec ! [ ] , & ttl_options) . await . unwrap ( ) ;
980
- client. create ( "/ttl/child" , & vec ! [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
980
+ client. create ( "/ttl" , & [ ] , & ttl_options) . await . unwrap ( ) ;
981
+ client. create ( "/ttl/child" , & [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
981
982
Timer :: after ( Duration :: from_secs ( 4 ) ) . await ;
982
983
client. delete ( "/ttl/child" , None ) . await . unwrap ( ) ;
983
984
Timer :: after ( Duration :: from_secs ( 4 ) ) . await ;
@@ -993,8 +994,8 @@ async fn test_create_container() {
993
994
. await ;
994
995
let client = cluster. client ( None ) . await ;
995
996
996
- client. create ( "/container" , & vec ! [ ] , & zk:: CreateMode :: Container . with_acls ( zk:: Acls :: anyone_all ( ) ) ) . await . unwrap ( ) ;
997
- client. create ( "/container/child" , & vec ! [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
997
+ client. create ( "/container" , & [ ] , & zk:: CreateMode :: Container . with_acls ( zk:: Acls :: anyone_all ( ) ) ) . await . unwrap ( ) ;
998
+ client. create ( "/container/child" , & [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
998
999
Timer :: after ( Duration :: from_secs ( 4 ) ) . await ;
999
1000
client. delete ( "/container/child" , None ) . await . unwrap ( ) ;
1000
1001
Timer :: after ( Duration :: from_secs ( 4 ) ) . await ;
@@ -1135,9 +1136,9 @@ async fn test_ephemerals() {
1135
1136
let ( _, sequence1) = client. create ( prefix, Default :: default ( ) , & ephemeral_sequential_options) . await . unwrap ( ) ;
1136
1137
let ( _, sequence2) = client. create ( prefix, Default :: default ( ) , & ephemeral_sequential_options) . await . unwrap ( ) ;
1137
1138
let ( _, sequence3) = client. create ( prefix, Default :: default ( ) , & ephemeral_sequential_options) . await . unwrap ( ) ;
1138
- root_ephemerals. push ( format ! ( "{}{}" , prefix , sequence1 ) ) ;
1139
- root_ephemerals. push ( format ! ( "{}{}" , prefix , sequence2 ) ) ;
1140
- root_ephemerals. push ( format ! ( "{}{}" , prefix , sequence3 ) ) ;
1139
+ root_ephemerals. push ( format ! ( "{prefix}{sequence1}" ) ) ;
1140
+ root_ephemerals. push ( format ! ( "{prefix}{sequence2}" ) ) ;
1141
+ root_ephemerals. push ( format ! ( "{prefix}{sequence3}" ) ) ;
1141
1142
1142
1143
assert ! ( sequence2 > sequence1) ;
1143
1144
assert ! ( sequence3 > sequence2) ;
@@ -1695,7 +1696,7 @@ async fn test_watcher_coexist_on_same_path() {
1695
1696
let mut persistent_watcher = client. watch ( "/a" , zk:: AddWatchMode :: Persistent ) . await . unwrap ( ) ;
1696
1697
let mut recursive_watcher = client. watch ( "/a" , zk:: AddWatchMode :: PersistentRecursive ) . await . unwrap ( ) ;
1697
1698
1698
- let ( stat, _) = client. create ( "/a" , & vec ! [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1699
+ let ( stat, _) = client. create ( "/a" , & [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1699
1700
1700
1701
let expected = zk:: WatchedEvent :: new ( zk:: EventType :: NodeCreated , "/a" . to_string ( ) ) . with_zxid ( stat. czxid ) ;
1701
1702
assert_that ! ( exist_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
@@ -1706,7 +1707,7 @@ async fn test_watcher_coexist_on_same_path() {
1706
1707
let ( _, _, child_watcher) = client. get_and_watch_children ( "/a" ) . await . unwrap ( ) ;
1707
1708
let ( _, exist_watcher) = client. check_and_watch_stat ( "/a" ) . await . unwrap ( ) ;
1708
1709
1709
- let ( stat, _) = client. create ( "/a/b" , & vec ! [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1710
+ let ( stat, _) = client. create ( "/a/b" , & [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1710
1711
let expected = zk:: WatchedEvent :: new ( zk:: EventType :: NodeChildrenChanged , "/a" . to_string ( ) ) . with_zxid ( stat. czxid ) ;
1711
1712
assert_that ! ( child_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
1712
1713
assert_that ! ( persistent_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
@@ -1738,7 +1739,7 @@ async fn test_watcher_coexist_on_same_path() {
1738
1739
assert_that ! ( recursive_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
1739
1740
1740
1741
// persistent ones still exist
1741
- let ( stat, _) = client. create ( "/a" , & vec ! [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1742
+ let ( stat, _) = client. create ( "/a" , & [ ] , PERSISTENT_OPEN ) . await . unwrap ( ) ;
1742
1743
let expected = zk:: WatchedEvent :: new ( zk:: EventType :: NodeCreated , "/a" . to_string ( ) ) . with_zxid ( stat. mzxid ) ;
1743
1744
assert_that ! ( persistent_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
1744
1745
assert_that ! ( recursive_watcher. changed( ) . await ) . is_equal_to ( & expected) ;
@@ -1751,7 +1752,7 @@ async fn test_remove_no_watcher() {
1751
1752
let client = cluster. client ( None ) . await ;
1752
1753
1753
1754
let ( _, exist_watcher) = client. check_and_watch_stat ( "/a" ) . await . unwrap ( ) ;
1754
- let create = client. create ( "/a" , & vec ! [ ] , PERSISTENT_OPEN ) ;
1755
+ let create = client. create ( "/a" , & [ ] , PERSISTENT_OPEN ) ;
1755
1756
1756
1757
// Let session task issue `create` request first, oneshot watch will be removed by server.
1757
1758
asyncs:: task:: yield_now ( ) . await ;
0 commit comments