Fief.Cache.VnodeImpl (Fief v0.1.0)

Copy Markdown View Source

The trivial reference Fief.Vnode implementation (implementation.md §6.1): a cache-shaped vnode backed by one ETS table per vnode. It doubles as the behaviour's documentation example — and it is genuinely trivial:

  • handoff_outFief.Vnode.report_drained/1 immediately. A cache holds nothing worth shipping; the transfer settles as soon as the planner sees the report.
  • handoff_in → start empty. Whether the assignment is fresh, a planned transfer, or a donor-return, dropping cache entries is always safe — the durable source of truth is elsewhere by definition.

No key callbacks, no residual enumeration, no migration: incremental migration is opt-in via Fief.Transfer, not contract surface.

The ETS table is created in init/2, which runs in the agent process, so the agent owns it: it lives in the agent's link tree and dies with the agent — exactly what makes the fencing kill complete (implementation.md §2).

Message format (the impl-defined payload vocabulary):

  • {:put, key, value} → replies :ok
  • {:get, key} → replies {:ok, value} or :error
  • {:delete, key} → replies :ok

This module is also the runtime half of the first-class Fief.Cache surface: Fief.Cache hashes keys to a vnode caller-side (Fief.Hasher) and calls straight through the router, so this impl never sees a raw key needing routing — only the already-targeted {:put, ...} / {:get, ...} / {:delete, ...} payload. Caller-side hashing is exactly why config_fingerprint/1 exists here: key→vnode agreement between every node is now contractual (a joiner computing a different vnode for the same key would silently split the keyspace), so the fingerprint gates the join on the hasher module agreeing everywhere, the same rationale as Fief.Key.VnodeImpl.

Summary

Functions

Joiner-compatibility fingerprint (mirrors Fief.Key.VnodeImpl's): because Fief.Cache hashes keys to vnodes caller-side, every node must agree on the hasher module or the keyspace silently splits across nodes with no framework signal. Checked at join phase one, before shared state is touched.

Functions

config_fingerprint(ctx)

Joiner-compatibility fingerprint (mirrors Fief.Key.VnodeImpl's): because Fief.Cache hashes keys to vnodes caller-side, every node must agree on the hasher module or the keyspace silently splits across nodes with no framework signal. Checked at join phase one, before shared state is touched.