Skip to content

Commit

Permalink
refactor: do not require Arc for handler factory (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Sep 20, 2024
1 parent 3bf4b7b commit 312210e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,29 @@ pub trait PgWireHandlerFactory {

fn copy_handler(&self) -> Arc<Self::CopyHandler>;
}

impl<T> PgWireHandlerFactory for Arc<T>
where
T: PgWireHandlerFactory,
{
type StartupHandler = T::StartupHandler;
type SimpleQueryHandler = T::SimpleQueryHandler;
type ExtendedQueryHandler = T::ExtendedQueryHandler;
type CopyHandler = T::CopyHandler;

fn simple_query_handler(&self) -> Arc<Self::SimpleQueryHandler> {
(**self).simple_query_handler()
}

fn extended_query_handler(&self) -> Arc<Self::ExtendedQueryHandler> {
(**self).extended_query_handler()
}

fn startup_handler(&self) -> Arc<Self::StartupHandler> {
(**self).startup_handler()
}

fn copy_handler(&self) -> Arc<Self::CopyHandler> {
(**self).copy_handler()
}
}
2 changes: 1 addition & 1 deletion src/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ fn check_alpn_for_direct_ssl<IO>(tls_socket: &TlsStream<IO>) -> Result<(), IOErr
pub async fn process_socket<H>(
tcp_socket: TcpStream,
tls_acceptor: Option<Arc<TlsAcceptor>>,
handlers: Arc<H>,
handlers: H,
) -> Result<(), IOError>
where
H: PgWireHandlerFactory,
Expand Down

0 comments on commit 312210e

Please sign in to comment.