I’m trying to use buoy but there are some weird things I’m encountering. I feel like looking at the source code may answer it, but I don’t know erlang so it’s quite confusing.
Here’s my code:
url = "https://httpbin.org/get"
buoy_url = url |> :buoy_utils.parse_url
pool = :buoy_pool.start(buoy_url, [backlog_size: 1024, pool_size: 16])
IO.inspect pool
:buoy.get(buoy_url)
This appears to work
Question 1: But, I want to set the timeout, as well as some headers. According to the docs it says I do this:
:buoy.get(buoy_url, %{timeout: 500})
but when I do this, it “hangs”… almost like its frozen. Did I format the erlang map wrong? I googled and it seems right?
Question 2: the version on hex is a little outdated. When I try doing this:
{:buoy, "~> 0.1", git: "https://github.com/lpgauth/buoy.git"},
it says:
Dependencies have diverged:
* metal (https://github.com/lpgauth/metal.git)
different specs were given for the metal app:
> In deps/shackle/rebar.config:
{:metal, ~r/.*/, [env: :prod, override: true, git: "https://github.com/lpgauth/metal.git", tag: "0.1.1", manager: :rebar3]}
> In deps/foil/rebar.config:
{:metal, "0.1.1", [env: :prod, repo: "hexpm", hex: "metal", override: true, manager: :rebar3]}
Ensure they match or specify one of the above in your deps and set "override: true"
** (Mix) Can't continue due to errors on dependencies
Question 3: One thing I find weird is that you have to start the pool based on URL… in my use case I don’t know the URL beforehand. Do you think its crazy to attempt to start a new pool for every URL, and just let it fail with {:error, :pool_already_started}
if it’s already started? I’m not quite sure the overhead of starting a new pool…