Class: ActiveRecord::Materialized::AsyncRefresher Private

Inherits:
Object
  • Object
show all
Defined in:
lib/activerecord/materialized/async_refresher.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

In-process, debounced background refresher — the default :async dispatcher.

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.paused=(value) ⇒ Object (writeonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

When paused, refreshes accumulate and run only on an explicit flush! — no background timer fires.



39
40
41
# File 'lib/activerecord/materialized/async_refresher.rb', line 39

def paused=(value)
  @paused = value
end

Class Method Details

.enqueue(view_class) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



10
11
12
13
14
15
16
17
# File 'lib/activerecord/materialized/async_refresher.rb', line 10

def enqueue(view_class)
  interval = view_class.resolved_refresh_debounce

  mutex.synchronize do
    pending[view_class.view_key] = view_class
    schedule_unlocked(interval)
  end
end

.flush!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



19
20
21
22
23
24
# File 'lib/activerecord/materialized/async_refresher.rb', line 19

def flush!
  mutex.synchronize do
    cancel_timer_unlocked
    drain_pending_unlocked
  end
end

.paused?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


41
42
43
# File 'lib/activerecord/materialized/async_refresher.rb', line 41

def paused?
  @paused || false
end

.pending_countObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



26
27
28
# File 'lib/activerecord/materialized/async_refresher.rb', line 26

def pending_count
  mutex.synchronize { pending.size }
end

.reset!Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



30
31
32
33
34
35
# File 'lib/activerecord/materialized/async_refresher.rb', line 30

def reset!
  mutex.synchronize do
    cancel_timer_unlocked
    pending.clear
  end
end