Fast
Build faster.
This is a personal grab-bag of utilities that I tend to want, but don’t want to reimplement for every app.
Installation
Add fast to your list of dependencies in mix.exs:
def deps do
[
{:fast, "~> 0.3.0"}
]
endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/fast.
Publishing
To publish a new version:
-
Ensure you’re on the
mainbranch with no uncommitted changes - Run the publish script with the new version number:
bin/publish <major/minor/patch/vX.Y.Z>The script will:
-
Update the version in
mix.exs(removing the ‘v’ prefix) - Create and push a git tag
- Trigger the GitHub Action to publish to Hex.pm
The package will be available at https://hex.pm/packages/fast once published.
Incorporating into a new app
Fast.Application.Ready & Fast.Plug.Ready
GenServer that tracks whether an application is ready for traffic (for use with Fast.Plug.Ready).
-
Add
Fast.Application.Readyas the last child inapplication.ex:
# lib/myapp/application.ex
defmodule MyApp.Application do
use Application
def start(_type, _args) do
children = [
...
- ]
+ ] ++ [{Fast.Application.Ready, otp_app: :my_app}]
opts = [strategy: :one_for_one, name: MyApp.Supervisor]
Supervisor.start_link(children, opts)
end
end-
Add
Fast.Plug.Readytolib/myapp_web/endpoint.ex:
plug Fast.Plug.Ready, otp_app: :myapp, path: "/readyz"