-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: first batch of client APIs (#231)
* feat: client api WIP * feat: client auth handler wip * feat: implement client connect WIP * feat: implement client message loop * feat: corrected implementation of clientsocket * feat: implement ssl handshake when no tls feature enabled * feat: implement ssl negotiation for non-ssl scenario * feat: implement tls connect * refactor: feature gate client-api
- Loading branch information
Showing
8 changed files
with
1,538 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
mod auth; | ||
pub(crate) mod config; | ||
|
||
use std::sync::Arc; | ||
|
||
pub use config::Config; | ||
|
||
/// The collection of all client handlers | ||
pub trait PgWireClientHandlers { | ||
type StartupHandler: auth::StartupHandler; | ||
|
||
fn startup_handler(&self) -> Arc<Self::StartupHandler>; | ||
} | ||
|
||
impl<T> PgWireClientHandlers for Arc<T> | ||
where | ||
T: PgWireClientHandlers, | ||
{ | ||
type StartupHandler = T::StartupHandler; | ||
|
||
fn startup_handler(&self) -> Arc<Self::StartupHandler> { | ||
(**self).startup_handler() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use async_trait::async_trait; | ||
|
||
use crate::error::PgWireResult; | ||
use crate::messages::response::{ReadyForQuery, SslResponse}; | ||
use crate::messages::startup::{Authentication, BackendKeyData, ParameterStatus}; | ||
|
||
use super::Config; | ||
|
||
#[async_trait] | ||
pub trait StartupHandler: Send + Sync { | ||
async fn startup(&self, config: &Config) -> PgWireResult<()>; | ||
|
||
async fn on_authentication(&self, message: Authentication) -> PgWireResult<()>; | ||
|
||
async fn on_parameter_status(&self, message: ParameterStatus) -> PgWireResult<()>; | ||
|
||
async fn on_backend_key(&self, message: BackendKeyData) -> PgWireResult<()>; | ||
|
||
async fn on_ready_for_query(&self, message: ReadyForQuery) -> PgWireResult<()>; | ||
} |
Oops, something went wrong.