mirror of
https://github.com/storytold/voder-proxy.git
synced 2026-10-18 07:33:13 +00:00
if I just read the docs, I would have figured this out sooner :|
This commit is contained in:
+2
-2
@@ -7,7 +7,7 @@ pub mod speak_proxy;
|
||||
|
||||
use anyhow::Result as AnyhowResult;
|
||||
use crate::newrelic_logger::{NewRelicLogger, MaybeNewRelicTransaction};
|
||||
use crate::speak_proxy::speak_proxy;
|
||||
use crate::speak_proxy::{speak_proxy, speak_proxy_with_retry};
|
||||
use futures::future::{self, Future};
|
||||
use hyper::Method;
|
||||
use hyper::header::HeaderValue;
|
||||
@@ -179,7 +179,7 @@ fn main() -> AnyhowResult<()> {
|
||||
match (req.method(), req.uri().path()) {
|
||||
(&Method::POST, "/speak") => {
|
||||
let nr_transaction = newrelic_logger3.web_transaction("/speak");
|
||||
speak_proxy(req, remote_addr.clone(), router3, nr_transaction, "/speak")
|
||||
speak_proxy_with_retry(req, remote_addr.clone(), router3, nr_transaction, "/speak")
|
||||
},
|
||||
(&Method::POST, "/speak_spectrogram") => {
|
||||
let nr_transaction = newrelic_logger3.web_transaction("/speak_spectrogram");
|
||||
|
||||
@@ -17,6 +17,7 @@ use std::fmt::Display;
|
||||
use std::net::SocketAddr;
|
||||
use std::str::FromStr;
|
||||
use std::sync::Arc;
|
||||
use futures::IntoFuture;
|
||||
|
||||
/// NB: This much match the shape of SpeakRequest in the 'voder/tts_service' code.
|
||||
/// This is used for both /speak and /speak_spectrogram requests.
|
||||
@@ -33,6 +34,23 @@ struct RequestDetails {
|
||||
pub speaker: String,
|
||||
}
|
||||
|
||||
pub fn speak_proxy_with_retry(
|
||||
req: Request<Body>,
|
||||
remote_addr: SocketAddr,
|
||||
router: Arc<Router>,
|
||||
transaction: MaybeNewRelicTransaction,
|
||||
endpoint: &'static str) -> BoxFut
|
||||
{
|
||||
speak_proxy(req, remote_addr, router, transaction, endpoint)
|
||||
.then(|result| {
|
||||
match result {
|
||||
Ok(t) => future::ok(t),
|
||||
Err(t) => future::err(t),
|
||||
}
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
|
||||
pub fn speak_proxy(
|
||||
req: Request<Body>,
|
||||
remote_addr: SocketAddr,
|
||||
|
||||
Reference in New Issue
Block a user