Skip to content

Support passing options when creating a snapshot - #110

Merged
lejeunerenard merged 3 commits into
session-checkoutfrom
ljr-session-checkout
Sep 30, 2026
Merged

lejeunerenard merged 3 commits into
session-checkoutfrom
ljr-session-checkout

Conversation

@lejeunerenard

@lejeunerenard lejeunerenard commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

This passes the options to the engine's .snapshot(opts) and maintains them on the HyperDB instance so they are maintained if it is .update()'ed, which refreshes the snapshot.

One con is that this will double snapshot the engine when creating a transaction on an outdated parent because one is to set the options and the other is to update the instance from the engine. So small tradeoff with that.

Done with help from AI.

Adds support for setting the session config options on the hyperbee2
engine while remaining generic. The options are stored on the HyperDB
instance because of snapshots being updated during `.update()`.

Engines now support a `snapshotFrom` method which takes the current
snapshot and the options giving a new configured version. This happens
only in `_createSnapshot()` as it is the shared way of creating the new
view / hyperdb instance. `snapshotFrom()` is necessary to maintain the
position of the current snapshot just with options.

This all supports setting the session config not just for transactions,
but also for calling `db.snapshot()` at the top level (aka on HyperDB
instance).
IE the shape is dictated by the underlying engine module so should be
driven by that instead of being enforced at the engine level.
Add noop `snapshotFrom` to the other engines
@lejeunerenard
lejeunerenard added this pull request to stack #111 September 30, 2026 20:03
@lejeunerenard
lejeunerenard merged commit faaa21c into main Sep 30, 2026
8 checks passed
@lejeunerenard
lejeunerenard deleted the ljr-session-checkout branch September 30, 2026 21:13
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