Skip to content

Commit

Permalink
refactor: rename PgWireHandlerFactory to PgWireServerHandlers (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 authored Dec 7, 2024
1 parent cdb0d02 commit 61db42e
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 25 deletions.
4 changes: 2 additions & 2 deletions examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -74,7 +74,7 @@ struct DummyProcessorFactory {
handler: Arc<DummyProcessor>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = DummyProcessor;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/copy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -106,7 +106,7 @@ struct DummyProcessorFactory {
handler: Arc<DummyProcessor>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = DummyProcessor;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/duckdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -328,7 +328,7 @@ struct DuckDBBackendFactory {
handler: Arc<DuckDBBackend>,
}

impl PgWireHandlerFactory for DuckDBBackendFactory {
impl PgWireServerHandlers for DuckDBBackendFactory {
type StartupHandler =
Md5PasswordAuthStartupHandler<DummyAuthSource, DefaultServerParameterProvider>;
type SimpleQueryHandler = DuckDBBackend;
Expand Down
4 changes: 2 additions & 2 deletions examples/gluesql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -165,7 +165,7 @@ struct GluesqlHandlerFactory {
processor: Arc<GluesqlProcessor>,
}

impl PgWireHandlerFactory for GluesqlHandlerFactory {
impl PgWireServerHandlers for GluesqlHandlerFactory {
type StartupHandler = GluesqlProcessor;
type SimpleQueryHandler = GluesqlProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/scram.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -78,7 +78,7 @@ struct DummyProcessorFactory {
cert: Vec<u8>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = SASLScramAuthStartupHandler<DummyAuthDB, DefaultServerParameterProvider>;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/secure_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -85,7 +85,7 @@ struct DummyProcessorFactory {
handler: Arc<DummyProcessor>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = DummyProcessor;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +75,7 @@ struct DummyProcessorFactory {
handler: Arc<DummyProcessor>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = DummyProcessor;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions examples/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -286,7 +286,7 @@ struct SqliteBackendFactory {
handler: Arc<SqliteBackend>,
}

impl PgWireHandlerFactory for SqliteBackendFactory {
impl PgWireServerHandlers for SqliteBackendFactory {
type StartupHandler =
Md5PasswordAuthStartupHandler<DummyAuthSource, DefaultServerParameterProvider>;
type SimpleQueryHandler = SqliteBackend;
Expand Down
4 changes: 2 additions & 2 deletions examples/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -91,7 +91,7 @@ struct DummyProcessorFactory {
handler: Arc<DummyProcessor>,
}

impl PgWireHandlerFactory for DummyProcessorFactory {
impl PgWireServerHandlers for DummyProcessorFactory {
type StartupHandler = DummyProcessor;
type SimpleQueryHandler = DummyProcessor;
type ExtendedQueryHandler = PlaceholderExtendedQueryHandler;
Expand Down
6 changes: 3 additions & 3 deletions src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,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;
Expand All @@ -163,9 +163,9 @@ pub trait PgWireHandlerFactory {
fn error_handler(&self) -> Arc<Self::ErrorHandler>;
}

impl<T> PgWireHandlerFactory for Arc<T>
impl<T> PgWireServerHandlers for Arc<T>
where
T: PgWireHandlerFactory,
T: PgWireServerHandlers,
{
type StartupHandler = T::StartupHandler;
type SimpleQueryHandler = T::SimpleQueryHandler;
Expand Down
4 changes: 2 additions & 2 deletions src/tokio/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -385,7 +385,7 @@ pub async fn process_socket<H>(
handlers: H,
) -> Result<(), IOError>
where
H: PgWireHandlerFactory,
H: PgWireServerHandlers,
{
let addr = tcp_socket.peer_addr()?;
tcp_socket.set_nodelay(true)?;
Expand Down
4 changes: 2 additions & 2 deletions tests-integration/test-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -217,7 +217,7 @@ impl ExtendedQueryHandler for DummyDatabase {

struct DummyDatabaseFactory(Arc<DummyDatabase>);

impl PgWireHandlerFactory for DummyDatabaseFactory {
impl PgWireServerHandlers for DummyDatabaseFactory {
type StartupHandler =
SASLScramAuthStartupHandler<DummyAuthSource, DefaultServerParameterProvider>;
type SimpleQueryHandler = DummyDatabase;
Expand Down

0 comments on commit 61db42e

Please sign in to comment.