package ledger import ( "context" "encoding/json" "time" "github.com/carlosframework/platform/internal/release" ) // Each ledger writer runs as one app mutation of sqid/app: the HEAD read, the // chained entry and the HEAD CAS (or the blob, or the manifest swap) share one // admitted operation on an enabled console store. Ordinary stores do not // implement release.AppMutationRunner, so on boxes and with host claims off // each writer runs its original body unchanged. // Append is claimRawAppend under the app mutation of sqid/app. func Append(ctx context.Context, st release.Store, sqid, app, name, writer string, payload json.RawMessage, now func() time.Time) (Appended, error) { var a Appended err := release.WithAppMutation(ctx, st, sqid, app, "ledger.Append", func(ctx context.Context) error { var err error a, err = claimRawAppend(ctx, st, sqid, app, name, writer, payload, now) return err }) return a, err } // PutBlob is claimRawPutBlob under the app mutation of sqid/app. func PutBlob(ctx context.Context, st release.Store, sqid, app, name string, body []byte) (string, error) { var sha string err := release.WithAppMutation(ctx, st, sqid, app, "ledger.PutBlob", func(ctx context.Context) error { var err error sha, err = claimRawPutBlob(ctx, st, sqid, app, name, body) return err }) return sha, err } // UpdateManifest is claimRawUpdateManifest under the app mutation of sqid/app. func UpdateManifest(ctx context.Context, st release.Store, sqid, app string, apply func(*Manifest) error) (Manifest, error) { var m Manifest err := release.WithAppMutation(ctx, st, sqid, app, "ledger.UpdateManifest", func(ctx context.Context) error { var err error m, err = claimRawUpdateManifest(ctx, st, sqid, app, apply) return err }) return m, err }