nerves-hub / nerves_hub

NervesHub client for devices
70 stars 14 forks source link

Make NervesHub.Connection safe #114

Closed jjcarstens closed 4 years ago

jjcarstens commented 4 years ago

Fixes https://github.com/nerves-hub/nerves_hub/issues/113

NervesHub.Connection is called when making HTTP requests to mark successful connections. However, it is started with the NervesHub.Supervisor which isn't typically present for HTTP use-cases of this lib, so things crash and fail.

This adds a note to the doc about how to use NervesHub.Connection if using HTTP only. Also makes the function calls safer by returning an {:error, :no_agent} tuple if the agent with connection state cannot be found.