11use std:: sync:: Arc ;
22
3- use reqwest:: { header:: HeaderMap , Client } ;
3+ use reqwest:: { header:: HeaderMap , Client , Method } ;
44
55use crate :: metrics:: metrics:: Metrics ;
66
77pub struct Scheduler < ' a > {
88 metrics : & ' a Arc < Metrics > ,
9+ method : Method ,
910 url : String ,
1011 concurrency : u64 ,
1112 duration : u64 ,
@@ -15,13 +16,15 @@ pub struct Scheduler<'a> {
1516impl < ' a > Scheduler < ' a > {
1617 pub fn new (
1718 metrics : & ' a Arc < Metrics > ,
19+ method : Method ,
1820 url : String ,
1921 concurrency : u64 ,
2022 duration : u64 ,
2123 headers : HeaderMap ,
2224 ) -> Self {
2325 Scheduler {
2426 metrics,
27+ method,
2528 url,
2629 concurrency,
2730 duration,
@@ -37,13 +40,14 @@ impl<'a> Scheduler<'a> {
3740 let headers = self . headers . clone ( ) ;
3841
3942 for _ in 0 ..self . concurrency {
43+ let method = self . method . clone ( ) ;
4044 let url = url. clone ( ) ;
4145 let headers = headers. clone ( ) ;
4246 let duration = self . duration ;
4347 let metrics = Arc :: clone ( self . metrics ) ;
4448
4549 tasks. push ( tokio:: spawn ( async move {
46- Scheduler :: run_client ( & metrics, start_bench, url, duration, headers) . await ;
50+ Scheduler :: run_client ( & metrics, start_bench, method , url, duration, headers) . await ;
4751 } ) ) ;
4852 }
4953
@@ -81,14 +85,15 @@ impl<'a> Scheduler<'a> {
8185 async fn run_client (
8286 metrics : & ' a Arc < Metrics > ,
8387 start_bench : std:: time:: Instant ,
88+ method : Method ,
8489 url : String ,
8590 duration : u64 ,
8691 headers : HeaderMap ,
8792 ) {
8893 let client = Client :: builder ( ) . default_headers ( headers) . build ( ) . unwrap ( ) ;
8994
9095 loop {
91- let result = Self :: make_request ( metrics, & client, & url) . await ;
96+ let result = Self :: make_request ( metrics, & client, & method , & url) . await ;
9297 Self :: handle_request_result ( metrics, result) . await ;
9398
9499 if std:: time:: Instant :: now ( ) >= start_bench + std:: time:: Duration :: from_secs ( duration) {
@@ -100,11 +105,12 @@ impl<'a> Scheduler<'a> {
100105 async fn make_request (
101106 metrics : & Arc < Metrics > ,
102107 client : & Client ,
108+ method : & Method ,
103109 url : & str ,
104110 ) -> Result < String , reqwest:: Error > {
105111 let start = std:: time:: Instant :: now ( ) ;
106112
107- let resp = client. get ( url) . send ( ) . await ?;
113+ let resp = client. request ( method . clone ( ) , url) . send ( ) . await ?;
108114 let _status = resp. status ( ) ;
109115 let body = resp. text ( ) . await ?;
110116
0 commit comments