LocalStateProvider
Implements
Index
Constructors
constructor
Parameters
localStateDirectoryPath: string
The directory state files are written into.
Returns LocalStateProvider
Methods
getAppLock
The id of the lock currently held, or
undefinedwhen the app is unlocked.Returns Promise<string | undefined>
getSealedStates
Reads state files from the newest archive, found by the time at the start of its commit id. Only one lock is held at a time, so the last lock taken is the last run sealed.
Parameters
stateFileNames: string[]
Returns Promise<(Buffer<ArrayBufferLike> | undefined)[]>
getState
Reads a state file.
Parameters
stateFileName: string
Returns Promise<Buffer<ArrayBufferLike>>
getTemporaryFilePath
A new path beside the state files, named
.<name>.<random>.tmp.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.Parameters
prefix: string
Returns Promise<string[]>
lockApp
Takes the app lock, writing its id, its commit and the time it was taken into
local-state.lockbeside the state files. WithlockId, resumes the run already holding it. The lock never expires.Parameters
lock: { commitId: string } | { lockId: string }
commitId: string
lockId: string
Returns Promise<{ commitId: string; lockId: string }>
refreshState
Does nothing: the directory is the only copy of the state, so it is always the newest.
Returns Promise<{ replaced: boolean }>
saveStates
Writes state files, overwriting whatever was there, moving each one given a
filePath, and deleting each one given nodata.Each file is written under a temporary name and renamed into place, so a process killed mid-write leaves the file whole, and a reader holding it through a hard link keeps what it holds.
Parameters
stateFiles: ({ data: Buffer<ArrayBufferLike> | undefined; stateFileName: string } | { filePath: string; stateFileName: string })[]
Returns Promise<void>
unlockApp
Seals the run with LocalStateProvider.archiveState, then releases the app lock by deleting the lock file. A run that cannot be archived keeps the lock held.
Parameters
lockId: string
Returns Promise<void>
Keeps state in a directory on the local filesystem.
Good for experimenting on your own machine. It is not shared, so a team running Octo against the same infrastructure needs a provider that persists somewhere they all reach.
Releasing the lock seals the run into
archives/<commitId>/, the newest of which is the sealed state. Deleting old archives is up to you.Services/State Management
Techniques for State Providers.