-module(test_server).
-behaviour(gen_server).

%% External exports
-export([start/0, ping/0, ping/1]).

%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2,
         handle_info/2, terminate/2, code_change/3]).

%% API

start() ->
    gen_server:start({local, ?MODULE}, ?MODULE, [], []).

ping() ->
    ping(node()).

ping(Node) ->
    gen_server:call({?MODULE, Node}, ping, 10000).

%---------------------------------------------------------------------
% Callback functions
%---------------------------------------------------------------------

init([]) ->
    {ok, none}.

handle_call(ping, _From, State) ->
    {reply, ok, State}.

handle_cast(Msg, State) ->
    {stop, {unknown_cast, Msg}, State}.

handle_info(_Info, State) ->
    {noreply, State}.

code_change(_OldVsn, State, _Extra) ->
    {ok, State}.

terminate(_Reason, _State) ->
    ok.

