Module jupiter::server

source ·
Expand description

Contains the server component of Jupiter.

Opens a server-socket on the specified port (server.port in the config or 2410 as fallback) and binds it to the selected IP (server.host in the config or 0.0.0.0 as fallback). Each incoming client is expected to send RESP requests and will be provided with the appropriate responses.

Note that in order to achieve zero downtime / ultra high availability demands, the sever will periodically try to bind the socket to the selected port, therefore an “new” instance can be started and the “old” once can bleed out and the port will be “handed through” with minimal downtime. Also, this will listen to change events of the config and will relocate to another port or host if changed.

Example

use jupiter::builder::Builder;
use tokio::time::Duration;
use jupiter::config::Config;
use jupiter::server::Server;

#[tokio::main]
async fn main() {
    //  Setup and create a platform...
let platform = Builder::new().enable_all().build().await;

    // Specify a minimal config so that we run on a different port than a
    // production instance.
    platform.require::<Config>().load_from_string("
        server:
            port: 1503
    ", None);

    // Run the platform...
    platform.require::<Server>().event_loop().await;
}

Structs

  • Represents a client connection.
  • Provides some metadata for a client connection.
  • Represents a server which manages all TCP connections.