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.
- Deflate
Config - A permessage-deflate configuration.
- Introspection
Config - Configuration for the introspection meta agents.
- Registration
Failed - Errors that can occur waiting for tha server to stop.
- Remote
Connections Config - Configuration for remote socket management.
- Server
Builder - Builder for a swimos server that will listen on a socket and run a suite of agents.
- Server
Handle - 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.
- Swim
Server Config - Configuration parameters for a Swim server.
- Window
Bits - Client or server maximum window bits. Wrapping a
u8with a value in the range of 8..=15.
Enums§
- Ambiguous
Routes - Indicates that the routes specified for plane are ambiguous (overlap with each other).
- Server
Builder Error - Error type that is returned if a server cannot be started.
- Server
Error - Error type returned from the server task if it encounters a non-recoverable error.
- Unresolvable
Route
Traits§
- Agent
Ext - 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.