Class: WideEvent::Sinks::Store
- Inherits:
-
Object
- Object
- WideEvent::Sinks::Store
- Defined in:
- lib/wide_event/sinks/store.rb
Overview
Delivers the wide event to the DuckDB store: builds the canonical event envelope (WideEvent::Store::Envelope) and hands the resulting JSON to the bounded, PID-aware sender. Never performs network I/O on the calling (application) thread and never changes the custom-sink interface: #flush(attrs) is the only method other sinks need.
Instance Method Summary collapse
- #flush(attrs) ⇒ Object
-
#initialize(sender:, clock: -> { Time.now }, uuid: -> { SecureRandom.uuid }, env: ENV) ⇒ Store
constructor
A new instance of Store.
-
#shutdown(timeout: ::WideEvent::Store::Sender::SHUTDOWN_TIMEOUT) ⇒ Object
Delegates to the sender's best-effort shutdown flush.
Constructor Details
#initialize(sender:, clock: -> { Time.now }, uuid: -> { SecureRandom.uuid }, env: ENV) ⇒ Store
Returns a new instance of Store.
11 12 13 14 15 16 |
# File 'lib/wide_event/sinks/store.rb', line 11 def initialize(sender:, clock: -> { Time.now }, uuid: -> { SecureRandom.uuid }, env: ENV) @sender = sender @clock = clock @uuid = uuid @env = env end |
Instance Method Details
#flush(attrs) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/wide_event/sinks/store.rb', line 18 def flush(attrs) json = ::WideEvent::Store::Envelope.build(attrs, clock: @clock, uuid: @uuid, env: @env) @sender.enqueue(json) nil rescue StandardError => e WideEvent.handle_error(e, "store_sink_flush") nil end |
#shutdown(timeout: ::WideEvent::Store::Sender::SHUTDOWN_TIMEOUT) ⇒ Object
Delegates to the sender's best-effort shutdown flush.
28 29 30 |
# File 'lib/wide_event/sinks/store.rb', line 28 def shutdown(timeout: ::WideEvent::Store::Sender::SHUTDOWN_TIMEOUT) @sender.shutdown(timeout: timeout) end |