pub struct Server<S, C, P>{ /* private fields */ }Expand description
Application Server. It handles object registration (Registry), clustering (through ClusterProviders), server state (via AppData), and more.
It handles various types of request: AdminCommands, RequestEnvelope, and SubscriptionRequest.
More of it can be seen in Server::run.
TODO example builder
Implementations§
Source§impl<S, C, P> Server<S, C, P>
impl<S, C, P> Server<S, C, P>
Sourcepub fn builder() -> ServerBuilder<S, C, P>
pub fn builder() -> ServerBuilder<S, C, P>
Create an instance of Server using the builder syntax
Source§impl<S, C, P> Server<S, C, P>where
S: MembershipStorage + 'static,
C: ClusterProvider<S> + Send + Sync + 'static,
P: ObjectPlacement + 'static,
impl<S, C, P> Server<S, C, P>where
S: MembershipStorage + 'static,
C: ClusterProvider<S> + Send + Sync + 'static,
P: ObjectPlacement + 'static,
pub async fn prepare(&self)
pub fn app_data<Data>(&mut self, data: Data)
Sourcepub async fn bind(&mut self) -> Result<TcpListener, ServerError>
pub async fn bind(&mut self) -> Result<TcpListener, ServerError>
Setup the server for running it
Sourcepub fn try_local_addr(listener: &TcpListener) -> Result<SocketAddr, ServerError>
pub fn try_local_addr(listener: &TcpListener) -> Result<SocketAddr, ServerError>
Tries to get a local address
It will get the first ip address for the machine where it is running, and fallback to the address given by tokio’s listener
It potentially won’t work on machine with multiple interfaces. So we need to add support to address mapping per node before merging this.
For now, if that is your case, you need to specify the IP for binding
Sourcepub async fn run(&mut self, listener: TcpListener) -> Result<(), ServerError>
pub async fn run(&mut self, listener: TcpListener) -> Result<(), ServerError>
Run the server forever
This is the main loop for a Rio server. It will handle a few types of future concurrently:
- New TCP connections from clients
- AdminCommands messages from running objects
- ClusterProvider server loop
If any of these fails, the server stops running with a ServerError
Trait Implementations§
Source§impl<S, C, P> TryFrom<&Server<S, C, P>> for Service<S, P>where
S: MembershipStorage + 'static,
C: ClusterProvider<S> + 'static + Send + Sync,
P: ObjectPlacement + 'static,
impl<S, C, P> TryFrom<&Server<S, C, P>> for Service<S, P>where
S: MembershipStorage + 'static,
C: ClusterProvider<S> + 'static + Send + Sync,
P: ObjectPlacement + 'static,
It can’t be infalible, because it needs to be bind so it can generate a Service
Auto Trait Implementations§
impl<S, C, P> Freeze for Server<S, C, P>where
C: Freeze,
impl<S, C, P> !RefUnwindSafe for Server<S, C, P>
impl<S, C, P> Send for Server<S, C, P>where
C: Send,
impl<S, C, P> Sync for Server<S, C, P>where
C: Sync,
impl<S, C, P> Unpin for Server<S, C, P>
impl<S, C, P> UnsafeUnpin for Server<S, C, P>where
C: UnsafeUnpin,
impl<S, C, P> !UnwindSafe for Server<S, C, P>
Blanket Implementations§
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 more