Skip to contents

Persists a guarded-flow object as JSON so that planning, approval and execution can happen in separate processes. The file carries a kind ("zotPlan", "zotPreview" or "zotApproval") and the fields of the corresponding object; a preview stores its rows together with its digest.

Usage

zotWriteBatch(x, path)

Arguments

x

A plan (a data.table with action, library, itemKey and payload), a zotPreview() or a zotApprove() record.

path

Destination file.

Value

path, invisibly.

Details

The file is written to a temporary sibling and renamed into place, so a reader never observes a partially written batch file. An existing file at path is replaced. Ledgers are written by zotExecute(), not here.

Examples

Plan <- data.table::data.table(
  action = "patch", library = "user", itemKey = "ABCD1234",
  payload = list(list(title = "A reviewed title"))
)
Path <- tempfile(fileext = ".json")
zotWriteBatch(Plan, Path)
zotReadBatch(Path)
#>    action library  itemKey   payload
#>    <char>  <char>   <char>    <list>
#> 1:  patch    user ABCD1234 <list[1]>
unlink(Path)