Class: LlmCostTracker::Ingestion::Inbox
- Inherits:
-
Object
- Object
- LlmCostTracker::Ingestion::Inbox
- Defined in:
- lib/llm_cost_tracker/ingestion/inbox.rb
Constant Summary collapse
- PAYLOAD_SCHEMA_VERSION =
2
Class Method Summary collapse
Class Method Details
.event_from_row(row) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/llm_cost_tracker/ingestion/inbox.rb', line 22 def event_from_row(row) payload = JSON.parse(row.payload, symbolize_names: true) schema_version = payload[:schema_version] unless schema_version == PAYLOAD_SCHEMA_VERSION raise LlmCostTracker::Error, "unsupported ledger inbox payload schema version #{schema_version.inspect}" end LlmCostTracker::Event.new(**event_attributes_from(payload)) end |
.save(event) ⇒ Object
16 17 18 19 20 |
# File 'lib/llm_cost_tracker/ingestion/inbox.rb', line 16 def save(event) insert_row(row_for(event)) Ingestion::Worker.ensure_started event end |