aboutsummaryrefslogtreecommitdiffstats
path: root/src/gun.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2019-04-26 14:57:34 +0200
committerLoïc Hoguin <[email protected]>2019-04-26 14:57:34 +0200
commiteb74e3d30ca9fa47268d3a235f928341fb807423 (patch)
tree6972ea3495306166467b239c840b5eedb322809c /src/gun.erl
parenta943324efff332c76a9738561b42c086fd910552 (diff)
downloadgun-eb74e3d30ca9fa47268d3a235f928341fb807423.tar.gz
gun-eb74e3d30ca9fa47268d3a235f928341fb807423.tar.bz2
gun-eb74e3d30ca9fa47268d3a235f928341fb807423.zip
Add the supervise option to start without supervisor
Diffstat (limited to 'src/gun.erl')
-rw-r--r--src/gun.erl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/gun.erl b/src/gun.erl
index d8aa15b..c2054e0 100644
--- a/src/gun.erl
+++ b/src/gun.erl
@@ -111,6 +111,7 @@
protocols => [http | http2],
retry => non_neg_integer(),
retry_timeout => pos_integer(),
+ supervise => boolean(),
trace => boolean(),
transport => tcp | tls | ssl,
transport_opts => [gen_tcp:connect_option()] | [ssl:connect_option()],
@@ -211,7 +212,11 @@ do_open(Host, Port, Opts0) ->
end,
case check_options(maps:to_list(Opts)) of
ok ->
- case supervisor:start_child(gun_sup, [self(), Host, Port, Opts]) of
+ Result = case maps:get(supervise, Opts, true) of
+ true -> supervisor:start_child(gun_sup, [self(), Host, Port, Opts]);
+ false -> start_link(self(), Host, Port, Opts)
+ end,
+ case Result of
OK = {ok, ServerPid} ->
consider_tracing(ServerPid, Opts),
OK;
@@ -260,6 +265,8 @@ check_options([{retry, R}|Opts]) when is_integer(R), R >= 0 ->
check_options(Opts);
check_options([{retry_timeout, T}|Opts]) when is_integer(T), T >= 0 ->
check_options(Opts);
+check_options([{supervise, B}|Opts]) when B =:= true; B =:= false ->
+ check_options(Opts);
check_options([{trace, B}|Opts]) when B =:= true; B =:= false ->
check_options(Opts);
check_options([{transport, T}|Opts]) when T =:= tcp; T =:= tls ->