pub struct Server {
pub configuration: Arc<ServerConf>,
pub options: Option<Opt>,
/* private fields */
}Expand description
The server object
This object represents an entire pingora server process which may have multiple independent services (see crate::services). The server object handles signals, reading configuration, zero downtime upgrade and error reporting.
Fields§
§configuration: Arc<ServerConf>The parsed server configuration
options: Option<Opt>The parser command line options
Implementations§
Source§impl Server
impl Server
Sourcepub fn watch_execution_phase(&self) -> Receiver<ExecutionPhase>
pub fn watch_execution_phase(&self) -> Receiver<ExecutionPhase>
Acquire a receiver for the server’s execution phase.
The receiver will produce values for each transition.
Sourcepub fn new_with_opt_and_conf(
raw_opt: impl Into<Option<Opt>>,
conf: ServerConf,
) -> Server
pub fn new_with_opt_and_conf( raw_opt: impl Into<Option<Opt>>, conf: ServerConf, ) -> Server
Create a new Server, using the Opt and ServerConf values provided
This method is intended for pingora frontends that are NOT using the built-in command line and configuration file parsing, and are instead using their own.
If a configuration file path is provided as part of opt, it will be ignored
and a warning will be logged.
Sourcepub fn add_service(&mut self, service: impl Service + 'static)
pub fn add_service(&mut self, service: impl Service + 'static)
Add a service to this server.
A service is anything that implements Service.
Sourcepub fn add_services(&mut self, services: Vec<Box<dyn Service>>)
pub fn add_services(&mut self, services: Vec<Box<dyn Service>>)
Similar to Self::add_service(), but take a list of services
Sourcepub fn bootstrap(&mut self)
pub fn bootstrap(&mut self)
Prepare the server to start
When trying to zero downtime upgrade from an older version of the server which is already running, this function will try to get all its listening sockets in order to take them over.
Sourcepub fn run_forever(self) -> !
pub fn run_forever(self) -> !
Start the server using Self::run and default RunArgs.
This function will block forever until the server needs to quit. So this would be the last function to call for this object.
Note: this function may fork the process for daemonization, so any additional threads created before this function will be lost to any service logic once this function is called.
Sourcepub fn run(self, run_args: RunArgs)
pub fn run(self, run_args: RunArgs)
Run the server until execution finished.
This function will run until the server has been instructed to shut down through a signal, and will then wait for all services to finish and runtimes to exit.
Note: if daemonization is enabled in the config, this function will never return. Instead it will either start the daemon process and exit, or panic if daemonization fails.
Auto Trait Implementations§
impl Freeze for Server
impl !RefUnwindSafe for Server
impl Send for Server
impl Sync for Server
impl Unpin for Server
impl !UnwindSafe for Server
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.