Skip to main content

Server

Struct Server 

Source
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>

Source

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,

Source

pub async fn prepare(&self)

Source

pub fn app_data<Data>(&mut self, data: Data)
where Data: Send + Sync + 'static,

Source

pub async fn bind(&mut self) -> Result<TcpListener, ServerError>

Setup the server for running it

Source

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

**TODO**

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

Source

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:

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,

Transforms a Server into a Service

It can’t be infalible, because it needs to be bind so it can generate a Service

Source§

type Error = ServerError

The type returned in the event of a conversion error.
Source§

fn try_from(server: &Server<S, C, P>) -> Result<Self, Self::Error>

Performs the conversion.

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>
where C: Unpin, S: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more