Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 645 Bytes

README.md

File metadata and controls

35 lines (23 loc) · 645 Bytes

Sequence

Start it with iex -S mix

{:ok, pid} = :gen_server.start_link(Sequence.Server, 100, [])
:gen_server.call(pid, :next_number)
:gen_server.call(pid, :next_number)

:gen_server.call(pid, {:set_number, 1000})

:gen_server.cast(pid, {:increment_number, 500})

:sys.get_status pid

Naming a server

{:ok, pid} = :gen_server.start_link({:local, :seq}, Sequence.Server, 100, [])

:gen_server.call(:seq, :next_number)
sys.get_status(:seq)

Using server with external API

Sequence.Server.start_link(13)

Sequence.Server.next_number
Sequence.Server.increment_number(100)
Sequence.Server.next_number