Class: InstantRecord::BootstrapsController
- Inherits:
-
ActionController::API
- Object
- ActionController::API
- InstantRecord::BootstrapsController
- Defined in:
- app/controllers/instant_record/bootstraps_controller.rb
Overview
First-sync hydration: current state (windowed per model when a sync_window is declared) plus the change-log cursor, so a fresh client never replays the whole change log. The cursor is read BEFORE the rows, inside one transaction: events committed between cursor and response re-apply idempotently client-side, whereas the reverse order would skip them.
Instance Method Summary collapse
Instance Method Details
#show ⇒ Object
10 11 12 13 14 15 16 |
# File 'app/controllers/instant_record/bootstraps_controller.rb', line 10 def show payload = ActiveRecord::Base.transaction do cursor = Change.maximum(:id) || 0 { cursor: cursor, records: bootstrap_models.flat_map { |model| serialize_rows(model) } } end render json: payload end |