Class: InstantRecord::Change
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- InstantRecord::Change
- Defined in:
- app/models/instant_record/change.rb
Overview
Server-side ordered change log. The auto-increment id is the SSE cursor.
Class Method Summary collapse
-
.poll(cursor) ⇒ Object
One poll of the change log for a streaming loop.
Instance Method Summary collapse
Class Method Details
.poll(cursor) ⇒ Object
One poll of the change log for a streaming loop. Block-scoped connection checkout — an idle stream must not pin a database connection while it sleeps — and uncached, because the request executor's query cache would otherwise return the first poll's result forever.
14 15 16 17 18 |
# File 'app/models/instant_record/change.rb', line 14 def self.poll(cursor) connection_pool.with_connection do uncached { after(cursor).to_a } end end |
Instance Method Details
#as_event ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/models/instant_record/change.rb', line 20 def as_event { type: record_type, id: record_id, operation: operation, version: version, attributes: attributes_payload } end |