Redix.PubSub.Fastlane
Fastlane pattern based on Redix.PubSub interface for Elixir
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:
-
Add
redix_pubsub_fastlaneto your list of dependencies inmix.exs:
def deps do
[{:redix_pubsub_fastlane, "~> 0.3.1"}]
end-
Ensure
redix_pubsub_fastlaneis started before your application:
def application do
[applications: [:redix_pubsub_fastlane]]
end- 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: