Skip to content

skipruntime: add updateAll to write several input collections atomically - #1509

Open
skiplabsdaniel wants to merge 1 commit into
SkipLabs:mainfrom
skiplabsdaniel:add-update-all
Open

skiplabsdaniel wants to merge 1 commit into
SkipLabs:mainfrom
skiplabsdaniel:add-update-all

Conversation

@skiplabsdaniel

Copy link
Copy Markdown
Contributor

Updating N input collections required N calls to update, each triggering its own recomputation and its own round of subscriber notifications. Beyond the cost, subscribers observed intermediate states in which only part of the collections had been written, and a failure midway left the earlier writes applied.

Add updateAll, which writes a whole batch in one shot:

  • writeInCollection (Runtime.sk) gains an update flag so several collections can be written before a single context.update() and a single getSubscriptions() drain -- one recomputation, one notification.
  • SkipRuntime_Runtime__updateAll is exported from the FFI and wired through both the native addon and the wasm bindings, mirroring update.
  • ServiceInstance.updateAll runs the batch in a fork, merged on success and aborted on failure, so the update is all-or-nothing.
  • SkipServiceBroker.updateAll and the PATCH /v1/inputs control route expose it over HTTP, the batch counterpart of PATCH /v1/inputs/:collection.

Tests cover the batch on two services, assert that a batch produces exactly one subscriber notification where two sequential updates produce two, and check that a batch naming an unknown collection throws and leaves none of the collections written.

Updating N input collections required N calls to `update`, each triggering
its own recomputation and its own round of subscriber notifications. Beyond
the cost, subscribers observed intermediate states in which only part of the
collections had been written, and a failure midway left the earlier writes
applied.

Add `updateAll`, which writes a whole batch in one shot:

- `writeInCollection` (Runtime.sk) gains an `update` flag so several
  collections can be written before a single `context.update()` and a single
  `getSubscriptions()` drain -- one recomputation, one notification.
- `SkipRuntime_Runtime__updateAll` is exported from the FFI and wired through
  both the native addon and the wasm bindings, mirroring `update`.
- `ServiceInstance.updateAll` runs the batch in a fork, merged on success and
  aborted on failure, so the update is all-or-nothing.
- `SkipServiceBroker.updateAll` and the `PATCH /v1/inputs` control route
  expose it over HTTP, the batch counterpart of `PATCH /v1/inputs/:collection`.

Tests cover the batch on two services, assert that a batch produces exactly
one subscriber notification where two sequential updates produce two, and
check that a batch naming an unknown collection throws and leaves none of the
collections written.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant