Time for burning our hands on

Elixir Mastering — Live Example of GenServer and GenServer Testing

Hard coding concepts are easy after knowing

Malreddy Ankanna
blackode
Published in
10 min readFeb 14, 2017

--

In this article, I will try my best to make you to understand each line of code which will help you to understand the GenServer in return.

The GenServer is really a night mare for the beginner but, if you learn how to ride with it , you will become KNIGHT in Elixir Programming.

What we do Here?

We are going to implement the following actions using the GenServer in Elixir.

NOTE:

Here, we assume only single user for our convenience.

  1. User start the server and receives the pid of the server by initiating server state with some random password.
  2. An unlock function to unlock the given password.
    If the password given is same as the one given at the time of the execution, the server has to return :ok else it will written {:error, "wrongpassword"}
  3. A reset function to reset the given password. If the old_password is correct , return :ok else {:error, "wrongpassword"}

These are the major tasks that we are going to implement from the scratch building the mix

--

--

Malreddy Ankanna
blackode

Programmer & Writer, I write about coding, thoughts, ideas, personal musings, technical articles, and tutorials.https://bio.link/blackode