Some checks are pending
Build and Publish / build-release (push) Waiting to run
22 lines
501 B
Elixir
22 lines
501 B
Elixir
defmodule PolicyService.MessageBus do
|
|
use AMQP
|
|
|
|
def publish(routing_key, event) do
|
|
payload = Jason.encode!(event)
|
|
|
|
:ok =
|
|
AMQP.Basic.publish(channel(), "policy_service.events", routing_key, payload,
|
|
content_type: "application/json",
|
|
persistent: true
|
|
)
|
|
end
|
|
|
|
defp channel do
|
|
{:ok, conn} = AMQP.Connection.open(amqp_url())
|
|
{:ok, chan} = AMQP.Channel.open(conn)
|
|
chan
|
|
end
|
|
|
|
defp amqp_url, do: Application.fetch_env!(:policy_service, :amqp_url)
|
|
end
|