Table of Contents

Class SchemaEvolutionHandler

Namespace
Excalibur.Data.ElasticSearch.Projections
Assembly
Excalibur.Data.ElasticSearch.dll

Handles schema evolution and migrations for Elasticsearch projections.

public sealed class SchemaEvolutionHandler : ISchemaEvolutionHandler, ISchemaEvolutionHandlerAdmin, IDisposable
Inheritance
SchemaEvolutionHandler
Implements
Inherited Members

Constructors

SchemaEvolutionHandler(ElasticsearchClient, IIndexAliasManager, IOptions<ElasticSearchProjectionManagementOptions>, ILogger<SchemaEvolutionHandler>)

Initializes a new instance of the SchemaEvolutionHandler class.

public SchemaEvolutionHandler(ElasticsearchClient client, IIndexAliasManager aliasManager, IOptions<ElasticSearchProjectionManagementOptions> options, ILogger<SchemaEvolutionHandler> logger)

Parameters

client ElasticsearchClient

The Elasticsearch client.

aliasManager IIndexAliasManager

The alias manager for zero-downtime swaps.

options IOptions<ElasticSearchProjectionManagementOptions>

Projection settings.

logger ILogger<SchemaEvolutionHandler>

Logger instance.

Methods

CompareSchemaAsync(string, string, CancellationToken)

Analyzes schema differences between source and target indices.

public Task<SchemaComparisonResult> CompareSchemaAsync(string sourceIndex, string targetIndex, CancellationToken cancellationToken)

Parameters

sourceIndex string

The source index name.

targetIndex string

The target index name or mapping.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaComparisonResult>

A schema comparison result detailing the differences.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

DryRunMigrationAsync(SchemaMigrationPlan, int, CancellationToken)

Performs a dry run of a schema migration without applying changes.

public Task<SchemaMigrationDryRunResult> DryRunMigrationAsync(SchemaMigrationPlan plan, int sampleSize, CancellationToken cancellationToken)

Parameters

plan SchemaMigrationPlan

The migration plan to test.

sampleSize int

The number of documents to test with.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaMigrationDryRunResult>

The dry run results.

ExecuteMigrationAsync(SchemaMigrationPlan, CancellationToken)

Executes a schema migration plan.

public Task<SchemaMigrationResult> ExecuteMigrationAsync(SchemaMigrationPlan plan, CancellationToken cancellationToken)

Parameters

plan SchemaMigrationPlan

The migration plan to execute.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaMigrationResult>

The result of the migration execution.

GetSchemaHistoryAsync(string, CancellationToken)

Gets the schema version history for a projection type.

public Task<SchemaVersionHistory> GetSchemaHistoryAsync(string projectionType, CancellationToken cancellationToken)

Parameters

projectionType string

The projection type.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaVersionHistory>

The version history of the schema.

PlanMigrationAsync(SchemaMigrationRequest, CancellationToken)

Plans a schema migration from one version to another.

public Task<SchemaMigrationPlan> PlanMigrationAsync(SchemaMigrationRequest request, CancellationToken cancellationToken)

Parameters

request SchemaMigrationRequest

The migration planning request.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaMigrationPlan>

A migration plan detailing the steps required.

RegisterSchemaVersionAsync(SchemaVersionRegistration, CancellationToken)

Registers a schema version for tracking.

public Task RegisterSchemaVersionAsync(SchemaVersionRegistration registration, CancellationToken cancellationToken)

Parameters

registration SchemaVersionRegistration

The schema version registration details.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task representing the asynchronous registration operation.

ValidateBackwardsCompatibilityAsync(object, object, CancellationToken)

Validates that a schema change is backwards compatible.

public Task<SchemaCompatibilityResult> ValidateBackwardsCompatibilityAsync(object currentSchema, object newSchema, CancellationToken cancellationToken)

Parameters

currentSchema object

The current schema definition.

newSchema object

The proposed new schema definition.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<SchemaCompatibilityResult>

A validation result indicating compatibility.