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 & in they await for published event, but also must know 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_fastlane
to your list of dependencies inmix.exs
:def deps do [{:redix_pubsub_fastlane, "~> 0.1.0"}, {:redix_pubsub, "~> 0.1.0", github: "whatyouhide/redix_pubsub"}] end
-
Ensure
redix_pubsub_fastlane
is 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:
License
Copyright (c) 2016 NSA Ltd. and other contributors
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.