Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elx — OTP Playground

A small Elixir project that messes around with OTP supervisors and GenServers. Built while learning how to chain supervisors, run dynamic workers, and keep processes talking to each other.

What's inside

  • Counter — a GenServer that goes up and down. You inc, you dec, you get. That's it. Lives under a dynamic supervisor so you can spin one up whenever you feel like counting something.

  • Worker — another GenServer, dumber but friendlier. It answers ping and status. Also dynamically supervised.

  • WorkerSupervisor — a DynamicSupervisor that launches counters and workers on the fly. No need to define them all upfront.

  • Supervisor — the top-level boss. It starts the process registry and the dynamic supervisor, and if either goes down it brings them back. That's the "one for one" strategy.

  • Registry — a local process registry (Registry module). Counters and workers register themselves here by name, so you can find them without keeping track of PIDs.

How to run

# Fire up the supervision tree
App.start()

# Run the demo — starts two counters, two workers,
# increments, decrements, and pings around
App.demo()

You should get a tuple back like:

{8, 5, {:ok, :alive, :w1}, %{status: :ok, id: :w2}}

Why this exists

Honestly? To get hands-on with OTP. Reading docs is one thing, wiring up supervisors and watching processes come and go on your own machine is another. If you're learning Elixir and want to see how the pieces fit together, this might help.

Requirements

  • Elixir 1.20+
  • A terminal

License

MIT — do whatever you want with it.

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages