riptide v0.4.4 Riptide.Store.Postgres View Source

This store persists data to a single Postgres table as materialized paths. It is best used in scenarios where your application will have multiple erlang nodes running that all need shared access to data. Note with this store Postgres is treated like a dumb key/value store and does not take advantage of any other Postgres capabilities.

Configuration

Add postgrex as a dependency to your mix.exs.

defp deps do
  [
    {:riptide, "~> 0.4.0"},
    {:postgrex,  "~> 0.15.3"}
  ]
end

And then you can configure the store:

config :riptide,
  store: %{
    read: {Riptide.Store.Postgres, []},
    write: {Riptide.Store.Postgres, []},
  }

You can start up a named Postgrex pool manually but this module provides a convenient way for you to do that. Add this to your application.ex:

children = [
  {Riptide.Store.Postgres, [
    hostname: "localhost",
    database: "riptide",
    username: "postgres",
    password: "postgres",
  ]},
  Riptide,
]
opts = [strategy: :one_for_one, name: Riptide.Supervisor]
Supervisor.start_link(children, opts)

Note, make sure the Postgres pool starts up before Riptide.

Options

  • :table - name of table defaults to riptide (optional)
  • :name - name of Postgrex pool, defaults to postgres (optional)
  • :transaction_timeout - duration for transaction timeout in milliseconds, defaults to 1 minute (optional)

Link to this section Summary

Functions

Convenience implementation of Supervisor.child_spec/1 to start up a Postgrex pool with name :postgres

Link to this section Functions

Convenience implementation of Supervisor.child_spec/1 to start up a Postgrex pool with name :postgres

Examples

children = [
  {Riptide.Store.Postgres, [
    hostname: "localhost",
    database: "riptide",
    username: "postgres",
    password: "postgres",
  ]},
  Riptide,
]
opts = [strategy: :one_for_one, name: Riptide.Supervisor]
Supervisor.start_link(children, opts)