Fact.Seam.Registry behaviour (Fact v0.2.1)

View Source

Provides a registry for all implementations of a configurable Fact.Seam component. 📚

A Fact.Seam.Registry is responsible for:

  • Listing all available implementations (all/0)
  • Resolving a specific implementation by {family, version} (resolve/1 or resolve/2)
  • Returning the latest implementation for a family (latest_impl/1)
  • Returning the latest version number for a family (latest_version/1)

Usage

When a module uses Fact.Seam.Registry, it generates:

  • A static list of all known implementations
  • A map of the latest version per family
  • Convenience functions to resolve specific versions or get the latest

This registry is key for the system's configurable architecture, allowing different components to be swapped, upgraded, or resolved dynamically without changing the core system logic.

Essentially, this module provides the source of truth for what implementations exist, their versions, and which one is considered the latest for a given family.

Summary

Callbacks

all()

@callback all() :: list()

latest_impl(atom)

@callback latest_impl(atom()) :: module()

latest_version(atom)

@callback latest_version(atom()) :: non_neg_integer()

resolve({})

@callback resolve({atom(), non_neg_integer()}) :: {:ok, module()} | {:error, term()}