Skip to content

Commit

Permalink
Include event handler state in gun:info/1 result
Browse files Browse the repository at this point in the history
Adds event_handler and event_handler_state in the map returned by
gun:info/1.

Signed-off-by: Viktor Söderqvist <[email protected]>

Merged PR:
ninenines#336
  • Loading branch information
zuiderkwast authored and bjosv committed May 14, 2024
1 parent 02dccb6 commit 5ee9c20
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
28 changes: 16 additions & 12 deletions doc/src/manual/gun.info.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ info(ConnPid) -> Info
ConnPid :: pid()
Info :: #{
owner => pid(),
socket => inet:socket() | ssl:sslsocket(),
transport => tcp | tls,
protocol => http | http2 | socks | ws,
sock_ip => inet:ip_address(),
sock_port => inet:port_number(),
origin_scheme => binary() | undefined,
origin_host => inet:hostname() | inet:ip_address(),
origin_port => inet:port_number(),
intermediaries => [Intermediary],
cookie_store => gun_cookies:cookie_store(),
state_name => atom()
owner => pid(),
socket => inet:socket() | ssl:sslsocket(),
transport => tcp | tls,
protocol => http | http2 | socks | ws,
sock_ip => inet:ip_address(),
sock_port => inet:port_number(),
origin_scheme => binary() | undefined,
origin_host => inet:hostname() | inet:ip_address(),
origin_port => inet:port_number(),
intermediaries => [Intermediary],
cookie_store => gun_cookies:cookie_store(),
state_name => atom(),
event_handler => module(),
event_handler_state => any()
}
Intermediary :: #{
type => connect | socks5,
Expand All @@ -49,6 +51,8 @@ the connection.

== Changelog

* *TBD*: The values `event_handler` and `event_handler_state` were
added.
* *2.0*: The values `owner`, `origin_scheme` and `cookie_store` were
added.
* *1.3*: The values `socket`, `transport`, `protocol`, `origin_host`,
Expand Down
8 changes: 6 additions & 2 deletions src/gun.erl
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,9 @@ info(ServerPid) ->
origin_host=OriginHost,
origin_port=OriginPort,
intermediaries=Intermediaries,
cookie_store=CookieStore
cookie_store=CookieStore,
event_handler=EventHandler,
event_handler_state=EventHandlerState
}} = sys:get_state(ServerPid),
Info0 = #{
owner => Owner,
Expand All @@ -508,7 +510,9 @@ info(ServerPid) ->
origin_port => OriginPort,
intermediaries => intermediaries_info(Intermediaries, []),
cookie_store => CookieStore,
state_name => CurrentStateName
state_name => CurrentStateName,
event_handler => EventHandler,
event_handler_state => EventHandlerState
},
Info = case Socket of
undefined ->
Expand Down

0 comments on commit 5ee9c20

Please sign in to comment.