Class: LlmCostTracker::Storage::Dispatcher

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/storage/dispatcher.rb

Class Method Summary collapse

Class Method Details

.save(event) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/llm_cost_tracker/storage/dispatcher.rb', line 9

def save(event)
  config = LlmCostTracker.configuration
  case config.storage_backend
  when :log           then log_event(event, config)
  when :active_record then active_record_save(event)
  when :custom        then custom_save(event, config)
  end
rescue LlmCostTracker::BudgetExceededError, LlmCostTracker::UnknownPricingError
  raise
rescue StandardError => e
  handle_error(e)
  false
end