@@ -96,7 +96,7 @@ impl Client {
96
96
///
97
97
/// This modifies a counter with an effective sampling
98
98
/// rate of 1.0.
99
- pub fn incr ( & mut self , metric : & str ) {
99
+ pub fn incr ( & self , metric : & str ) {
100
100
self . count ( metric, 1.0 ) ;
101
101
}
102
102
@@ -109,7 +109,7 @@ impl Client {
109
109
///
110
110
/// This modifies a counter with an effective sampling
111
111
/// rate of 1.0.
112
- pub fn decr ( & mut self , metric : & str ) {
112
+ pub fn decr ( & self , metric : & str ) {
113
113
self . count ( metric, -1.0 ) ;
114
114
}
115
115
@@ -122,7 +122,7 @@ impl Client {
122
122
/// // Increment by 12
123
123
/// client.count("metric.completed", 12.0);
124
124
/// ```
125
- pub fn count ( & mut self , metric : & str , value : f64 ) {
125
+ pub fn count ( & self , metric : & str , value : f64 ) {
126
126
let data = self . prepare ( format ! ( "{}:{}|c" , metric, value) ) ;
127
127
self . send ( data) ;
128
128
}
@@ -137,7 +137,7 @@ impl Client {
137
137
/// // Increment by 4 50% of the time.
138
138
/// client.sampled_count("metric.completed", 4, 0.5);
139
139
/// ```
140
- pub fn sampled_count ( & mut self , metric : & str , value : f64 , rate : f64 ) {
140
+ pub fn sampled_count ( & self , metric : & str , value : f64 , rate : f64 ) {
141
141
if rand:: random :: < f64 > ( ) < rate {
142
142
return ;
143
143
}
@@ -151,7 +151,7 @@ impl Client {
151
151
/// // set a gauge to 9001
152
152
/// client.gauge("power_level.observed", 9001.0);
153
153
/// ```
154
- pub fn gauge ( & mut self , metric : & str , value : f64 ) {
154
+ pub fn gauge ( & self , metric : & str , value : f64 ) {
155
155
let data = self . prepare ( format ! ( "{}:{}|g" , metric, value) ) ;
156
156
self . send ( data) ;
157
157
}
@@ -164,7 +164,7 @@ impl Client {
164
164
/// // pass a duration value
165
165
/// client.timer("response.duration", 10.123);
166
166
/// ```
167
- pub fn timer ( & mut self , metric : & str , value : f64 ) {
167
+ pub fn timer ( & self , metric : & str , value : f64 ) {
168
168
let data = self . prepare ( format ! ( "{}:{}|ms" , metric, value) ) ;
169
169
self . send ( data) ;
170
170
}
@@ -180,7 +180,7 @@ impl Client {
180
180
/// // Your code here.
181
181
/// });
182
182
/// ```
183
- pub fn time < F , R > ( & mut self , metric : & str , callable : F ) -> R
183
+ pub fn time < F , R > ( & self , metric : & str , callable : F ) -> R
184
184
where F : Fn ( ) -> R
185
185
{
186
186
let start = time:: Instant :: now ( ) ;
@@ -197,7 +197,7 @@ impl Client {
197
197
}
198
198
199
199
/// Send data along the UDP socket.
200
- fn send ( & mut self , data : String ) {
200
+ fn send ( & self , data : String ) {
201
201
let _ = self . socket . send_to ( data. as_bytes ( ) , self . server_address ) ;
202
202
}
203
203
@@ -364,7 +364,7 @@ impl Pipeline {
364
364
}
365
365
366
366
/// Send data along the UDP socket.
367
- pub fn send ( & mut self , client : & mut Client ) {
367
+ pub fn send ( & mut self , client : & Client ) {
368
368
let mut _data = String :: new ( ) ;
369
369
if let Some ( data) = self . stats . pop_front ( ) {
370
370
_data = _data + client. prepare ( & data) . as_ref ( ) ;
@@ -435,7 +435,7 @@ mod test {
435
435
fn test_sending_gauge ( ) {
436
436
let host = next_test_ip4 ( ) ;
437
437
let server = make_server ( & host) ;
438
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
438
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
439
439
440
440
client. gauge ( "metric" , 9.1 ) ;
441
441
@@ -447,7 +447,7 @@ mod test {
447
447
fn test_sending_incr ( ) {
448
448
let host = next_test_ip4 ( ) ;
449
449
let server = make_server ( & host) ;
450
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
450
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
451
451
452
452
client. incr ( "metric" ) ;
453
453
@@ -459,7 +459,7 @@ mod test {
459
459
fn test_sending_decr ( ) {
460
460
let host = next_test_ip4 ( ) ;
461
461
let server = make_server ( & host) ;
462
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
462
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
463
463
464
464
client. decr ( "metric" ) ;
465
465
@@ -471,7 +471,7 @@ mod test {
471
471
fn test_sending_count ( ) {
472
472
let host = next_test_ip4 ( ) ;
473
473
let server = make_server ( & host) ;
474
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
474
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
475
475
476
476
client. count ( "metric" , 12.2 ) ;
477
477
@@ -483,7 +483,7 @@ mod test {
483
483
fn test_sending_timer ( ) {
484
484
let host = next_test_ip4 ( ) ;
485
485
let server = make_server ( & host) ;
486
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
486
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
487
487
488
488
client. timer ( "metric" , 21.39 ) ;
489
489
@@ -495,7 +495,7 @@ mod test {
495
495
fn test_sending_timed_block ( ) {
496
496
let host = next_test_ip4 ( ) ;
497
497
let server = make_server ( & host) ;
498
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
498
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
499
499
500
500
let output = client. time ( "metric" , || {
501
501
"a string"
@@ -511,10 +511,10 @@ mod test {
511
511
fn test_pipeline_sending_gauge ( ) {
512
512
let host = next_test_ip4 ( ) ;
513
513
let server = make_server ( & host) ;
514
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
514
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
515
515
let mut pipeline = client. pipeline ( ) ;
516
516
pipeline. gauge ( "metric" , 9.1 ) ;
517
- pipeline. send ( & mut client) ;
517
+ pipeline. send ( & client) ;
518
518
519
519
let response = server_recv ( server) ;
520
520
assert_eq ! ( "myapp.metric:9.1|g" , response) ;
@@ -524,11 +524,11 @@ mod test {
524
524
fn test_pipeline_sending_multiple_data ( ) {
525
525
let host = next_test_ip4 ( ) ;
526
526
let server = make_server ( & host) ;
527
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
527
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
528
528
let mut pipeline = client. pipeline ( ) ;
529
529
pipeline. gauge ( "metric" , 9.1 ) ;
530
530
pipeline. count ( "metric" , 12.2 ) ;
531
- pipeline. send ( & mut client) ;
531
+ pipeline. send ( & client) ;
532
532
533
533
let response = server_recv ( server) ;
534
534
assert_eq ! ( "myapp.metric:9.1|g\n myapp.metric:12.2|c" , response) ;
@@ -538,12 +538,12 @@ mod test {
538
538
fn test_pipeline_set_max_udp_size ( ) {
539
539
let host = next_test_ip4 ( ) ;
540
540
let server = make_server ( & host) ;
541
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
541
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
542
542
let mut pipeline = client. pipeline ( ) ;
543
543
pipeline. set_max_udp_size ( 20 ) ;
544
544
pipeline. gauge ( "metric" , 9.1 ) ;
545
545
pipeline. count ( "metric" , 12.2 ) ;
546
- pipeline. send ( & mut client) ;
546
+ pipeline. send ( & client) ;
547
547
548
548
let response = server_recv ( server) ;
549
549
assert_eq ! ( "myapp.metric:9.1|g" , response) ;
@@ -553,12 +553,12 @@ mod test {
553
553
fn test_pipeline_send_metric_after_pipeline ( ) {
554
554
let host = next_test_ip4 ( ) ;
555
555
let server = make_server ( & host) ;
556
- let mut client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
556
+ let client = Client :: new ( & host, "myapp" ) . unwrap ( ) ;
557
557
let mut pipeline = client. pipeline ( ) ;
558
558
559
559
pipeline. gauge ( "load" , 9.0 ) ;
560
560
pipeline. count ( "customers" , 7.0 ) ;
561
- pipeline. send ( & mut client) ;
561
+ pipeline. send ( & client) ;
562
562
563
563
// Should still be able to send metrics
564
564
// with the client.
0 commit comments