WardrikStore.Ecto (wardrik_store v0.1.0-rc.1)

Copy Markdown

Keeps keys in a Postgres table.

# Through your app's repo
store = WardrikStore.Ecto.new(repo: MyApp.Repo)
children = [MyApp.Repo, {WardrikStore, store}]

# Through a repo of its own
store = WardrikStore.Ecto.new(url: "postgres://user:pass@db.example.com/wardrik?ssl=true")
children = [{WardrikStore, store}]

Your repo

Create the table from a migration of your own. See WardrikStore.Ecto.Migration.

If the table is missing, the store logs an error as it starts. Your app still boots, so a release can run its migrations.

A repo of its own

The store starts WardrikStore.Ecto.Repo over the URL. It creates the table before it keeps anything, one node at a time.

?ssl=true connects over TLS, verified against the system's certificates. It needs :postgrex in your deps.

Summary

Functions

Builds a store. Starts nothing.

Checks the store's table exists in repo. Logs an error if it doesn't. Returns :ignore.

Functions

new(opts)

@spec new(keyword()) :: WardrikStore.t()

Builds a store. Starts nothing.

Options

Give one of:

  • :repo - your app's repo. Point it at the primary, not a replica.
  • :url - a Postgres URL for a repo of its own.

Raises ArgumentError if given both or neither.

start_link(repo)

@spec start_link(module()) :: :ignore

Checks the store's table exists in repo. Logs an error if it doesn't. Returns :ignore.