Skip to content

libcluster clustering strategy using PostgreSQL LISTEN/NOTIFY and Postgrex.Notifications

License

Notifications You must be signed in to change notification settings

sloanelybutsurely/libcluster_postgrex_notifications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libcluster_postgrex_notifications

Module Version Hex Docs

A clustering strategy for libcluster using PostgreSQL LISTEN/NOTIFY and Postgrex.Notifications.

Motivations

Many Elixir applications already depend on a single PostgreSQL database. That same database is used to communicate between nodes and form a cluster without any additional infrastructure.

Installation

This package can be installed from hex by adding libcluster_postgrex_notifications to your list of dependencies in mix.exs:

def deps do
  [
    {:libcluster_postgrex_notifications, "~> MAJ.MIN"}
  ]
end

You can determine the latest version by running mix hex.info libcluster_postgrex_notifications in your shell, or by going to the libcluster_postgrex_notifications page on Hex.pm.

Usage

Add the strategy and config to your topologies.

config :libcluster,
  topologies: [
    postgrex_notifications_example: [
      strategy: Cluster.Strategy.PostgrexNotifications,
      config: [
        postgrex: MyApp.Postgrex,
        notifications: MyApp.Notifications,
        channel: "libcluster_postgrex_notifications"
      ]
    ]
  ]

Make sure postgrex and notifications correspond to pids or process names of Postgrex and Postgrex.Notifications.

# Starting these under a Supervisor is a better idea
{:ok, _} = Postgrex.start_link(opts, name: MyApp.Postgrex)
{:ok, _} = Postgrex.Notifications.start_link(opts, name: MyApp.Notifications)

About

libcluster clustering strategy using PostgreSQL LISTEN/NOTIFY and Postgrex.Notifications

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Languages