Class: ActiveRecord::Materialized::AsyncRefresher Private

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
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 Method Summary collapse

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.



14
15
16
17
18
19
20
21
# File 'lib/activerecord/materialized/async_refresher.rb', line 14

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.



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

def flush!
  mutex.synchronize do
    cancel_timer_unlocked
    drain_pending_unlocked
  end
end

.paused=(value) ⇒ 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.



47
48
49
# File 'lib/activerecord/materialized/async_refresher.rb', line 47

def paused=(value)
  @paused = T.let(value, T.nilable(T::Boolean))
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)


52
53
54
55
# File 'lib/activerecord/materialized/async_refresher.rb', line 52

def paused?
  @paused = T.let(@paused, T.nilable(T::Boolean))
  @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.



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

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.



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

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