Class: Legion::Extensions::MicrosoftTeams::Actor::CacheSync
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::MicrosoftTeams::Actor::CacheSync
- Defined in:
- lib/legion/extensions/microsoft_teams/actors/cache_sync.rb
Constant Summary collapse
- SYNC_INTERVAL =
5 minutes
300
Instance Method Summary collapse
- #args ⇒ Object
- #check_subtask? ⇒ Boolean
- #enabled? ⇒ Boolean
- #generate_task? ⇒ Boolean
-
#initialize(**opts) ⇒ CacheSync
constructor
A new instance of CacheSync.
- #manual ⇒ Object
- #run_now? ⇒ Boolean
- #runner_class ⇒ Object
- #runner_function ⇒ Object
- #time ⇒ Object
- #use_runner? ⇒ Boolean
Constructor Details
#initialize(**opts) ⇒ CacheSync
Returns a new instance of CacheSync.
10 11 12 13 14 15 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 10 def initialize(**opts) return unless enabled? @last_sync_time = nil super end |
Instance Method Details
#args ⇒ Object
31 32 33 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 31 def args { since: @last_sync_time, skip_bots: true } end |
#check_subtask? ⇒ Boolean
22 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 22 def check_subtask? = false |
#enabled? ⇒ Boolean
25 26 27 28 29 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 25 def enabled? # TODO: local cache has no chat type metadata — cannot filter out channel # messages. Disabled until cache records include chatType. false end |
#generate_task? ⇒ Boolean
23 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 23 def generate_task? = false |
#manual ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 35 def manual result = runner_class.send(runner_function, since: @last_sync_time, skip_bots: true) if result.is_a?(Hash) && result[:result] latest = result[:result][:latest_time] @last_sync_time = latest if latest stored = result[:result][:stored] || 0 log.info("CacheSync: ingested #{stored} new Teams messages") if stored.positive? end rescue StandardError => e log.error("CacheSync: #{e.}") end |
#run_now? ⇒ Boolean
20 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 20 def run_now? = false |
#runner_class ⇒ Object
17 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 17 def runner_class = Legion::Extensions::MicrosoftTeams::Runners::CacheIngest |
#runner_function ⇒ Object
18 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 18 def runner_function = 'ingest_cache' |
#time ⇒ Object
19 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 19 def time = SYNC_INTERVAL |
#use_runner? ⇒ Boolean
21 |
# File 'lib/legion/extensions/microsoft_teams/actors/cache_sync.rb', line 21 def use_runner? = false |