Class: Legion::Extensions::Lex::Actor::AgentWatcher

Inherits:
Actors::Every
  • Object
show all
Defined in:
lib/legion/extensions/lex/actors/agent_watcher.rb

Overview

rubocop:disable Legion/Extension/EveryActorRequiresTime

Instance Method Summary collapse

Instance Method Details

#action(**_opts) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 18

def action(**_opts)
  current = Legion::Extensions.instance_variable_get(:@load_yaml_agents) || []
  reloaded = 0

  current.each do |agent|
    path = agent[:_source_path]
    next unless path && File.exist?(path)
    next unless File.mtime(path) > agent[:_source_mtime]

    reloaded += 1
  end

  if reloaded.positive?
    Legion::Extensions.instance_variable_set(:@load_yaml_agents, nil)
    Legion::Extensions.load_yaml_agents
  end

  { reloaded: reloaded }
end

#check_subtask?Boolean

Returns:

  • (Boolean)


15
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 15

def check_subtask? = false

#generate_task?Boolean

Returns:

  • (Boolean)


16
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 16

def generate_task? = false

#run_now?Boolean

Returns:

  • (Boolean)


13
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 13

def run_now? = false

#runner_classObject



8
9
10
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 8

def runner_class
  self.class
end

#timeObject



12
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 12

def time = 30

#use_runner?Boolean

Returns:

  • (Boolean)


14
# File 'lib/legion/extensions/lex/actors/agent_watcher.rb', line 14

def use_runner? = false