Class: CodeSunset::EventIngestor
- Inherits:
-
Object
- Object
- CodeSunset::EventIngestor
- Defined in:
- lib/code_sunset/event_ingestor.rb
Class Method Summary collapse
Class Method Details
.flush_buffer(limit: nil) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/code_sunset/event_ingestor.rb', line 26 def flush_buffer(limit: nil) drained = CodeSunset.event_buffer.drain(limit: limit) drained.each { |payload| persist(payload) } drained.size rescue StandardError => error CodeSunset.log_error("buffer flush", error) 0 end |
.ingest(payload) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/code_sunset/event_ingestor.rb', line 4 def ingest(payload) return if payload.blank? if CodeSunset.configuration.async && defined?(CodeSunset::PersistEventJob) enqueue(payload) else persist(payload) end rescue StandardError => error CodeSunset.log_error("event ingestion", error) handle_async_failure(payload, error) end |
.persist(payload) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/code_sunset/event_ingestor.rb', line 17 def persist(payload) return unless defined?(CodeSunset::Event) CodeSunset::Event.create_from_payload(payload) rescue StandardError => error CodeSunset.log_error("event persistence", error) nil end |