Packages

A few sentences (a paragraph) describing the project.

Current section

Files

Jump to
vtexws lib vtex_ws_web controllers notification_controller.ex
Raw

lib/vtex_ws_web/controllers/notification_controller.ex

defmodule VtexWsWeb.NotificationController do
@moduledoc "Controller responsável por receber os webhooks da Vtex e enfileirá-los no Worker."
use VtexWsWeb, :controller
alias VtexWs.Workers.NotificationWorker
@doc "Action que enfileira os jobs. Utiliza o método Genretry para, em caso de erro, tentar enfileirar novamente."
def notification(
conn,
%{
"IdSku" => product_sku,
"app_slug" => app_slug
}
) do
fn ->
{:ok, _jid} = Exq.enqueue(
Exq,
NotificationWorker.queue,
NotificationWorker,
[app_slug, product_sku, nil, nil, 0]
)
end
|> GenRetry.retry(retries: 5, delay: 10_000, jitter: 0.1)
send_resp(conn, 200, "")
end
end