@@ -108,35 +108,6 @@ impl Client {
108
108
Ok ( subscription)
109
109
}
110
110
111
- // todo - deprecate - move to service subscriber
112
- pub async fn get_endpoints (
113
- & self ,
114
- service_name : & str ,
115
- timeout : time:: Duration ,
116
- ) -> Result < Vec < Bytes > , anyhow:: Error > {
117
- let subject = format ! ( "$SRV.STATS.{}" , service_name) ;
118
- let reply_subject = format ! ( "_INBOX.{}" , nuid:: next( ) ) ;
119
- let mut subscription = self . client . subscribe ( reply_subject. clone ( ) ) . await ?;
120
-
121
- let deadline = tokio:: time:: Instant :: now ( ) + timeout;
122
-
123
- // Publish the request with the reply-to subject
124
- self . client
125
- . publish_with_reply ( subject, reply_subject, "" . into ( ) )
126
- . await ?;
127
-
128
- // Set a timeout to gather responses
129
- let mut responses = Vec :: new ( ) ;
130
- // let mut response_stream = subscription.take_while(|_| futures::future::ready(true));
131
-
132
- while let Ok ( Some ( message) ) = time:: timeout_at ( deadline, subscription. next ( ) ) . await {
133
- // log::debug!("get endpoint received message before timeout: {:?}", message);
134
- responses. push ( message. payload ) ;
135
- }
136
-
137
- Ok ( responses)
138
- }
139
-
140
111
// /// create a new stream
141
112
// async fn get_or_create_work_queue_stream(
142
113
// &self,
@@ -272,35 +243,6 @@ impl Client {
272
243
// Ok(())
273
244
// }
274
245
275
- // pub async fn get_endpoints(
276
- // &self,
277
- // service_name: &str,
278
- // timeout: Duration,
279
- // ) -> Result<Vec<Bytes>, anyhow::Error> {
280
- // let subject = format!("$SRV.STATS.{}", service_name);
281
- // let reply_subject = format!("_INBOX.{}", nuid::next());
282
- // let mut subscription = self.client.subscribe(reply_subject.clone()).await?;
283
-
284
- // // Publish the request with the reply-to subject
285
- // self.client
286
- // .publish_with_reply(subject, reply_subject, "".into())
287
- // .await?;
288
-
289
- // // Set a timeout to gather responses
290
- // let mut responses = Vec::new();
291
- // // let mut response_stream = subscription.take_while(|_| futures::future::ready(true));
292
-
293
- // let start = time::Instant::now();
294
- // while let Ok(Some(message)) = time::timeout(timeout, subscription.next()).await {
295
- // responses.push(message.payload);
296
- // if start.elapsed() > timeout {
297
- // break;
298
- // }
299
- // }
300
-
301
- // Ok(responses)
302
- // }
303
-
304
246
// pub fn frontend_client(&self, request_id: String) -> SpecializedClient {
305
247
// SpecializedClient::new(self.client.clone(), ClientKind::Frontend, request_id)
306
248
// }
@@ -691,35 +633,6 @@ mod tests {
691
633
// assert_eq!(initial_work_queue_count, work_queue_count);
692
634
// }
693
635
694
- // pub async fn get_endpoints(
695
- // &self,
696
- // service_name: &str,
697
- // timeout: Duration,
698
- // ) -> Result<Vec<Bytes>, anyhow::Error> {
699
- // let subject = format!("$SRV.STATS.{}", service_name);
700
- // let reply_subject = format!("_INBOX.{}", nuid::next());
701
- // let mut subscription = self.client.subscribe(reply_subject.clone()).await?;
702
-
703
- // // Publish the request with the reply-to subject
704
- // self.client
705
- // .publish_with_reply(subject, reply_subject, "".into())
706
- // .await?;
707
-
708
- // // Set a timeout to gather responses
709
- // let mut responses = Vec::new();
710
- // // let mut response_stream = subscription.take_while(|_| futures::future::ready(true));
711
-
712
- // let start = time::Instant::now();
713
- // while let Ok(Some(message)) = time::timeout(timeout, subscription.next()).await {
714
- // responses.push(message.payload);
715
- // if start.elapsed() > timeout {
716
- // break;
717
- // }
718
- // }
719
-
720
- // Ok(responses)
721
- // }
722
-
723
636
// async fn connect(config: Arc<Config>) -> Result<NatsClient> {
724
637
// let client = ClientOptions::builder()
725
638
// .server(config.nats_address.clone())
@@ -852,35 +765,6 @@ mod tests {
852
765
// pub fn service_builder(&self) -> NatsServiceBuilder {
853
766
// self.client.service_builder()
854
767
// }
855
-
856
- // pub async fn get_endpoints(
857
- // &self,
858
- // service_name: &str,
859
- // timeout: Duration,
860
- // ) -> Result<Vec<Bytes>, anyhow::Error> {
861
- // let subject = format!("$SRV.STATS.{}", service_name);
862
- // let reply_subject = format!("_INBOX.{}", nuid::next());
863
- // let mut subscription = self.client.subscribe(reply_subject.clone()).await?;
864
-
865
- // // Publish the request with the reply-to subject
866
- // self.client
867
- // .publish_with_reply(subject, reply_subject, "".into())
868
- // .await?;
869
-
870
- // // Set a timeout to gather responses
871
- // let mut responses = Vec::new();
872
- // // let mut response_stream = subscription.take_while(|_| futures::future::ready(true));
873
-
874
- // let start = tokio::time::Instant::now();
875
- // while let Ok(Some(message)) = tokio::time::timeout(timeout, subscription.next()).await {
876
- // responses.push(message.payload);
877
- // if start.elapsed() > timeout {
878
- // break;
879
- // }
880
- // }
881
-
882
- // Ok(responses)
883
- // }
884
768
// }
885
769
886
770
// #[derive(Debug, Clone, Serialize, Deserialize)]
0 commit comments