Next: Persistence Environments, Previous: Operations on actormaps, Up: Persistence [Contents][Index]
When a vat is spawned, it can be spawned as a persistent vat with a given persistence environment and set of roots. The vat also has a storage provider associated with it. Vats can be persisted either on each churn (when the vat reaches quiescence), or manually. If a vat is configured to persist on churns, just the objects which have changed (using become) will be persisted.
[#:log-capacity] [#:persistence-registry] [#:version] [#:upgrade]
Create and return a reference to a new vat configured with persistence.
'churn
will persist on churns, otherwise
in a manual persistence mode (default: 'churn
).
spawn-fibrous-vat
.
name: Name of the vat. Note that this is not the name it is bound to in the current namespace.
#t
, log vat events; otherwise, do not.
0
when no version is specified.
The migrations
macro is generally what would be expected to be
used for the upgrade procedure
(define-actor (^counter bcom value) (lambda () (bcom (^counter bcom (+ 1 value)) value))) (define persistence-env (make-persistence-env `((((counter) ^counter) ,^counter)))) (define-values (vat my-counter) (spawn-persistent-vat persistence-env (lambda () (spawn ^counter 0)) (make-memory-store)))
The ^persistence-registry
actor is designed to be spawned anew
each time the program starts (i.e. is not part of the persistence
graph) and is shared amongst several persistent vats which want to
persist/rehydrate objects across vats.
Unlike local near refrs which are promises during rehydration, but are swapped
to local refrs after rehydration is complete, Far refrs remain promises and
should resolve after both vats are setup and have registered themselves with
the ^persistence-registry
object.
Here’s an example of two vats, the cell on b-vat
holds a reference to
an object on a-vat
;; Spawn the persistence registry in its own vat without persistence enabled. (define persistence-vat (spawn-vat)) (define persistence-registry (with-vat persistence-vat (spawn ^persistence-registry))) ;; Spawn the initial a-vat with an a-cell object (define a-vat-store (make-memory-store)) (define-values (a-vat a-cell) (spawn-persistent-vat cell-env (lambda () (spawn ^cell)) a-vat-store #:persistence-registry persistence-registry)) ;; Spawn a b-vat with a b-cell object, that will reference the far refr a-cell (define b-vat-store (make-memory-store)) (define-values (b-vat b-cell) (spawn-persistent-vat cell-env (lambda () (spawn ^cell a-cell)) b-vat-store #:persistence-registry persistence-registry))
Next: Persistence Environments, Previous: Operations on actormaps, Up: Persistence [Contents][Index]