TestStateProvider
Implements
Index
Constructors
constructor
Returns TestStateProvider
Methods
getAppLock
The id of the lock currently held, or
undefinedwhen the app is unlocked.Returns Promise<string | undefined>
getSealedStates
Reads state files. Nothing is sealed here, so the state itself stands in for the sealed state.
Parameters
stateFileNames: string[]
Returns Promise<(Buffer<ArrayBufferLike> | undefined)[]>
getState
Reads a state file.
Parameters
stateFileName: string
Returns Promise<Buffer<ArrayBufferLike>>
getTemporaryFilePath
A new path in the system's temporary directory, since the state holds no files.
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. With
lockId, resumes the run already holding it.Parameters
lock: { commitId: string } | { lockId: string }
commitId: string
lockId: string
Returns Promise<{ commitId?: string; lockId: string; resumedFrom?: directory | run | sealed }>
refreshState
Does nothing: the state lives in this process alone, so it is always the newest.
Returns Promise<{ replaced: boolean }>
saveStates
Writes state files, overwriting whatever was there, moving each one given a
filePathinto memory, and deleting each one given nodata.Parameters
stateFiles: ({ data: Buffer<ArrayBufferLike> | undefined; stateFileName: string } | { filePath: string; stateFileName: string })[]
Returns Promise<void>
unlockApp
Clears the journal, which a run that follows would refuse to lock over, and releases the app lock.
Parameters
lockId: string
Returns Promise<void>
Keeps state in memory, and discards it when the process ends. For tests.
Services/State Management
Techniques for State Providers.