Table of Contents

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
object
MetaDataBlockRegistry
Implements

Constructors

MetaDataBlockRegistry(IDataCache?, IOptions<MetaRegistryOptions>)

Initializes a new instance of the MetaDataBlockRegistry.

public MetaDataBlockRegistry(IDataCache? cache, IOptions<MetaRegistryOptions> options)

Parameters

cache IDataCache
options IOptions<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

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

Contains(string)

Checks if a DataBlock with the specified identifier exists.

public bool Contains(string id)

Parameters

id string

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

id string

The unique identifier to check.

cancellationToken CancellationToken

A 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

DataBlockSnapshot

ExportStateAsync(CancellationToken)

Asynchronously exports the entire registry state as a DataBlockSnapshot.

public Task<DataBlockSnapshot> ExportStateAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

A 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

cancellationToken CancellationToken

A 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

cancellationToken CancellationToken

A 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

id string

Returns

DataBlock

GetDataBlockAsync(string, CancellationToken)

Asynchronously retrieves a DataBlock by its identifier.

public Task<DataBlock?> GetDataBlockAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock.

cancellationToken CancellationToken

A 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

id string

Returns

DataBlockMetadata

GetDataBlockMetadataAsync(string, CancellationToken)

Asynchronously retrieves metadata for a DataBlock by its identifier.

public Task<DataBlockMetadata?> GetDataBlockMetadataAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock.

cancellationToken CancellationToken

A 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

DataBlock

GetRegistryStatistics()

Gets registry analytics and statistics.

public DataBlock GetRegistryStatistics()

Returns

DataBlock

ImportState(DataBlockSnapshot)

Imports registry state from a DataBlockSnapshot.

public void ImportState(DataBlockSnapshot snapshot)

Parameters

snapshot DataBlockSnapshot

ImportStateAsync(DataBlockSnapshot, CancellationToken)

Asynchronously imports registry state from a DataBlockSnapshot, replacing current state.

public Task ImportStateAsync(DataBlockSnapshot snapshot, CancellationToken cancellationToken = default)

Parameters

snapshot DataBlockSnapshot

The snapshot to restore from.

cancellationToken CancellationToken

A 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

id string
dataBlock DataBlock
metadata DataBlockMetadata

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

id string

The unique identifier for the DataBlock.

dataBlock DataBlock

The DataBlock instance to register.

metadata DataBlockMetadata

Optional metadata associated with the DataBlock.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task

UnregisterDataBlock(string)

Removes a DataBlock from the registry.

public bool UnregisterDataBlock(string id)

Parameters

id string

Returns

bool

UnregisterDataBlockAsync(string, CancellationToken)

Asynchronously removes a DataBlock from the registry.

public Task<bool> UnregisterDataBlockAsync(string id, CancellationToken cancellationToken = default)

Parameters

id string

The unique identifier of the DataBlock to remove.

cancellationToken CancellationToken

A token to cancel the operation.

Returns

Task<bool>

True if the DataBlock was removed; otherwise, false.