mix slap.server (slap v0.3.0)

Copy Markdown View Source

Starts a standalone HTTP server (Slap.Server) for Durable Streams, KV, or both. Select at least one service. Applications can embed either service directly in their supervision tree and Plug pipeline.

mix slap.server [--help] [--port 4437] [--ip 127.0.0.1]
              --store memory|local:DIR|s3:URL
              [--streams] [--kv]
              [--streams-shards 8] [--streams-flush-interval 10ms]
              [--streams-idle-timeout MS]
              [--streams-max-fork-copy-bytes BYTES]
              [--streams-fork-copy-grace MS]
              [--streams-expiry-interval MS]
              [--streams-repair-interval MS]
              [--streams-deleter-interval MS]
              [--streams-deleter-page N]
              [--streams-load-interval MS]
              [--streams-max-inflight-bytes-per-stream BYTES]
              [--streams-max-inflight-bytes-per-shard BYTES]
              [--long-poll-timeout 30000] [--sse-timeout 60000]
              [--pid-file FILE]
              [--placement local|object-lease|distributed|static]
              [--lease-ttl MS] [--static-nodes name@host,...]
              [--peers name@host,...]
              [--kv-shards 8] [--kv-flush-interval 10ms]
              [--kv-partition-writers N]

For s3:URL, the endpoint and credentials come from the AWS_* environment variables. --store is required; a memory store is lost when the server stops. Streams are served under /v1/stream/ and KV under /v1/kv/; GET /health answers 200 once the listener is up. Each service has its own shards and databases. --pid-file writes the VM's OS process id, for tests that kill it. There is no authentication. The listener binds to loopback unless --ip selects another address.

Use iex -S mix slap.server ... to keep an interactive prompt while the listener runs.

Without a Mix project, use Mix.install:

elixir -e 'Mix.install([:slap]); Mix.Task.run("slap.server", System.argv())' -- \
  --streams --store memory

With a placement other than local, the node is one of a cluster: start it with a name and a shared cookie, for example elixir --name a@127.0.0.1 --cookie slap -S mix slap.server --streams --store s3:s3://bucket/streams --placement distributed --peers b@127.0.0.1,c@127.0.0.1. object-lease needs an S3 store; --peers requires a placement other than local.