From 06e97c440fbe165584d5aba1ffb6a2e05c953631 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Fri, 6 Dec 2024 19:33:38 +0800 Subject: [PATCH] refactor: rename PgWireHandlerFactory to PgWireServerHandlers --- examples/bench.rs | 4 ++-- examples/copy.rs | 4 ++-- examples/duckdb.rs | 4 ++-- examples/gluesql.rs | 4 ++-- examples/scram.rs | 4 ++-- examples/secure_server.rs | 4 ++-- examples/server.rs | 4 ++-- examples/sqlite.rs | 4 ++-- examples/transaction.rs | 4 ++-- src/api/mod.rs | 6 +++--- src/tokio/server.rs | 4 ++-- tests-integration/test-server/src/main.rs | 4 ++-- 12 files changed, 25 insertions(+), 25 deletions(-) diff --git a/examples/bench.rs b/examples/bench.rs index 624fc5f..4c19591 100644 --- a/examples/bench.rs +++ b/examples/bench.rs @@ -4,7 +4,7 @@ use async_trait::async_trait; use futures::stream; use futures::StreamExt; use pgwire::api::NoopErrorHandler; -use pgwire::api::PgWireHandlerFactory; +use pgwire::api::PgWireServerHandlers; use tokio::net::TcpListener; use pgwire::api::auth::noop::NoopStartupHandler; @@ -74,7 +74,7 @@ struct DummyProcessorFactory { handler: Arc, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = DummyProcessor; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/copy.rs b/examples/copy.rs index aae182d..13b8ddb 100644 --- a/examples/copy.rs +++ b/examples/copy.rs @@ -9,7 +9,7 @@ use pgwire::api::auth::noop::NoopStartupHandler; use pgwire::api::copy::CopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{CopyResponse, Response}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireConnectionState, PgWireHandlerFactory}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireConnectionState, PgWireServerHandlers}; use pgwire::error::ErrorInfo; use pgwire::error::{PgWireError, PgWireResult}; use pgwire::messages::copy::{CopyData, CopyDone, CopyFail}; @@ -106,7 +106,7 @@ struct DummyProcessorFactory { handler: Arc, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = DummyProcessor; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/duckdb.rs b/examples/duckdb.rs index 3cebcf7..b575315 100644 --- a/examples/duckdb.rs +++ b/examples/duckdb.rs @@ -16,7 +16,7 @@ use pgwire::api::results::{ Response, Tag, }; use pgwire::api::stmt::{NoopQueryParser, StoredStatement}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::{ErrorInfo, PgWireError, PgWireResult}; use pgwire::messages::data::DataRow; use pgwire::tokio::process_socket; @@ -328,7 +328,7 @@ struct DuckDBBackendFactory { handler: Arc, } -impl PgWireHandlerFactory for DuckDBBackendFactory { +impl PgWireServerHandlers for DuckDBBackendFactory { type StartupHandler = Md5PasswordAuthStartupHandler; type SimpleQueryHandler = DuckDBBackend; diff --git a/examples/gluesql.rs b/examples/gluesql.rs index 0aa1ff1..21a2723 100644 --- a/examples/gluesql.rs +++ b/examples/gluesql.rs @@ -9,7 +9,7 @@ use pgwire::api::auth::noop::NoopStartupHandler; use pgwire::api::copy::NoopCopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{DataRowEncoder, FieldFormat, FieldInfo, QueryResponse, Response, Tag}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::{PgWireError, PgWireResult}; use pgwire::tokio::process_socket; @@ -165,7 +165,7 @@ struct GluesqlHandlerFactory { processor: Arc, } -impl PgWireHandlerFactory for GluesqlHandlerFactory { +impl PgWireServerHandlers for GluesqlHandlerFactory { type StartupHandler = GluesqlProcessor; type SimpleQueryHandler = GluesqlProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/scram.rs b/examples/scram.rs index 854a059..ea10950 100644 --- a/examples/scram.rs +++ b/examples/scram.rs @@ -16,7 +16,7 @@ use pgwire::api::copy::NoopCopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{Response, Tag}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers}; use pgwire::error::PgWireResult; use pgwire::tokio::process_socket; @@ -78,7 +78,7 @@ struct DummyProcessorFactory { cert: Vec, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = SASLScramAuthStartupHandler; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/secure_server.rs b/examples/secure_server.rs index 0630cc7..07292dc 100644 --- a/examples/secure_server.rs +++ b/examples/secure_server.rs @@ -14,7 +14,7 @@ use pgwire::api::auth::noop::NoopStartupHandler; use pgwire::api::copy::NoopCopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{DataRowEncoder, FieldFormat, FieldInfo, QueryResponse, Response, Tag}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::PgWireResult; use pgwire::tokio::process_socket; @@ -85,7 +85,7 @@ struct DummyProcessorFactory { handler: Arc, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = DummyProcessor; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/server.rs b/examples/server.rs index dd8ab11..02c41b9 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -9,7 +9,7 @@ use pgwire::api::auth::noop::NoopStartupHandler; use pgwire::api::copy::NoopCopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{DataRowEncoder, FieldFormat, FieldInfo, QueryResponse, Response, Tag}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::ErrorInfo; use pgwire::error::{PgWireError, PgWireResult}; use pgwire::messages::response::NoticeResponse; @@ -75,7 +75,7 @@ struct DummyProcessorFactory { handler: Arc, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = DummyProcessor; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/examples/sqlite.rs b/examples/sqlite.rs index 6c53386..cc354e9 100644 --- a/examples/sqlite.rs +++ b/examples/sqlite.rs @@ -15,7 +15,7 @@ use pgwire::api::results::{ }; use pgwire::api::stmt::{NoopQueryParser, StoredStatement}; use pgwire::api::NoopErrorHandler; -use pgwire::api::PgWireHandlerFactory; +use pgwire::api::PgWireServerHandlers; use pgwire::api::{ClientInfo, Type}; use pgwire::error::{ErrorInfo, PgWireError, PgWireResult}; use pgwire::messages::data::DataRow; @@ -286,7 +286,7 @@ struct SqliteBackendFactory { handler: Arc, } -impl PgWireHandlerFactory for SqliteBackendFactory { +impl PgWireServerHandlers for SqliteBackendFactory { type StartupHandler = Md5PasswordAuthStartupHandler; type SimpleQueryHandler = SqliteBackend; diff --git a/examples/transaction.rs b/examples/transaction.rs index ce579f8..249a507 100644 --- a/examples/transaction.rs +++ b/examples/transaction.rs @@ -9,7 +9,7 @@ use pgwire::api::auth::noop::NoopStartupHandler; use pgwire::api::copy::NoopCopyHandler; use pgwire::api::query::{PlaceholderExtendedQueryHandler, SimpleQueryHandler}; use pgwire::api::results::{DataRowEncoder, FieldFormat, FieldInfo, QueryResponse, Response, Tag}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::ErrorInfo; use pgwire::error::{PgWireError, PgWireResult}; use pgwire::messages::response::NoticeResponse; @@ -91,7 +91,7 @@ struct DummyProcessorFactory { handler: Arc, } -impl PgWireHandlerFactory for DummyProcessorFactory { +impl PgWireServerHandlers for DummyProcessorFactory { type StartupHandler = DummyProcessor; type SimpleQueryHandler = DummyProcessor; type ExtendedQueryHandler = PlaceholderExtendedQueryHandler; diff --git a/src/api/mod.rs b/src/api/mod.rs index 5b9b983..e7e0066 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -140,7 +140,7 @@ pub struct NoopErrorHandler; impl ErrorHandler for NoopErrorHandler {} -pub trait PgWireHandlerFactory { +pub trait PgWireServerHandlers { type StartupHandler: auth::StartupHandler; type SimpleQueryHandler: query::SimpleQueryHandler; type ExtendedQueryHandler: query::ExtendedQueryHandler; @@ -158,9 +158,9 @@ pub trait PgWireHandlerFactory { fn error_handler(&self) -> Arc; } -impl PgWireHandlerFactory for Arc +impl PgWireServerHandlers for Arc where - T: PgWireHandlerFactory, + T: PgWireServerHandlers, { type StartupHandler = T::StartupHandler; type SimpleQueryHandler = T::SimpleQueryHandler; diff --git a/src/tokio/server.rs b/src/tokio/server.rs index 29d5fe6..078a6ec 100644 --- a/src/tokio/server.rs +++ b/src/tokio/server.rs @@ -15,7 +15,7 @@ use crate::api::query::SimpleQueryHandler; use crate::api::query::{send_ready_for_query, ExtendedQueryHandler}; use crate::api::{ ClientInfo, ClientPortalStore, DefaultClient, ErrorHandler, PgWireConnectionState, - PgWireHandlerFactory, + PgWireServerHandlers, }; use crate::error::{ErrorInfo, PgWireError, PgWireResult}; use crate::messages::response::ReadyForQuery; @@ -385,7 +385,7 @@ pub async fn process_socket( handlers: H, ) -> Result<(), IOError> where - H: PgWireHandlerFactory, + H: PgWireServerHandlers, { let addr = tcp_socket.peer_addr()?; tcp_socket.set_nodelay(true)?; diff --git a/tests-integration/test-server/src/main.rs b/tests-integration/test-server/src/main.rs index df288ff..41d3f2a 100644 --- a/tests-integration/test-server/src/main.rs +++ b/tests-integration/test-server/src/main.rs @@ -21,7 +21,7 @@ use pgwire::api::results::{ Response, Tag, }; use pgwire::api::stmt::{NoopQueryParser, StoredStatement}; -use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireHandlerFactory, Type}; +use pgwire::api::{ClientInfo, NoopErrorHandler, PgWireServerHandlers, Type}; use pgwire::error::PgWireResult; use pgwire::tokio::process_socket; use tokio::net::TcpListener; @@ -217,7 +217,7 @@ impl ExtendedQueryHandler for DummyDatabase { struct DummyDatabaseFactory(Arc); -impl PgWireHandlerFactory for DummyDatabaseFactory { +impl PgWireServerHandlers for DummyDatabaseFactory { type StartupHandler = SASLScramAuthStartupHandler; type SimpleQueryHandler = DummyDatabase;