Crate swimos_server_app

Crate swimos_server_app 

Source
Expand description

§SwimOS Server Application

This module contains the main runtime loop for the SwimOS server. A SwimOS server contains a web server that can accept incoming websocket connections, using the Warp protocol, to communicate with agents that run within the server. It will additionally accept plain HTTP connections that are targetted at HTTP lanes exposed by the agents.

A server instance is created by using the ServerBuilder to configure how the server should behave. By default, a server will not host any agent routes and these must be registered by calling ServerBuilder::add_route. This crate is not sufficient, in itself, to produce a complete SwimOS application as it does not supply any implementation of the agent interface.

A Rust implementation of agents is provided by the swimos_agent crate.

§Examples

use std::error::Error;
use swimos_server_app::{Server, ServerBuilder};

let server = ServerBuilder::with_plane_name("Example Server")
    .set_bind_addr("127.0.0.1:8080".parse()?)
    .enable_introspection()
    .with_in_memory_store()
    // Register agent routes.
    .build()
    .await?;

let (task, mut handle) = server.run();
let stop = async move {
    ctrl_c.await; // Provide a signal to cause the server to stop. E.g. Ctrl-C.
    handle.stop();
};
tokio::join!(stop, task).1?;

Structs§

BoxServer
A boxed server implementation.
DeflateConfig
A permessage-deflate configuration.
IntrospectionConfig
Configuration for the introspection meta agents.
RegistrationFailed
Errors that can occur waiting for tha server to stop.
RemoteConnectionsConfig
Configuration for remote socket management.
ServerBuilder
Builder for a swimos server that will listen on a socket and run a suite of agents.
ServerHandle
A handle used to interact with a running Swim server instance. This can be used to find the interface on which the server is listening, instruct the server to stop and explicitly start agents.
SwimServerConfig
Configuration parameters for a Swim server.
WindowBits
Client or server maximum window bits. Wrapping a u8 with a value in the range of 8..=15.

Enums§

AmbiguousRoutes
Indicates that the routes specified for plane are ambiguous (overlap with each other).
ServerBuilderError
Error type that is returned if a server cannot be started.
ServerError
Error type returned from the server task if it encounters a non-recoverable error.
UnresolvableRoute

Traits§

AgentExt
Adds additional methods for manipulating Agents.
Server
Interface for Swim server implementations.

Functions§

until_termination
Register a Ctrl-C handler that will stop a server instance.