Releases: dimamik/vault
Releases · dimamik/vault
v0.2.1
Implementation changes
- Instead of relying on process links, we now use
ProcessTreelibrary to safely and efficiently traverse process trees. This library under the hood usesProcess.info(pid, :parent)and fallbacks to Processes$ancestorsand$callersif OTP<=24 or if parent process is dead. - Update documentation to better explain the purpose and usage of the library.
Apart from that, the API remains unchanged.
v0.2.0
New 🔥
Vault is a lightweight Elixir library for process-scoped global data storage that propagates to linked process children.
Due to Elixir's actor model nature, it's common for a process to have global context that is valid for every function call inside this process (and its children).
For example, this context can include:
- A user when processing a user's request
- A tenant in a multi-tenant application
- Rate limiting buckets/quotas
- Cache namespaces
- API or client versions
- And many more, depending on your application domain
Usage
# Initialize vault in parent process
Vault.init(current_user: %{id: 1, first_name: "Alice", role: "admin"})
# Access data from any linked child process
Task.async(fn ->
user = Vault.get(:current_user)
user.first_name # => "Alice"
end)
# Access data from the parent process itself
Vault.get(:current_user) # => %{id: 1, first_name: "Alice", role: "admin"}Read more on GitHub