OeditusCredo.Check.Warning.BlockingInPlug
(OeditusCredo v0.5.0)
View Source
Basics
This check is disabled by default.
Learn how to enable it via .credo.exs.
This check has a base priority of normal and works with any version of Elixir.
Explanation
Expensive blocking operations in Plug functions slow down request processing.
Move expensive operations to background jobs or async tasks.
Bad:
plug :load_user_data
def load_user_data(conn, _opts) do
user = Repo.get!(User, conn.assigns.user_id)
assign(conn, :user, user)
endGood:
# Load user data in the controller action instead
def show(conn, params) do
user = Repo.get!(User, params["id"])
render(conn, "show.html", user: user)
endCheck-Specific Parameters
Use the following parameters to configure this check:
:exclude_test_files
Set to true to skip test files (default: false)
This parameter defaults to nil.
:extra_blocking_modules
Additional module atoms to treat as blocking (default: [])
This parameter defaults to nil.
General Parameters
Like with all checks, general params can be applied.
Parameters can be configured via the .credo.exs config file.