Slap.Server (slap v0.4.0)

Copy Markdown View Source

A standalone HTTP server for Durable Streams, KV, or both. Pass :streams and/or :kv to select the services. At least one is required.

Add {Slap.Server, opts} to an application's supervision tree, or run the mix slap.server task under Mix. The slap application starts no listener on boot. The supported setup has one Streams cluster and one KV cluster per VM.

  • :store - required, as for Slap.SlateDB.open/2: :memory, {:local, dir} or {:url, "s3://bucket/prefix", options}. For S3, the endpoint and credentials can also come from AWS_* variables. The streams' shards are under streams/ in it, KV's under kv/.
  • :streams - [shards: n, settings: settings, child_options: service_options, http: router_options]. The shard count defaults to 8 and is fixed for the life of the data. See Slap.Streams.Cluster for service options.
  • :kv - the same keys (default 8 shards). See Slap.KV.Cluster for its child_options:. Settings merge with each cluster's defaults, which set flush_interval to 10 ms.
  • :port (default 4437), :ip (default :loopback) - the listener.
  • :strategy - run as one node of a cluster: {module, opts}, a Slap.Cluster.Strategy, for both clusters. The nodes must be connected with distributed Erlang; requests for a shard on another node are served there (:erpc). Without it every shard is on this node (Local).
  • :peers - node names to stay connected to (Slap.Cluster.Peers).

The listener does not authenticate (see the routers).

Summary

Functions

A single supervisor child for the configured server.

Starts a supervisor for the configured clusters and listener.

Functions

child_spec(config)

@spec child_spec(keyword()) :: Supervisor.child_spec()

A single supervisor child for the configured server.

start_link(config)

@spec start_link(keyword()) :: Supervisor.on_start()

Starts a supervisor for the configured clusters and listener.