Module: Trane::Registry

Defined in:
lib/trane/registry.rb

Overview

Thread-safe registry of operations, representations, and errors.

The registry maintains a single frozen snapshot containing all three categories. Reads (Registry.operations, etc.) are lock-free: one ivar read returning a frozen Hash. Writes happen atomically via Registry.replace!, which constructs a new snapshot in a builder and swaps it in a single assignment (atomic under MRI GVL).

For ad-hoc registrations outside replace! (specs, REPL), the register_* methods do copy-on-write to a new snapshot — O(n) per write but bounded by spec sizes (typically < 100 entries).

Class methods on this module delegate to the process-level Registry::Instance via Trane.registry. Existing call sites (Trane::Registry.reset! etc.) continue to work unchanged.

Defined Under Namespace

Classes: Instance, SnapshotBuilder

Constant Summary collapse

EMPTY_ERRORS_BY_NAME =
{}.freeze
EMPTY_SNAPSHOT =
{
  operations:      {}.freeze,
  representations: {}.freeze,
  errors:          {}.freeze,
  errors_by_name:  EMPTY_ERRORS_BY_NAME
}.freeze

Class Method Summary collapse

Class Method Details

.errorsObject



309
# File 'lib/trane/registry.rb', line 309

def errors;          Trane.registry.errors; end

.errors_by_nameObject



311
# File 'lib/trane/registry.rb', line 311

def errors_by_name;  Trane.registry.errors_by_name; end

.operationsObject



307
# File 'lib/trane/registry.rb', line 307

def operations;      Trane.registry.operations; end

.register_error(d) ⇒ Object



316
# File 'lib/trane/registry.rb', line 316

def register_error(d);          Trane.registry.register_error(d); end

.register_operation(d) ⇒ Object



314
# File 'lib/trane/registry.rb', line 314

def register_operation(d);      Trane.registry.register_operation(d); end

.register_representation(d) ⇒ Object



315
# File 'lib/trane/registry.rb', line 315

def register_representation(d); Trane.registry.register_representation(d); end

.replace!(&block) ⇒ Object



313
# File 'lib/trane/registry.rb', line 313

def replace!(&block); Trane.registry.replace!(&block); end

.representationsObject



308
# File 'lib/trane/registry.rb', line 308

def representations; Trane.registry.representations; end

.reset!Object



317
# File 'lib/trane/registry.rb', line 317

def reset!;    Trane.registry.reset!; end

.validate!Object



318
# File 'lib/trane/registry.rb', line 318

def validate!; Trane.registry.validate!; end

.validator_declared_field_names_for(fields) ⇒ Object



321
# File 'lib/trane/registry.rb', line 321

def validator_declared_field_names_for(fields); Trane.registry.validator_declared_field_names_for(fields); end

.validator_field_names_for(fields) ⇒ Object



320
# File 'lib/trane/registry.rb', line 320

def validator_field_names_for(fields);          Trane.registry.validator_field_names_for(fields); end