Lantern.Connection (Lantern v0.6.0)

Copy Markdown View Source

Opens one-shot Postgrex connections from a Lantern.Source.

Lantern deliberately avoids a long-lived pool: an embeddable live_component has no reliable teardown hook, so each operation opens a connection, runs, and closes it. The per-call cost is irrelevant for an administrative tool and it leaves nothing for host applications to supervise.

Summary

Functions

Resolves source_input to a Source, opens a connection, and runs fun.

Functions

run(source_input, fun)

@spec run(Lantern.Source.t() | String.t() | keyword() | map(), (pid() -> result)) ::
  result | {:error, String.t()}
when result: term()

Resolves source_input to a Source, opens a connection, and runs fun.

fun receives the Postgrex connection pid and its result is returned as-is. Connection/resolution failures return {:error, reason}.