ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - ggpasqualino/plug_checkup: PlugCheckup provides a Plug for adding simple health checks to your app
PlugCheckup provides a Plug for adding simple health checks to your app - ggpasqualino/plug_checkup
Visit Site

GitHub - ggpasqualino/plug_checkup: PlugCheckup provides a Plug for adding simple health checks to your app

GitHub - ggpasqualino/plug_checkup: PlugCheckup provides a Plug for adding simple health checks to your app

Build Coverage Status || Hex version Hex downloads

PlugCheckup

PlugCheckup provides a Plug for adding simple health checks to your app. The JSON output is similar to the one provided by the MiniCheck Ruby library. It was started to provide solarisBank an easy way of monitoring Plug based applications.

Usage

  • Add the package to "mix.exs"
defp deps do
  [
    {:plug_checkup, "~> 0.3.0"}
  ]
end
defmodule MyHealthChecks do
  def check_db do
    :ok
  end

  def check_redis do
    :ok
  end
end
  • Forward your health path to PlugCheckup in your Plug Router
checks = [
  %PlugCheckup.Check{name: "DB", module: MyHealthChecks, function: :check_db},
  %PlugCheckup.Check{name: "Redis", module: MyHealthChecks, function: :check_redis}
]

forward(
  "/health",
  to: PlugCheckup,
  init_opts: PlugCheckup.Options.new(json_encoder: Jason, checks: checks)
)

If you're working with Phoenix, you need to change the syntax slightly to accomodate Phoenix.Router.forward/4:

checks = [
  %PlugCheckup.Check{name: "DB", module: MyHealthChecks, function: :check_db},
  %PlugCheckup.Check{name: "Redis", module: MyHealthChecks, function: :check_redis}
]

forward("/health", PlugCheckup, PlugCheckup.Options.new(json_encoder: Jason, checks: checks))

The Checks

A check is a function with arity zero, which should return either :ok or {:error, term}. In case the check raises an exception or times out, that will be mapped to an {:error, reason} result.

Response

PlugCheckup should return either 200 or 500 statuses, Content-Type header "application/json", and the body should respect this JSON schema

If you configure the error_code option when initializing the plug, the specified value will be used when an error occurs instead of the 500 status.

Demo

Check .iex.exs for a demo of plug_checkup in a Plug.Router. The demo can be run as following.

git clone https://github.com/ggpasqualino/plug_checkup
cd plug_checkup
mix deps.get
iex -S mix

Open your browse either on http://localhost:4000/selfhealth or http://localhost:4000/dependencyhealth

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory