From c40c851aac69d11a6ac984769c00def00e7031df Mon Sep 17 00:00:00 2001 From: Yury Gargay Date: Wed, 16 Nov 2016 11:58:22 +0100 Subject: [PATCH] Support new hackney In the new `hackney` were made the following changes: * `hackney_tcp_transport` was changed to `hackney_tcp`. * `hackney_ssl_transport` was changed to `hackney_ssl`. This commit brings the new changes with backward compatibility. --- src/exometer_report_influxdb.erl | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/exometer_report_influxdb.erl b/src/exometer_report_influxdb.erl index 17ce765..dc33f46 100644 --- a/src/exometer_report_influxdb.erl +++ b/src/exometer_report_influxdb.erl @@ -224,8 +224,18 @@ connect(Proto, Host, Port, Username, Password) when ?HTTP(Proto) -> _ -> [{basic_auth, {Username, Password}}] end ++ [{pool, false}], Transport = case Proto of - http -> hackney_tcp_transport; - https -> hackney_ssl_transport + http -> + code:load_file(hackney_tcp), + case code:is_loaded(hackney_tcp) of + true -> hackney_tcp; + _ -> hackney_tcp_transport + end; + https -> + code:load_file(hackney_ssl), + case code:is_loaded(hackney_ssl) of + true -> hackney_ssl; + _ -> hackney_ssl_transport + end end, hackney:connect(Transport, Host, Port, Options); connect(udp, _, _, _, _) -> gen_udp:open(0);