Packages

LowEndInsight is a simple 'bus-factor' risk analysis library for Open Source Software which is managed within a Git repository. Provide the git URL and the library will respond with a basic Elixir Map structure report.

Current section

Files

Jump to
lowendinsight lib counter_agent.ex
Raw

lib/counter_agent.ex

defmodule CounterAgent do
def new do
Agent.start_link(fn -> 0 end)
end
def click(pid) do
Agent.get_and_update(pid, fn n -> {n + 1, n + 1} end)
end
def set(pid, new_value) do
Agent.update(pid, fn _n -> new_value end)
end
def get(pid) do
Agent.get(pid, fn n -> n end)
end
end