Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Or 1349 restart #611

Merged
merged 2 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public PublicProjectionHostHttpClient(HttpClient httpClient)
_httpClient = httpClient;
}

public async Task<HttpResponseMessage> RebuildAllProjections(CancellationToken cancellationToken)
=> await _httpClient.PostAsync(requestUri: "/v1/projections/all/rebuild", content: null, cancellationToken);
public async Task<HttpResponseMessage> RebuildDetailProjection(CancellationToken cancellationToken)
=> await _httpClient.PostAsync(requestUri: "/v1/projections/detail/rebuild", content: null, cancellationToken);

Expand All @@ -27,4 +29,6 @@ public void Dispose()
{
_httpClient.Dispose();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ public async Task<IActionResult> GetAdminProjectionStatus(CancellationToken canc
return await OkObjectOrForwardedResponse(cancellationToken, response);
}

[HttpPost("public/all/rebuild")]
public async Task<IActionResult> RebuildPublicAllProjections(CancellationToken cancellationToken)
{
var response = await _publicHttpClient.RebuildAllProjections(cancellationToken);

return await OkOrForwardedResponse(cancellationToken, response);
}

[HttpPost("public/detail/rebuild")]
public async Task<IActionResult> RebuildPublicProjectionDetail(CancellationToken cancellationToken)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,7 @@ private static async Task RebuildElasticProjections(
{
await elasticClient.Indices.DeleteAsync(indeces, ct: CancellationToken.None).ThrowIfInvalidAsync();
}

await projectionDaemon.StartShard($"{ProjectionNames.VerenigingZoeken}:All", CancellationToken.None);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,43 @@
{
var shardTimeout = TimeSpan.FromMinutes(configurationSection.TimeoutInMinutes);

app.MapPost(
pattern: "v1/projections/all/rebuild",
handler: async (
IDocumentStore store,
IElasticClient elasticClient,
ElasticSearchOptionsSection options,
ILogger<Program> logger) =>
{
StartRebuild(logger, projectionName: "Detail", rebuildFunc: async () =>
{
var projectionDaemon = await store.BuildProjectionDaemonAsync();
await projectionDaemon.RebuildProjection<PubliekVerenigingDetailProjection>(shardTimeout, CancellationToken.None);
});

StartRebuild(logger, projectionName: "Search", rebuildFunc: async () =>
{
var projectionDaemon = await store.BuildProjectionDaemonAsync();
await projectionDaemon.StopShard($"{ProjectionNames.VerenigingZoeken}:All");

await elasticClient.Indices.DeleteAsync(options.Indices.Verenigingen, ct: CancellationToken.None);

Check warning on line 35 in src/AssociationRegistry.Public.ProjectionHost/Extensions/ProjectionEndpointsExtensions.cs

View workflow job for this annotation

GitHub Actions / Run Tests (test/AssociationRegistry.Test.Admin.Api)

Dereference of a possibly null reference.
await elasticClient.Indices.CreateVerenigingIndexAsync(options.Indices.Verenigingen);

await projectionDaemon.RebuildProjection(ProjectionNames.VerenigingZoeken, shardTimeout, CancellationToken.None);
await projectionDaemon.StartShard($"{ProjectionNames.VerenigingZoeken}:All", CancellationToken.None);
});

return Results.Accepted();
});

app.MapPost(
pattern: "v1/projections/detail/rebuild",
handler: async (IDocumentStore store, ILogger<Program> logger) =>
{
StartRebuild(logger, projectionName: "Detail", rebuildFunc: async () =>
{
var projectionDaemon = await store.BuildProjectionDaemonAsync();
await projectionDaemon.RebuildProjection<PubliekVerenigingDetailProjection>(shardTimeout,CancellationToken.None);
await projectionDaemon.RebuildProjection<PubliekVerenigingDetailProjection>(shardTimeout, CancellationToken.None);
});

return Results.Accepted();
Expand All @@ -42,7 +71,8 @@
await elasticClient.Indices.DeleteAsync(options.Indices.Verenigingen, ct: CancellationToken.None);
await elasticClient.Indices.CreateVerenigingIndexAsync(options.Indices.Verenigingen);

await projectionDaemon.RebuildProjection(ProjectionNames.VerenigingZoeken,shardTimeout, CancellationToken.None);
await projectionDaemon.RebuildProjection(ProjectionNames.VerenigingZoeken, shardTimeout, CancellationToken.None);
await projectionDaemon.StartShard($"{ProjectionNames.VerenigingZoeken}:All", CancellationToken.None);
});

return Results.Accepted();
Expand Down
Loading