strata_server
strata_server — top-level bootstrap.
Starts a supervised beryl channel system with the strata wire codec,
registers the doc:* and admin:status channel handlers, opens the
document store, and serves the WebSocket endpoint via mist
(beryl_mist).
Authentication: clients must include a ?token=<value> query
parameter on the WebSocket upgrade request. The token is compared to
the value of the STRATA_TOKEN environment variable. Connections
without a matching token are rejected with HTTP 403 before any
socket process is spawned.
Origins: strata authenticates with an explicit token rather than
ambient browser credentials, so by default every Origin is
accepted. Set STRATA_ALLOWED_ORIGINS (comma-separated, e.g.
https://app.example.com) to restrict upgrades to an allow-list.
Server
Section titled “Server”A running server and its stable supervised handles.
pub type ServerShutdownError
Section titled “ShutdownError”Shutdown stops new work before attempting a final store close.
pub type ShutdownError { DependentStopFailed(dynamic.Dynamic) StoreCloseFailed(shelf.ShelfError) ShutdownTimedOut}StartError
Section titled “StartError”Server startup failures.
pub type StartError { StorageDirectoryFailed(simplifile.FileError) ChannelsFailed(channel.ChildSpecError) SupervisorFailed(actor.StartError)}StrataConfig
Section titled “StrataConfig”Server bootstrap configuration.
pub type StrataConfig { StrataConfig(token: String, port: Int, websocket_path: String, storage_dir: String, static_dir: option.Option(String), admin_dir: option.Option(String), admin_status_interval_ms: Int, rate_limit_messages_per_second: Int, rate_limit_messages_burst: Int, rate_limit_joins_per_second: Int, rate_limit_joins_burst: Int, max_document_bytes: Int, allowed_origins: List(String))}Constants
Section titled “Constants”default_admin_status_interval_ms
Section titled “default_admin_status_interval_ms”Default interval for admin status broadcasts.
pub const default_admin_status_interval_ms: Intdefault_port
Section titled “default_port”Default HTTP port.
pub const default_port: Intdefault_rate_limit_joins_burst
Section titled “default_rate_limit_joins_burst”Default join burst capacity.
pub const default_rate_limit_joins_burst: Intdefault_rate_limit_joins_per_second
Section titled “default_rate_limit_joins_per_second”Default maximum joins per socket per second.
pub const default_rate_limit_joins_per_second: Intdefault_rate_limit_messages_burst
Section titled “default_rate_limit_messages_burst”Default burst capacity for message rate limit.
pub const default_rate_limit_messages_burst: Intdefault_rate_limit_messages_per_second
Section titled “default_rate_limit_messages_per_second”Default max messages per second.
pub const default_rate_limit_messages_per_second: Intdefault_storage_dir
Section titled “default_storage_dir”Default storage directory for DETS files.
pub const default_storage_dir: Stringdefault_websocket_path
Section titled “default_websocket_path”Default WebSocket path. Override via StrataConfig for non-default
deployments.
pub const default_websocket_path: StringFunctions
Section titled “Functions”channel_config
Section titled “channel_config”Build the wire codec and per-socket rate limits used by the server.
pub fn channel_config(StrataConfig) -> beryl.Configdefault_config
Section titled “default_config”Build a default config; reads STRATA_TOKEN and STRATA_DATA_DIR
from the environment. Falls back to dev-only defaults if either is
unset.
pub fn default_config() -> StrataConfigdocument_store
Section titled “document_store”Access the server's stable store handle for embedded applications.
pub fn document_store(Server) -> store.StoreDefault main for gleam run in dev.
pub fn main() -> Nilparse_origins
Section titled “parse_origins”Split a comma-separated origin list, dropping blanks.
pub fn parse_origins(String) -> List(String)Start the server and wait for its supervision tree to stop.
pub fn run(StrataConfig) -> Nilshutdown
Section titled “shutdown”Stop the listener and dependents, then close the store. On storage failure, service remains stopped and the store stays available for a shutdown retry. This API does not install an operating-system signal handler.
pub fn shutdown(Server) -> Result(Nil, ShutdownError)Start the complete dependency tree. Abnormal store failure restarts the tracker, presence, sockets, admin collector, and listener in that order. The restart limit is two restarts in five seconds.
pub fn start(StrataConfig) -> Result(Server, StartError)