Skip to content

Commit

Permalink
Documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
v0idpwn committed Jul 1, 2024
1 parent 7bfe5fb commit 09ae2de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 2 additions & 0 deletions lib/db_connection.ex
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,8 @@ defmodule DBConnection do
* `:opts` - All options given to the pool operation
See `DBConnection.TelemetryListener` for enabling `[:db_connection, :connected]`
and `[:db_connection, :disconnected]` events.
"""
@spec start_link(module, [start_option()] | Keyword.t()) :: GenServer.on_start()
def start_link(conn_mod, opts) do
Expand Down
18 changes: 13 additions & 5 deletions lib/db_connection/telemetry_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@ defmodule DBConnection.TelemetryListener do
## Usage
Start the listener, optionally using a name, and pass it under the
`:connection_listeners` option when starting DbConnection:
Start the listener, and pass it under the `:connection_listeners` option when
starting DBConnection:
{:ok, pid} = TelemetryListener.start_link()
{:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: [pid])
{:ok, pid} = TelemetryListener.start_link([name: MyListener])
{:ok, _conn} = DBConnection.start_link(SomeModule, [connection_listeners: [MyListener]])
# Using a tag, which will be sent in telemetry metadata
{:ok, _conn} = DBConnection.start_link(SomeModule, [connection_listeners: {[pid], :my_tag}])
{:ok, _conn} = DBConnection.start_link(SomeModule, connection_listeners: {[pid], :my_tag})
# Or, with a Supervisor:
Supervisor.start_link([
{TelemetryListener, [name: MyListener]},
DBConnection.child_spec(SomeModule, connection_listeners: {[MyListener], :my_tag})
])
## Telemetry events
Expand Down

0 comments on commit 09ae2de

Please sign in to comment.