# PingServer

A GenServer which repeatedly pings itself on an interval.
Additionally, it can be pinged manually to accelerate the ping.

defmodule UsePing do
  use PingServer, interval: 10_000

  def start_link(thing) do
    # You can start link this way.  It will call PingServer.init(thing)
    PingServer.start_link(__MODULE__, thing, [])

  def handle_ping(state) do
    # Even though the interval is 10 seconds, we can make it be every 1 second this way
    PingServer.ping_after(self(), 1_000)

  def handle_info(:manual_ping, state) do
    # only one ping will happen but it will happen pretty much right away.
    {:noreply, state}

## Installation

If [available in Hex](, the package can be installed
by adding `ex_ping_server` to your list of dependencies in `mix.exs`:

def deps do
    {:ex_ping_server, "~> 0.1.0"}

Documentation can be generated with [ExDoc](
and published on [HexDocs]( Once published, the docs can
be found at [](