Skip to content

Releases: dimamik/vault

v0.2.1

20 Sep 15:16
6a0d685

Choose a tag to compare

Implementation changes

  • Instead of relying on process links, we now use ProcessTree library to safely and efficiently traverse process trees. This library under the hood uses Process.info(pid, :parent) and fallbacks to Processes $ancestors and $callers if 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

11 Sep 13:16
7532cb4

Choose a tag to compare

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