Class: Legion::Extensions::MicrosoftTeams::Actor::ApiIngest

Inherits:
Actors::Every
  • Object
show all
Includes:
Helpers::ThrottleAware
Defined in:
lib/legion/extensions/microsoft_teams/actors/api_ingest.rb

Constant Summary

Constants included from Helpers::ThrottleAware

Helpers::ThrottleAware::DEFAULT_DEFERRAL, Helpers::ThrottleAware::MAX_DEFERRAL

Instance Method Summary collapse

Methods included from Helpers::ThrottleAware

#defer_for, #reset_throttle_deferral, #throttle_remaining, #throttle_suppressed?, #throttled_until, #with_throttle_deferral

Instance Method Details

#check_subtask?Boolean

Returns:

  • (Boolean)


16
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 16

def check_subtask? = false

#delayObject



22
23
24
25
26
27
28
29
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 22

def delay
  auth_validator = Legion::Extensions::Identity::Entra::Delegated::Actor::AuthValidator.allocate
  base_delay = auth_validator.respond_to?(:delay) ? auth_validator.delay.to_f : 9.0
  [base_delay + 5.0, 14].max
rescue StandardError => e
  handle_exception(e, level: :debug, operation: 'ApiIngest#delay')
  14
end

#enabled?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
40
41
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 35

def enabled?
  teams_settings.dig(:api_ingest, :enabled) &&
    defined?(Legion::Extensions::Agentic::Memory::Trace::Runners::Traces)
rescue StandardError => e
  handle_exception(e, level: :warn, operation: 'ApiIngest#enabled?')
  false
end

#generate_task?Boolean

Returns:

  • (Boolean)


18
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 18

def generate_task? = false

#manualObject



43
44
45
46
47
48
49
50
51
52
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 43

def manual
  log.debug('ApiIngest#manual starting')
  # The runner re-raises Errors::Throttled (rather than folding it
  # into an error result) precisely so this actor can defer its
  # next run by the advertised retry_after instead of charging the
  # shared Graph circuit again on the next interval.
  with_throttle_deferral { run_ingest }
rescue StandardError => e
  handle_exception(e, level: :error, operation: 'ApiIngest#manual')
end

#run_now?Boolean

Returns:

  • (Boolean)


20
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 20

def run_now? = true

#runner_classObject



10
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 10

def runner_class = Legion::Extensions::MicrosoftTeams::Runners::ApiIngest

#runner_functionObject



12
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 12

def runner_function = 'ingest_api'

#timeObject



31
32
33
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 31

def time
  teams_settings.dig(:api_ingest, :interval)
end

#use_runner?Boolean

Returns:

  • (Boolean)


14
# File 'lib/legion/extensions/microsoft_teams/actors/api_ingest.rb', line 14

def use_runner? = false