Skip to content

darkofabijan/otp-server-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

OTP server example in Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages