Created
February 9, 2021 22:37
-
-
Save sorentwo/70948c432f4a4489b5dbf8ec0e5f97fb to your computer and use it in GitHub Desktop.
Oban Pro Relay Plugin Mini-Demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alias Oban.Pro.Plugins.Relay | |
Oban.Pro.Repo.start_link() | |
Oban.start_link( | |
repo: Oban.Pro.Repo, | |
queues: [alpha: 2], | |
plugins: [Oban.Pro.Plugins.Relay] | |
) | |
defmodule Worker do | |
use Oban.Worker, queue: :alpha | |
@impl Worker | |
def perform(%{args: %{"msg" => msg}}) do | |
{:ok, "#{msg} from #{node()}"} | |
end | |
end | |
~w(foo bar baz) | |
|> Enum.map(&Worker.new(%{msg: &1})) | |
|> Enum.map(&Relay.async/1) | |
|> Relay.await_many() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment