Class: Legion::Extensions::Llm::Actor::MeteringFlush
- Inherits:
-
Actors::Every
- Object
- Actors::Every
- Legion::Extensions::Llm::Actor::MeteringFlush
- Defined in:
- lib/legion/extensions/llm/actors/metering_flush.rb
Overview
Periodically drains the LLM metering spool.
Metering events are emitted by legion-llm's Legion::LLM::Metering. When
transport is down at emit time they are appended to a durable JSONL
spool (~/.legionio/data/spool/metering/events.jsonl) instead of being
published to the llm.metering exchange. Nothing was draining that
spool after lex-llm-gateway was retired, so events accumulated forever.
flush_spool reads every spooled event — chat, embeddings, skills, all funnel through Legion::LLM::Metering.emit into the same file — and republishes each to the exchange, then truncates. It is a no-op when transport is unavailable, so it is safe to tick every minute.
runner_class points at legion-llm (the higher gem, always loaded at full boot). lex-llm must not require legion-llm — that would be circular (legion-llm depends on lex-llm) — so we reference it by string and let the actor base resolve the constant at tick time via const_get.
NOT a singleton actor: every node runs LegionIO independently and owns its own spool file, so each node must drain its own spool. Leader election would strand every non-leader node's spool.
Instance Method Summary collapse
- #check_subtask? ⇒ Boolean
- #generate_task? ⇒ Boolean
- #run_now? ⇒ Boolean
- #runner_class ⇒ Object
- #runner_function ⇒ Object
- #time ⇒ Object
- #use_runner? ⇒ Boolean
Instance Method Details
#check_subtask? ⇒ Boolean
49 50 51 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 49 def check_subtask? false end |
#generate_task? ⇒ Boolean
53 54 55 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 53 def generate_task? false end |
#run_now? ⇒ Boolean
41 42 43 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 41 def run_now? false end |
#runner_class ⇒ Object
29 30 31 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 29 def runner_class 'Legion::LLM::Metering' end |
#runner_function ⇒ Object
33 34 35 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 33 def runner_function 'flush_spool' end |
#time ⇒ Object
37 38 39 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 37 def time 60 end |
#use_runner? ⇒ Boolean
45 46 47 |
# File 'lib/legion/extensions/llm/actors/metering_flush.rb', line 45 def use_runner? false end |