carlosj
Hi all,
I have published the first public release, 0.1.0, of Malla, a framework for distributed services in Elixir.
Malla is a framework for developing distributed services in Elixir. A service is a module whose behavior is composed from plugins through callback chains that are resolved when the code is compiled. Services running on different Erlang nodes find each other and can call each other. The framework keeps the moving parts few and visible.
Malla is also useful on a single node: it gives you plugin-based services, a lifecycle with admin and running statuses, and plugins that can be added, removed or reconfigured while the service runs. Distribution is there when you need it.
A service is a module:
defmodule MyService do
use Malla.Service, global: true
defcb fun1(a), do: {:ok, %{you_said: a, node: node()}}
end
From any other node of the cluster:
Malla.remote(MyService, :fun1, ["hello"])
#=> {:ok, %{you_said: "hello", node: :"first@127.0.0.1"}}
Behaviour comes from plugins. A callback is a chain: each plugin answers, or passes the call on with :cont:
defmodule AdditionPlugin do
use Malla.Plugin
defcb calculate(:add, a, b), do: {:ok, a + b}
defcb calculate(_, _, _), do: :cont
end
defmodule MultiplicationPlugin do
use Malla.Plugin
defcb calculate(:multiply, a, b), do: {:ok, a * b}
defcb calculate(_, _, _), do: :cont
end
defmodule Calculator do
use Malla.Service, plugins: [AdditionPlugin, MultiplicationPlugin]
end
Calculator.calculate(:multiply, 8, 4)
#=> {:ok, 32}
What it does:
- Plugins. Each plugin can handle the call, change its arguments or pass it on with
:cont. A plugin can depend on others and is placed above them. The chain is worked out at compile time, so a call is a function call. - Discovery and remote calls. Services announce themselves through
:pgand are called with:erpc. A node that does not have the module gets a proxy for it. - Changes at run time.
reconfigure/2,add_plugin/3,del_plugin/2andset_admin_status/3(active, pause, inactive) on a running service. - Optional plugins for request handling, tracing, status and an HTTP endpoint for Kubernetes probes.
Malla is the first piece of a larger set I am opening up, one by one: Marea for Kubernetes deploys, Grada as a Kafka client, Caracola for SIP, and plugins for data, jobs, auth, tracing, MQTT and UI. Together they are meant to let you build a complex distributed application quickly and completely, on one foundation. Malla is the base the rest plugs into.
Where it stands: 0.1.0, Elixir 1.17+, one required dependency (telemetry), Apache-2.0. It runs a big telemedicine platform in production, and it is the Elixir successor of NkSERVICE, which some of you may remember from NkSIP. The API can still change.
- Hex: malla | Hex
- Docs: malla v0.1.0 — Documentation
- Livebook: malla/livebook/getting_started.livemd at main · netkubes/malla · GitHub
- Longer write-up: Introducing Malla: distributed services in Elixir, composed from plugins · Erlnets
Thanks,
Carlos
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #elixirconf-us
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #security
- #elixirconf-eu
- #processes
- #api
- #forms
- #hex










