Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Erlang app example

An OTP application split into three packages. It builds and tests on the pinned Erlang/OTP runtime with nothing installed on the host.

PackageRole
protokv_proto library: a leex lexer and a yecc parser for put, get and del commands
storekv_store application: a supervised gen_server with a key limit, watchers and a JSON snapshot through thoas
clikvctl escript that runs commands against the store
bazel build //examples/erlang-app/...
bazel test //examples/erlang-app/...
bazel run //examples/erlang-app/cli:kvctl -- "put apples 3" "get apples"

The run prints ok, 3 and the snapshot {"apples":3}. A command that does not parse prints error: ... and exits 1.

proto:eunit runs the parser tests. store:kv_store_SUITE is a Common Test suite for the limit from app_env, watcher events, supervisor restarts and the snapshot. cli:kvctl_SUITE runs the commands in process and through the kvctl launcher.

thoas is a pinned http_archive declared in MODULE.bazel.