Skip to content

Commit

Permalink
Map mobc pool errors to type that would invalidate connection
Browse files Browse the repository at this point in the history
  • Loading branch information
criminosis committed Aug 27, 2024
1 parent 093c04c commit 802a20c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 3 additions & 1 deletion gremlin-client/src/aio/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,9 @@ impl Conn {
.map_err(|e| {
//If there's been an websocket layer error, mark the connection as invalid
match e {
GremlinError::WebSocket(_) | GremlinError::WebSocketAsync(_) => {
GremlinError::WebSocket(_)
| GremlinError::WebSocketAsync(_)
| GremlinError::WebSocketPoolAsync(_) => {
self.valid = false;
}
_ => {}
Expand Down
8 changes: 4 additions & 4 deletions gremlin-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ pub enum GremlinError {
WebSocketAsync(#[from] Arc<async_tungstenite::tungstenite::Error>),
#[cfg(feature = "async_gremlin")]
#[error(transparent)]
WebSocketPoolAsync(#[from] Arc<mobc::Error<GremlinError>>),
#[cfg(feature = "async_gremlin")]
#[error(transparent)]
ChannelSend(#[from] futures::channel::mpsc::SendError),
#[error(transparent)]
Uuid(#[from] uuid::Error),
Expand All @@ -49,10 +52,7 @@ impl From<mobc::Error<GremlinError>> for GremlinError {
fn from(e: mobc::Error<GremlinError>) -> GremlinError {
match e {
mobc::Error::Inner(e) => e,
mobc::Error::BadConn => {
GremlinError::Generic(String::from("Async pool bad connection"))
}
mobc::Error::Timeout => GremlinError::Generic(String::from("Async pool timeout")),
other => GremlinError::WebSocketPoolAsync(Arc::new(other)),
}
}
}
Expand Down

0 comments on commit 802a20c

Please sign in to comment.