Class: ActiveStorage::AsyncVariants::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/active_storage/async_variants/registry.rb

Overview

Process-wide lookup of async_options keyed by Variation#digest.

Populated lazily by VariationExtension#initialize whenever a Variation is constructed with :transformer in its async_options – which happens on every view-side ‘attachment.variant(:name)` call. The redirect controller then resolves async_options by digest without scanning blob.attachments for a transformations-match.

Cold-worker behavior: if a worker receives a redirect-URL request before any view-side call has registered the variant’s digest, the lookup misses and resolution falls through to standard Rails (no leak, no spinner). Self-warms on subsequent view requests.

Constant Summary collapse

MONITOR =
Monitor.new
STORE =
{}

Class Method Summary collapse

Class Method Details

.[](digest) ⇒ Object



28
29
30
# File 'lib/active_storage/async_variants/registry.rb', line 28

def [](digest)
  MONITOR.synchronize { STORE[digest] }
end

.clearObject



32
33
34
# File 'lib/active_storage/async_variants/registry.rb', line 32

def clear
  MONITOR.synchronize { STORE.clear }
end

.register(digest, async_options) ⇒ Object



24
25
26
# File 'lib/active_storage/async_variants/registry.rb', line 24

def register(digest, async_options)
  MONITOR.synchronize { STORE[digest] = async_options }
end