Class: MemoryEntityStorageConnector<T>
Class for performing entity storage operations in-memory backed by a shared object buffer.
All reads and writes are serialised with a per-schema lock so that concurrent async access, including across worker threads, never produces torn or lost updates.
All connector instances that share the same entity schema name share the same underlying buffer, making data written in one instance immediately visible in another, including across worker threads when the main thread forwards worker messages to the lock and buffer handlers.
Type Parameters
T
T = unknown
Implements
IEntityStorageConnector<T>IEntityStorageMigrationConnector<T>IHealthProviderComponent
Constructors
Constructor
new MemoryEntityStorageConnector<
T>(options):MemoryEntityStorageConnector<T>
Create a new instance of MemoryEntityStorageConnector.
Parameters
options
IMemoryEntityStorageConnectorConstructorOptions
The options for the connector.
Returns
MemoryEntityStorageConnector<T>
Properties
CLASS_NAME
readonlystaticCLASS_NAME:string
Runtime name for the class.
Methods
className()
className():
string
Returns the class name of the component.
Returns
string
The class name of the component.
Implementation of
IEntityStorageConnector.className
health()
health():
Promise<IHealth[]>
Returns the health status of the component.
Returns
Promise<IHealth[]>
The health status of the component.
Implementation of
IHealthProviderComponent.health
getSchema()
getSchema():
IEntitySchema
Get the schema for the entities.
Returns
IEntitySchema
The schema for the entities.
Implementation of
IEntityStorageConnector.getSchema
bootstrap()
bootstrap(
nodeLoggingComponentType?):Promise<boolean>
Bootstrap the component by creating and initializing any resources it needs.
Parameters
nodeLoggingComponentType?
string
The node logging component type.
Returns
Promise<boolean>
True if the bootstrapping process was successful.
Implementation of
IEntityStorageConnector.bootstrap
get()
get(
id,secondaryIndex?,conditions?):Promise<T|undefined>
Get an entity.
Parameters
id
string
The id of the entity to get, or the index value if secondaryIndex is set.
secondaryIndex?
keyof T
Get the item using a secondary index.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<T | undefined>
The object if it can be found or undefined.
Implementation of
IEntityStorageConnector.get
set()
set(
entity,conditions?):Promise<void>
Set an entity.
Parameters
entity
T
The entity to set.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
Resolves when the entity has been stored.
Throws
ConflictError when the entity exists but the supplied conditions or version do not match the stored state.
Implementation of
IEntityStorageConnector.set
setBatch()
setBatch(
entities):Promise<void>
Set multiple entities in a batch.
Parameters
entities
T[]
The entities to set.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.setBatch
remove()
remove(
id,conditions?):Promise<void>
Remove the entity.
Parameters
id
string
The id of the entity to remove.
conditions?
object[]
The optional conditions to match for the entities.
Returns
Promise<void>
Nothing.
Throws
ConflictError when the entity exists but the supplied conditions do not match the stored state.
Implementation of
IEntityStorageConnector.remove
query()
query(
conditions?,sortProperties?,properties?,cursor?,limit?):Promise<{entities:Partial<T>[];cursor?:string; }>
Find all the entities which match the conditions.
Parameters
conditions?
EntityCondition<T>
The conditions to match for the entities.
sortProperties?
object[]
The optional sort order.
properties?
keyof T[]
The optional properties to return, defaults to all.
cursor?
string
The cursor to request the next chunk of entities.
limit?
number
The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
Returns
Promise<{ entities: Partial<T>[]; cursor?: string; }>
All the entities for the storage matching the conditions, and a cursor which can be used to request more entities.
Implementation of
IEntityStorageConnector.query
queryJoin()
queryJoin<
U>(joinConnector,joinOptions):Promise<{entities:Partial<T> &object[];cursor?:string; }>
Find all the entities which match the conditions, attaching to each one the entities from a second storage connector whose join property matches. The join behaves like a left join by default, a primary entity with no matches is still returned with an empty joined list, unless joinRequired asks for an inner join and those entities are left out altogether.
Type Parameters
U
U
Parameters
joinConnector
IEntityStorageConnector<U>
The connector holding the entities to join to.
joinOptions
IEntityStorageJoinOptions<T, U>
The properties to join on, the conditions, sort order, projection and paging for the primary entities, the optional grouping and group conditions, and the optional conditions, sort order and projection for the joined entities.
Returns
Promise<{ entities: Partial<T> & object[]; cursor?: string; }>
All the entities for the storage matching the conditions with their joined entities, and a cursor which can be used to request more entities.
Implementation of
IEntityStorageConnector.queryJoin
empty()
empty():
Promise<void>
Remove all entities from the storage.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.empty
removeBatch()
removeBatch(
ids):Promise<void>
Remove multiple entities by id.
Parameters
ids
string[]
The ids of the entities to remove.
Returns
Promise<void>
Nothing.
Implementation of
IEntityStorageConnector.removeBatch
teardown()
teardown(
nodeLoggingComponentType?):Promise<boolean>
Teardown the storage by clearing the underlying shared buffer for this schema.
Parameters
nodeLoggingComponentType?
string
The node logging component type.
Returns
Promise<boolean>
True if the teardown process was successful.
Implementation of
IEntityStorageConnector.teardown
count()
count(
conditions?):Promise<number>
Count all the entities which match the conditions.
Parameters
conditions?
EntityCondition<T>
The optional conditions to match for the entities.
Returns
Promise<number>
The total count of entities in the storage.
Implementation of
IEntityStorageConnector.count
getStore()
getStore():
Promise<T[]>
Get all entities in the memory store.
Returns
Promise<T[]>
All stored entities with partition keys removed.
connectorVersion()
connectorVersion():
number
Get the connector implementation version.
Returns
number
The connector implementation version.
Implementation of
IEntityStorageMigrationConnector.connectorVersion
getPartitionContextIds()
getPartitionContextIds(
loggingComponentType?):Promise<IContextIds[] |undefined>
Get a unique list of all the context ids from the storage.
Parameters
loggingComponentType?
string
The optional component type to use for logging skipped partition ids.
Returns
Promise<IContextIds[] | undefined>
The list of unique context ids.
Implementation of
IEntityStorageMigrationConnector.getPartitionContextIds
createTargetConnector()
createTargetConnector<
U>(newEntitySchema):Promise<IEntityStorageConnector<U>>
Create the target connector for performing the migration it will use a temporary storage location.
Type Parameters
U
U
Parameters
newEntitySchema
string
The name of the new entity schema to create the connector for.
Returns
Promise<IEntityStorageConnector<U>>
Connector for performing the migration.
Implementation of
IEntityStorageMigrationConnector.createTargetConnector
finalizeMigration()
finalizeMigration<
U>(targetConnector,options?,loggingComponentType?):Promise<IEntityStorageConnector<U>>
Finalize the migration by tearing down the old connector and replacing it with the target connector.
Type Parameters
U
U
Parameters
targetConnector
IEntityStorageConnector<U>
The target connector to finalize the migration with.
options?
IMigrationOptions
The options to control how the migration is finalized.
loggingComponentType?
string
The optional component type to use for logging the migration progress.
Returns
Promise<IEntityStorageConnector<U>>
A promise that resolves when the migration is finalized.
Implementation of
IEntityStorageMigrationConnector.finalizeMigration
cleanupMigration()
cleanupMigration<
U>(targetConnector,options?,loggingComponentType?):Promise<void>
Cleanup the migration if a migration fails or needs to be aborted.
Type Parameters
U
U
Parameters
targetConnector
IEntityStorageConnector<U> | undefined
The target connector to cleanup the migration with.
options?
IMigrationOptions
The options to control how the migration is cleaned up.
loggingComponentType?
string
The optional component type to use for logging the migration progress.
Returns
Promise<void>
A promise that resolves when the migration is cleaned up.
Implementation of
IEntityStorageMigrationConnector.cleanupMigration