Persistence
Persistence
DataSources provide basic volatile persistence by default. The last 120k events will be stored in memory (~5MB of RAM) and will be queryable.
If you don't know what a DataSource
is, read this guide first
MessageDataSource
s can have their default transport-manager side storage modified by setting the setPersistenceEngineFactory
method on the QueryableMessageIDProvider
.
// template/src/transport-manager/index.tsximport { DataSource , PersistenceEngineMemory ,} from '@electricui/core-timeseries' queryableMessageIDProvider .setPersistenceEngineFactory ( 'speed', (dataSource : DataSource ) => { // Use the in-memory persistence engine with a ceiling of 20k points return new PersistenceEngineMemory (20_000) },)
Note
As the
PersistenceEngineMemory
allocates storage for the message based on the ceiling value per-device, applications which handle frequently changing devices or large meshes should be aware of the memory impact of deep storage pools.
Allocated space = eventSize * maxItems * number of unique devices that have connected
If no persistence is desired, the PersistenceEnginePassthrough
engine can be used which does no buffering.
import { DataSource , PersistenceEnginePassthrough ,} from '@electricui/core-timeseries'// template/src/transport-manager/index.tsx queryableMessageIDProvider .setPersistenceEngineFactory ( 'speed', (dataSource : DataSource ) => { // No storage, events are streamed through the entire system return new PersistenceEnginePassthrough () },)
Custom DataSources
DataSource
s can have their default storage modified by setting the setPersistenceEngineFactory
method on the dataSource itself.
import { DataSource , PersistenceEngineMemory ,} from '@electricui/core-timeseries' const customDataSource = new DataSource ()customDataSource .setPersistenceEngineFactory ( dataSource => new PersistenceEngineMemory (20_000),)