ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

Export declared event types in gun_event #249

Closed keynslug closed 3 years ago

keynslug commented 3 years ago

This should help library users in keeping event handler specs concise and correct.

One may consider these types a part of the public API once they're exported though, maybe that's the reason they weren't?

essen commented 3 years ago

As a rule if it's not documented then it's not public. The real reason is that it's a new feature in upcoming 2.0 and it hasn't been documented. The intent is that those types get reviewed and documented.

I would love to hear what you (or others) are doing with event handlers.

I will look into merging this tomorrow.

keynslug commented 3 years ago

Ah, ok, great to hear!

I would love to hear what you (or others) are doing with event handlers.

Well not much for the time being to be honest, besides occasional logging in tests. Worth mentioning that we have a strong requirement to have every public function typespec'ed in our projects, including gun event handlers, that's why I decided to open a PR for discussion. Later I'm planning to extract some additional log event metadata like, for example, domain lookup and request timings.

essen commented 3 years ago

Merged, thanks!

Note that the event data may be subject to change before we reach 2.0, particularly as I will go through them in the context of HTTP/2 tunnels.