Skip to content

cnsa/redix_pubsub_fastlane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

56 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Redix.PubSub.Fastlane

Fastlane pattern based on Redix.PubSub interface for Elixir

Build Status Coverage Status Hex.pm Deps Status

See the docs for more information.

TL;DR Example Phoenix app

About

Works as a simple wrapper over Redix.PubSub.

Main goal is providing a fastlane path for published events.

Imagine: You have a Main task, that depends on few subtasks, each with its own UUID & await for published event, but also wants the Main task ID within every event.

Ie:

Redix.PubSub.Fastlane.subscribe(MyApp.PubSub.Redis, "channel1", {pid, My.Fastlane, ["some_id"]})

Installation

redix_pubsub_fastlane can be installed as:

  1. Add redix_pubsub_fastlane to your list of dependencies in mix.exs:
def deps do
  [{:redix_pubsub_fastlane, "~> 0.3.1"}]
end
  1. Ensure redix_pubsub_fastlane is started before your application:
def application do
  [applications: [:redix_pubsub_fastlane]]
end
  1. Also you can simply add it to your Mix.config:
config :redix_pubsub_fastlane, MyApp.PubSub.Redis,
  fastlane: My.Fastlane,
  host: "192.168.1.100"

Usage

Simply add it to your Supervisor stack:

supervisor(Redix.PubSub.Fastlane, [MyApp.PubSub.Redis, [host: "localhost",
                                                        port: 6397,
                                                        pool_size: 5]])

Or run it by hands:

{:ok, pubsub_server} = Redix.PubSub.Fastlane.start_link(MyApp.PubSub.Redis)

Config Options

Option Description Default
:name The required name to register the PubSub processes, ie: MyApp.PubSub
:fastlane The name of base fastlane module, ie: My.Fastlane none
:decoder The decoder method for payloads, ie: &Poison.decode!/1 none
:database The redis-server database ""
:host The redis-server host IP "127.0.0.1"
:port The redis-server port 6379
:password The redis-server password ""

Inspired by:

License

MIT