Class: OllamaAgent::Runtime::CompactorRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama_agent/runtime/compactor_runner.rb

Overview

Epoch-gated driver for Compactor; safe to call from a daemon loop (not auto-started).

Instance Method Summary collapse

Constructor Details

#initialize(compactor:, interval_epochs:) ⇒ CompactorRunner

Returns a new instance of CompactorRunner.



7
8
9
10
11
# File 'lib/ollama_agent/runtime/compactor_runner.rb', line 7

def initialize(compactor:, interval_epochs:)
  @compactor = compactor
  @interval = interval_epochs.to_i
  @last_compact_epoch = nil
end

Instance Method Details

#tick(current_epoch:) ⇒ Hash?

Returns compaction counts when a run fires; nil when below interval.

Returns:

  • (Hash, nil)

    compaction counts when a run fires; nil when below interval



14
15
16
17
18
19
20
21
22
# File 'lib/ollama_agent/runtime/compactor_runner.rb', line 14

def tick(current_epoch:)
  epoch = current_epoch.to_i
  if @last_compact_epoch.nil? || (epoch - @last_compact_epoch) >= @interval
    @last_compact_epoch = epoch
    return @compactor.compact(current_epoch: epoch)
  end

  nil
end