Skip to content

Commit 6da99e2

Browse files
committed
tests/util/chaosproxy: Return anyhow::Result instead of using the ambiguous Error import
1 parent ac69fa6 commit 6da99e2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/tests/util/chaosproxy.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use anyhow::{Context, Error};
1+
use anyhow::Context;
22
use std::net::SocketAddr;
33
use std::sync::Arc;
44
use tokio::{
@@ -23,7 +23,7 @@ pub(crate) struct ChaosProxy {
2323
}
2424

2525
impl ChaosProxy {
26-
pub(crate) fn new(backend_address: SocketAddr) -> Result<Arc<Self>, Error> {
26+
pub(crate) fn new(backend_address: SocketAddr) -> anyhow::Result<Arc<Self>> {
2727
let runtime = Runtime::new().expect("failed to create Tokio runtime");
2828
let listener = runtime.block_on(TcpListener::bind("127.0.0.1:0"))?;
2929

@@ -50,7 +50,7 @@ impl ChaosProxy {
5050
Ok(instance)
5151
}
5252

53-
pub(crate) fn proxy_database_url(url: &str) -> Result<(Arc<Self>, String), Error> {
53+
pub(crate) fn proxy_database_url(url: &str) -> anyhow::Result<(Arc<Self>, String)> {
5454
let mut db_url = Url::parse(url).context("failed to parse database url")?;
5555
let backend_addr = db_url
5656
.socket_addrs(|| Some(5432))
@@ -77,7 +77,7 @@ impl ChaosProxy {
7777
.context("Failed to send the restore_networking message")
7878
}
7979

80-
async fn server_loop(&self, initial_listener: TcpListener) -> Result<(), Error> {
80+
async fn server_loop(&self, initial_listener: TcpListener) -> anyhow::Result<()> {
8181
let mut listener = Some(initial_listener);
8282

8383
let mut break_networking_recv = self.break_networking_send.subscribe();
@@ -104,7 +104,7 @@ impl ChaosProxy {
104104
}
105105
}
106106

107-
async fn accept_connection(&self, accepted: TcpStream) -> Result<(), Error> {
107+
async fn accept_connection(&self, accepted: TcpStream) -> anyhow::Result<()> {
108108
let (client_read, client_write) = accepted.into_split();
109109
let (backend_read, backend_write) = TcpStream::connect(&self.backend_address)
110110
.await?
@@ -132,7 +132,7 @@ async fn proxy_data(
132132
break_networking_send: Sender<()>,
133133
mut from: OwnedReadHalf,
134134
mut to: OwnedWriteHalf,
135-
) -> Result<(), Error> {
135+
) -> anyhow::Result<()> {
136136
let mut break_connections_recv = break_networking_send.subscribe();
137137
let mut buf = [0; 1024];
138138

0 commit comments

Comments
 (0)