FakeRiak.CLI (fake_riak v0.2.1)

Copy Markdown View Source

Command-line entry point for the mix escript.build executable.

Parses the endpoint flags (--riak, --etcd, --redis, --memcached), configures the matching FakeRiak.Listeners and starts the application. At least one endpoint must be enabled, otherwise it prints an error and exits. A flag may be repeated to start the same API on multiple ports, e.g. --riak 8098 --riak 8099; its value may also be a comma-separated list and/or a first..last range, e.g. --riak 10012,10013,10014 or --riak 6700..6705 (see parse_ports/1). Every --riak port serves both the Riak HTTP and Protocol Buffers (PBC) APIs, so a single port is enough; a bare --riak (no port given) still opens both of Riak's conventional ports, 8098 and 8087, since real clients expect to find each API on its usual port.

Every endpoint silently accepts both plain TCP and TLS on the same port (see FakeRiak.TLS), using an ephemeral self-signed certificate unless --tls-cert/--tls-key point at a real one — which is validated up front (readable and usable in an actual handshake) so a bad pair is a startup error instead of a mysterious closed connection on every client's first attempt. An expired certificate only prints a warning, since the handshake itself still works with it.

--debug traces every byte received/sent, how each protocol handler parsed it, and full TLS handshake detail — the tool of first resort for "why did the client's handshake/request just fail with no other information".