StateManagementService
Index
Constructors
Properties
Methods
Constructors
constructor
Parameters
stateProvider: IStateProvider
Where state is read from and written to.
Returns StateManagementService
Properties
readonlyactualResourceStateFileName
The resource graph as it stands after the last commit.
readonlyexternalResourceStateFileNamePrefix
The prefix of each record an external resource's action writes, until commit folds it into
the resource graph.
readonlyimportStateFileName
The other apps' sealed states the last generate read.
readonlymodelStateFileName
The model graph as it stands after the last commit.
readonlyoldResourceStateFileName
The resource graph as intent described it on the last commit.
readonlystateVersion
The version of the state files this octo writes, and the only one it reads.
Methods
getAppLock
The id of the lock currently held, or
undefinedwhen the app is unlocked.Returns Promise<string | undefined>
getModelState
Reads the model graph. Returns an empty graph when no state exists yet.
Parameters
stateFileName: string
__namedParameters: { freeze?: boolean } = {}
optionalfreeze: boolean = true
Returns Promise<ModelStateFile>
getResourceState
Reads a resource graph. Returns an empty graph when no state exists yet.
Parameters
stateFileName: string
__namedParameters: { freeze?: boolean } = {}
optionalfreeze: boolean = true
Returns Promise<ResourceStateFile>
getSealedState
The model graph and the resource graph of the newest sealed state, both from the one seal. A graph the sealed state does not hold, or all of them when nothing is sealed yet, is empty.
Returns Promise<{ modelState: ModelStateFile; resourceState: ResourceStateFile }>
getState
Reads a state file as-is.
Parameters
stateFileName: string
The file's name in the state provider.
optionaldefaultValue: any
Returned instead of throwing when the file does not exist.
Returns Promise<Buffer<ArrayBufferLike>>
getTemporaryFilePath
A new path where a writer prepares a file. See IStateProvider.getTemporaryFilePath.
Parameters
name: string
Returns Promise<string>
isAppLocked
Whether
lockIdis the lock currently held.Parameters
lockId: string
Returns Promise<boolean>
listStates
The names of the state files whose name starts with
prefix. See IStateProvider.listStates.Parameters
prefix: string
Returns Promise<string[]>
lockApp
Takes the app lock and returns its id. With
lockId, resumes the run already holding it.A new lock is refused while the state holds a journal file of any command but
generate,validateorlock: a run that finished without its journal being archived.Parameters
optionallockId: string
Returns Promise<{ commitId?: string; lockId: string; resumedFrom?: directory | run | sealed }>
refreshState
Brings the state up to the newest a run may plan against. See IStateProvider.refreshState.
Returns Promise<{ commitId?: string; previousCommitId?: string; replaced: boolean }>
saveStates
Writes state files as-is and as one change, moving each one given a
filePathand deleting each one given nodata. Listeners of StateFilesSavingEvent may add files to the change first.Parameters
stateFiles: ({ data: Buffer<ArrayBufferLike> | undefined; stateFileName: string } | { filePath: string; stateFileName: string })[]
Returns Promise<void>
unlockApp
Seals the run and releases the app lock. Unlocking an app that is not locked is not an error.
In order: listeners of AppUnlockingEvent write the last of the run, and a failure there keeps the lock held; the provider seals the run and releases the lock, see IStateProvider.unlockApp.
Parameters
lockId: string
Returns Promise<void>
Reads and writes Octo's state files through the configured IStateProvider.
Resolve it from the Container when you need to inspect what the last run recorded. Octo manages its own state files, so writing through this service is rarely the right move.
Services/State Management