defmodule Server do
    @moduledoc """
    A GenServer template for a "singleton" process.
    """
    use GenServer
    require Logger 

    def start_link(opts \\ []) do
        Logger.debug "Started with opts: #{inspect opts}"
        GenServer.start_link(__MODULE__, opts, [name: __MODULE__])
    end
  
    def init(opts) do
        Logger.debug "Init with opts: #{inspect opts}"
        {:ok, opts}
    end
  
    #######
    # API #
    #######

    def send_something(m) do
        GenServer.cast(__MODULE__, m)
    end
    
    #############
    # Callbacks #
    #############

    def handle_call(m, from, state) do
        Logger.debug "Call #{inspect m} from #{inspect from} with state #{inspect state}"
        {:reply, :response, state}
    end
  
    def handle_cast(m, state) do
        Logger.debug "Cast #{inspect m} with state #{inspect state}"
         {:noreply, state}
    end
  
    def handle_info(m, state) do
        Logger.debug "Info #{inspect m} with state #{inspect state}"
        {:noreply, state}
    end
  
    ###########
    # Helpers #
    ###########
  
    defp private(x) do
        x
    end
  
  end