Building the Name Server
A name server is a program that, given a name, returns a value associated with that name. We can also change the value associated with a particular name.
Our first name server is extremely simple. It is not fault tolerant, so all the data it stores will be lost if it crashes. The point of this exercise is not to make a fault-tolerant name server but to get started with distributed programming techniques.
Stage 1: A Simple Name Server
Our name server kvs
is a simple Key
→ Value
, server. It has the following
interface:
-spec kvs:start() -> true
-
Start the server; this creates a server with the registered name
kvs
. -spec kvs:store(Key, Value) -> true
-
Associate
Key
withValue
. -spec kvs:lookup(Key) -> {ok, Value} | undefined ...
Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.