I hereby claim:
- I am lpeppe on github.
- I am luca_peppe (https://keybase.io/luca_peppe) on keybase.
- I have a public key ASC-ca8kfZMvNK-cxab93IDHZRoFfiHkL-TZzZ-Ei8kmGAo
To claim this, I am signing this object:
def fib(n: Int): Int = { | |
def go(n: Int, prev: Int, curr: Int): Int = { | |
if(n == 0) prev | |
else go(n - 1, curr, prev + curr) | |
} | |
go(n, 0, 1) | |
} | |
fib(5) |
def gcd(a: Int, b: Int) = | |
if(b == 0) a | |
else gcd(b, a%b) |
// const prom1 = new Promise((resolve, reject) => { | |
// resolve(2 + 2); | |
// }); | |
// const prom2 = new Promise((resolve, reject) => { | |
// setTimeout(() => resolve(1 + 1), 2000); | |
// }); | |
// // prom1.then(console.log); | |
// Promise.all([prom1, prom2]).then(console.log) |
I hereby claim:
To claim this, I am signing this object:
{ | |
"database": "healthy", | |
"document_processor": "healthy", | |
"payment_system": "unhealthy" | |
} |
defmodule PhxHealthcheck.Healthcheck do | |
@callback check_status() :: String.t() | |
end |
defmodule PhxHealthcheck.Healthcheck.Services.Database do | |
alias PhxHealthcheck.{Healthcheck, Repo} | |
import Ecto.Adapters.SQL | |
@behaviour Healthcheck | |
def check_status() do | |
try do | |
query(Repo, "SELECT 1") | |
rescue |
defmodule PhxHealthcheck.Healthcheck.Worker do | |
use GenServer | |
@spec start_link(list()) :: GenServer.on_start() | |
def start_link([service | _] = args) do | |
GenServer.start_link(__MODULE__, args, name: service) | |
end | |
@impl true | |
def init([service, refresh_interval]) do |
defmodule PhxHealthcheck.Healthcheck.Supervisor do | |
alias PhxHealthcheck.Healthcheck.Worker | |
use Supervisor | |
def start_link(init_arg) do | |
Supervisor.start_link(__MODULE__, init_arg, name: __MODULE__) | |
end | |
@impl true |
config :phx_healthcheck, :healthcheck, | |
services: [ | |
{PhxHealthcheck.Healthcheck.Services.Database, [name: "database", refresh_interval: 10000]} | |
] |