Class MetaDataBlockRegistry
- Namespace
- Datafication.Server.Core.Registry
- Assembly
- Datafication.Server.Core.dll
A meta DataBlock registry that uses a DataBlock to manage DataBlock registrations. This implementation demonstrates the meta-concept of using DataBlock to manage its own state.
public class MetaDataBlockRegistry : ISerializableDataBlockRegistry, IDataBlockRegistry, IDataBlockPersistence, IDataBlockCache, IDataBlockMaintenance, IDataBlockIntrospection
- Inheritance
-
objectMetaDataBlockRegistry
- Implements
Constructors
MetaDataBlockRegistry(IDataCache?, IOptions<MetaRegistryOptions>)
Initializes a new instance of the MetaDataBlockRegistry.
public MetaDataBlockRegistry(IDataCache? cache, IOptions<MetaRegistryOptions> options)
Parameters
cacheIDataCacheoptionsIOptions<MetaRegistryOptions>
Properties
Count
Gets the total number of registered DataBlocks.
public int Count { get; }
Property Value
- int
Methods
ClearCache()
Clears the internal cache.
public void ClearCache()
ClearCacheAsync(CancellationToken)
Asynchronously clears the internal cache without affecting the registry storage.
public Task ClearCacheAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
Contains(string)
Checks if a DataBlock with the specified identifier exists.
public bool Contains(string id)
Parameters
idstring
Returns
- bool
ContainsAsync(string, CancellationToken)
Asynchronously checks if a DataBlock with the specified identifier exists.
public Task<bool> ContainsAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe unique identifier to check.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<bool>
True if the DataBlock exists; otherwise, false.
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
ExportState()
Exports the entire registry state as a DataBlockSnapshot.
public DataBlockSnapshot ExportState()
Returns
ExportStateAsync(CancellationToken)
Asynchronously exports the entire registry state as a DataBlockSnapshot.
public Task<DataBlockSnapshot> ExportStateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<DataBlockSnapshot>
A DataBlockSnapshot containing the complete registry state.
ForceMaintenance()
Forces maintenance to run immediately, cleaning up expired entries.
public void ForceMaintenance()
ForceMaintenanceAsync(CancellationToken)
Asynchronously forces maintenance to run immediately, cleaning up expired entries.
public Task ForceMaintenanceAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
GetAllDataBlockIds()
Gets all registered DataBlock identifiers.
public IEnumerable<string> GetAllDataBlockIds()
Returns
- IEnumerable<string>
GetAllDataBlockIdsAsync(CancellationToken)
Asynchronously gets all registered DataBlock identifiers.
public Task<IEnumerable<string>> GetAllDataBlockIdsAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<IEnumerable<string>>
A collection of all registered DataBlock identifiers.
GetDataBlock(string)
Retrieves a DataBlock by its identifier.
public DataBlock? GetDataBlock(string id)
Parameters
idstring
Returns
GetDataBlockAsync(string, CancellationToken)
Asynchronously retrieves a DataBlock by its identifier.
public Task<DataBlock?> GetDataBlockAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe unique identifier of the DataBlock.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<DataBlock>
The DataBlock instance if found; otherwise, null.
GetDataBlockMetadata(string)
Retrieves metadata for a DataBlock by its identifier.
public DataBlockMetadata? GetDataBlockMetadata(string id)
Parameters
idstring
Returns
GetDataBlockMetadataAsync(string, CancellationToken)
Asynchronously retrieves metadata for a DataBlock by its identifier.
public Task<DataBlockMetadata?> GetDataBlockMetadataAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe unique identifier of the DataBlock.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<DataBlockMetadata>
The metadata for the DataBlock if found; otherwise, null.
GetRegistryAsDataBlock()
Gets the registry itself as a queryable DataBlock.
public DataBlock GetRegistryAsDataBlock()
Returns
GetRegistryStatistics()
Gets registry analytics and statistics.
public DataBlock GetRegistryStatistics()
Returns
ImportState(DataBlockSnapshot)
Imports registry state from a DataBlockSnapshot.
public void ImportState(DataBlockSnapshot snapshot)
Parameters
snapshotDataBlockSnapshot
ImportStateAsync(DataBlockSnapshot, CancellationToken)
Asynchronously imports registry state from a DataBlockSnapshot, replacing current state.
public Task ImportStateAsync(DataBlockSnapshot snapshot, CancellationToken cancellationToken = default)
Parameters
snapshotDataBlockSnapshotThe snapshot to restore from.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
RegisterDataBlock(string, DataBlock, DataBlockMetadata?)
Registers a DataBlock with the specified identifier.
public void RegisterDataBlock(string id, DataBlock dataBlock, DataBlockMetadata? metadata = null)
Parameters
idstringdataBlockDataBlockmetadataDataBlockMetadata
RegisterDataBlockAsync(string, DataBlock, DataBlockMetadata?, CancellationToken)
Asynchronously registers a DataBlock with the specified identifier.
public Task RegisterDataBlockAsync(string id, DataBlock dataBlock, DataBlockMetadata? metadata = null, CancellationToken cancellationToken = default)
Parameters
idstringThe unique identifier for the DataBlock.
dataBlockDataBlockThe DataBlock instance to register.
metadataDataBlockMetadataOptional metadata associated with the DataBlock.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task
UnregisterDataBlock(string)
Removes a DataBlock from the registry.
public bool UnregisterDataBlock(string id)
Parameters
idstring
Returns
- bool
UnregisterDataBlockAsync(string, CancellationToken)
Asynchronously removes a DataBlock from the registry.
public Task<bool> UnregisterDataBlockAsync(string id, CancellationToken cancellationToken = default)
Parameters
idstringThe unique identifier of the DataBlock to remove.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<bool>
True if the DataBlock was removed; otherwise, false.