Skip to content

Commit

Permalink
use otp unix domain sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
rozap committed Aug 7, 2017
1 parent 6e91b57 commit 12c0e97
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
%% -*- erlang -*-
{deps,
[
{exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core.git", "09c2a93"}},
{afunix, ".*", {git, "git://github.com/tonyrog/afunix.git", "180eed9"}}
{exometer_core, ".*", {git, "git://github.com/Feuerlabs/exometer_core.git", "09c2a93"}}
]}.

{erl_opts,
Expand Down
2 changes: 1 addition & 1 deletion src/exometer_collectd.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{vsn, git},
{registered, []},
{applications, [kernel, stdlib,
lager, afunix, exometer_core]},
lager, exometer_core]},
{included_applications, []},
{env, []}
]}.
10 changes: 5 additions & 5 deletions src/exometer_report_collectd.erl
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ report_exometer_(Metric, DataPoint, Extra, Value,
type_map = TypeMap} = St) ->
case get_type(TypeMap, Extra, ets_key(Metric, DataPoint)) of
error ->
?log(warning,
?log(warning,
"Could not resolve ~p to a collectd type."
"Update exometer_report_collectd -> type_map in app.config. "
"Value lost~n", [ets_key(Metric, DataPoint)]),
Expand All @@ -262,9 +262,9 @@ report_exometer_(Metric, DataPoint, Extra, Value,

send_request(Sock, Request, Metric, DataPoint, Extra, Value,
#st{read_timeout = TOut} = St) ->
try afunix:send(Sock, Request) of
try gen_tcp:send(Sock, Request) of
ok ->
case afunix:recv(Sock, 0, TOut) of
case gen_tcp:recv(Sock, 0, TOut) of
{ok, Bin} ->
%% Parse the reply
case parse_reply(Request, Bin, St) of
Expand Down Expand Up @@ -351,7 +351,7 @@ connect_collectd(St) ->
end.

connect_collectd(SocketPath, ConnectTimeout) ->
afunix:connect(SocketPath, [{active, false}, {mode, binary}], ConnectTimeout).
gen_tcp:connect(SocketPath, [{active, false}, {mode, binary}], ConnectTimeout).

unix_time() ->
datetime_to_unix_time(erlang:universaltime()).
Expand Down Expand Up @@ -422,7 +422,7 @@ get_type(TypeMap, Extra, Name) ->

maybe_reconnect_after(Socket) ->
%% Close socket if open
if Socket =/= undefined -> afunix:close(Socket);
if Socket =/= undefined -> gen_tcp:close(Socket);
true -> true
end,
prepare_reconnect().
Expand Down

0 comments on commit 12c0e97

Please sign in to comment.