Description
Concurrent PostgreSQL protocol server parameterized by application authentication and command handling.
Authenticate
function Authenticate
(Context : in out Handler_Context;
Startup : Protocol.Startup_Information;
Password : String) return Boolean
Parameters
- Context
- Startup
- Password
Return value
Authentication
Authentication : Authentication_Method := Trust;
Classify_SCRAM_Verifier
procedure Classify_SCRAM_Verifier
(Context : in out Handler_Context;
Startup : Protocol.Startup_Information;
Verifier : String;
Has_Credential : in out Boolean)
Optionally downgrade a nonempty verifier to a mock credential. Setting Has_Credential to True never makes an empty verifier authenticatable. Verifier is the exact Lookup_SCRAM_Verifier result, and Has_Credential is initially True exactly when that result is nonempty.
Parameters
- Context
- Startup
- Verifier
- Has_Credential
Command_Timeout
Command_Timeout : Duration := Flyology.IO.Infinite;
Handle
procedure Handle
(Context : in out Handler_Context;
Client : in out Server_Sessions.Session;
Command : Protocol.Message)
Parameters
- Context
- Client
- Command
Handler_Context
type Handler_Context (<>) is limited private;
Handler_CPU
Handler_CPU : System.Multiprocessors.CPU_Range :=
System.Multiprocessors.Not_A_Specific_CPU;
Handler_Model
Handler_Model : Flyology.Execution_Model := Flyology.Project_Default;
Lookup_SCRAM_Verifier
function Lookup_SCRAM_Verifier
(Context : in out Handler_Context;
Startup : Protocol.Startup_Information) return String
Return the Postgres rolpassword form SCRAM-SHA-256$iterations:salt$StoredKey:ServerKey, or "" when the startup user has no credential. Plaintext is never requested by the SCRAM authentication path.
Parameters
- Context
- Startup
Return value
Provide_SCRAM_Mock_Secret
procedure Provide_SCRAM_Mock_Secret
(Context : in out Handler_Context;
Secret : in out Flyology.Postgres.SCRAM.Digest;
Provided : in out Boolean)
Supply the persistent cluster secret used to disguise absent roles. SCRAM servers require a nonzero unpredictable value shared by all processes in the cluster and retained across restarts. Other authentication methods do not call this procedure. Mock challenges use SCRAM.Minimum_Iterations; real verifiers with another iteration count remain distinguishable by that count. Secret and Provided initially contain zero and False; a SCRAM Serve raises Program_Error unless the procedure replaces them with a nonzero secret and True.
Parameters
- Context
- Secret
- Provided
Request_Shutdown
procedure Request_Shutdown (Item : in out Server)
Request a stop to new connection admission. Active handlers drain until they complete or the Drain_Timeout of Serve or Serve_TLS expires; on expiry, remaining handlers are asked to cancel. With the default infinite drain, Serve or Serve_TLS may wait indefinitely for handlers to finish. This operation is idempotent and may be called from another task.
Parameters
- Item
Running server to stop.
Serve
procedure Serve
(Item : aliased in out Server;
Listener : in out Flyology.IO.Sockets.Socket_Type;
Context : aliased in out Handler_Context;
Drain_Timeout : Duration := Flyology.IO.Infinite)
Accept and process plaintext PostgreSQL connections until shutdown.
Parameters
- Item
Server instance; Serve may be called only once at a time.
- Listener
Open listening socket owned by the caller.
- Context
Application state passed to all callbacks.
- Drain_Timeout
Time allowed for active handlers after shutdown.
Serve_TLS
procedure Serve_TLS
(Item : aliased in out Server;
Listener : in out Flyology.IO.Sockets.Socket_Type;
Context : aliased in out Handler_Context;
Backend : aliased in out Flyology.IO.TLS.Provider'Class;
Policy : TLS_Policy := TLS_Required;
Drain_Timeout : Duration := Flyology.IO.Infinite)
Serve with PostgreSQL SSLRequest negotiation. TLS_Allowed accepts both modes; TLS_Required rejects plaintext. Direct TLS negotiation is not supported, and TLS_Disabled is represented by ordinary Serve.
Parameters
- Item
Server instance; Serve_TLS may be called only once at a time.
- Listener
Open listening socket owned by the caller.
- Context
Application state passed to all callbacks.
- Backend
TLS provider, certificate, key, and trust configuration.
- Policy
Whether plaintext startup is allowed or rejected.
- Drain_Timeout
Time allowed for active handlers after shutdown.
Raised exceptions
- Constraint_Error
Policy is TLS_Disabled.
Server
type Server (Capacity : Positive) is limited private;
Server instance with bounded cancellation-routing capacity.
Record fields
- Capacity
Maximum number of concurrently registered sessions.
Startup_Timeout
Startup_Timeout : Duration := 30.0;
Write_Timeout
Write_Timeout : Duration := 30.0;