Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invoke lambda function in pixel handler for #35 #36

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/app_web/controllers/sent_controller.ex
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,15 @@ defmodule AppWeb.SentController do
end

def pixel(conn, _params) do
# warm up the lambda function so emails are sent instantly!
payload = %{"ping" => :os.system_time(:millisecond), key: "ping"}
# IO.inspect(payload, label: "payload ping/2:151")
# see: https://github.com/dwyl/elixir-invoke-lambda-example
lambda = System.get_env("AWS_LAMBDA_FUNCTION")
ExAws.Lambda.invoke(lambda, payload, "no_context")
|> ExAws.request(region: System.get_env("AWS_REGION"))
|> IO.inspect(label: "ExAws.Lambda ping response")
Copy link
Member

@SimonLab SimonLab May 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if you want to keep this IO.inspect uncommented

Suggested change
|> IO.inspect(label: "ExAws.Lambda ping response")
# |> IO.inspect(label: "ExAws.Lambda ping response")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I'm happy to leave these kinds of logs in this App.
When we are paying for the storage of logs, we will have to be strict about them
and will probably have a pre-commit hook/check to not allow uncommented IO.inspect. 👍


conn # instruct browser not to cache the image
|> put_resp_header("cache-control", "no-store, private")
|> put_resp_header("pragma", "no-cache")
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule App.MixProject do
def project do
[
app: :app,
version: "1.0.0",
version: "1.0.1",
elixir: "~> 1.10",
elixirc_paths: elixirc_paths(Mix.env()),
compilers: [:phoenix, :gettext] ++ Mix.compilers(),
Expand Down