pub struct AstraeaServer { /* private fields */ }Expand description
TCP server that accepts newline-delimited JSON requests.
Protocol: each request is a single JSON line, each response is a single JSON line. Supports connection limits, request timeouts, idle timeouts, metrics, auth, TLS/mTLS, and graceful shutdown.
Implementations§
Source§impl AstraeaServer
impl AstraeaServer
Sourcepub fn new(
config: ServerConfig,
handler: RequestHandler,
) -> Result<Self, TlsError>
pub fn new( config: ServerConfig, handler: RequestHandler, ) -> Result<Self, TlsError>
Create a new server. If TLS is configured, this will load the certificates.
§Errors
Returns an error if TLS is configured but certificates cannot be loaded.
Sourcepub fn new_without_tls(config: ServerConfig, handler: RequestHandler) -> Self
pub fn new_without_tls(config: ServerConfig, handler: RequestHandler) -> Self
Create a new server without TLS validation at construction time. Use this for testing or when you want to defer TLS setup.
Sourcepub fn with_auth(self, auth: AuthManager) -> Self
pub fn with_auth(self, auth: AuthManager) -> Self
Create a server with authentication enabled.
Sourcepub fn metrics(&self) -> &Arc<ServerMetrics> ⓘ
pub fn metrics(&self) -> &Arc<ServerMetrics> ⓘ
Get a reference to the metrics collector.
Sourcepub fn connection_manager(&self) -> &Arc<ConnectionManager> ⓘ
pub fn connection_manager(&self) -> &Arc<ConnectionManager> ⓘ
Get a reference to the connection manager (for external shutdown).
Sourcepub async fn run(&self) -> Result<()>
pub async fn run(&self) -> Result<()>
Run the server, accepting connections until shutdown is initiated.
Sourcepub fn is_tls_enabled(&self) -> bool
pub fn is_tls_enabled(&self) -> bool
Check if TLS is enabled for this server.
Auto Trait Implementations§
impl !RefUnwindSafe for AstraeaServer
impl !UnwindSafe for AstraeaServer
impl Freeze for AstraeaServer
impl Send for AstraeaServer
impl Sync for AstraeaServer
impl Unpin for AstraeaServer
impl UnsafeUnpin for AstraeaServer
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request