Skip to content

Commit 7c32cc6

Browse files
MpdreamzCopilot
andauthored
Merge docs-assembler commands into docs-builder (#1931)
* Reorganize into services that can be more easily shared * Ensure uncaught exceptions get reported as errors on diagnosticscollector summaries * Moved all commands over * DetermineWorkingDirectoryRoot never considered solution root. This caused running commands in the IDE to use an .artifacts folder under bin/ folders. * build and clone should return true if no errors. ServiceInvoker caught them returning false without emitting errors so thats good. * Silence noisy bloom filter service command now that it logs using ILogger * Move docs-builder commands to services too * update Aspire to use `assembler serve` * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> * Update src/tooling/Elastic.Documentation.Tooling/Filters/CatchExceptionFilter.cs Co-authored-by: Copilot <[email protected]> * Move Aspire over to docs-builder assembler completely * Add explicit support for git worktrees --------- Co-authored-by: Copilot <[email protected]>
1 parent c295d10 commit 7c32cc6

File tree

106 files changed

+2177
-1187
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2177
-1187
lines changed

Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@
9797
</PackageVersion>
9898
<PackageVersion Include="xunit.v3" Version="2.0.2" />
9999
</ItemGroup>
100-
</Project>
100+
</Project>

aspire/AppHost.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
4040
var elasticsearchUrl = builder.AddParameter("DocumentationElasticUrl", secret: true);
4141
var elasticsearchApiKey = builder.AddParameter("DocumentationElasticApiKey", secret: true);
4242

43-
var cloneAll = builder.AddProject<Projects.docs_assembler>(AssemblerClone);
43+
var cloneAll = builder.AddProject<Projects.docs_builder>(AssemblerClone);
4444
string[] cloneArgs = assumeCloned ? ["--assume-cloned"] : [];
45-
cloneAll = cloneAll.WithArgs(["repo", "clone-all", .. globalArguments, .. cloneArgs]);
45+
cloneAll = cloneAll.WithArgs(["assembler", "clone", .. globalArguments, .. cloneArgs]);
4646

47-
var buildAll = builder.AddProject<Projects.docs_assembler>(AssemblerBuild)
48-
.WithArgs(["repo", "build-all", .. globalArguments])
47+
var buildAll = builder.AddProject<Projects.docs_builder>(AssemblerBuild)
48+
.WithArgs(["assembler", "build", .. globalArguments])
4949
.WaitForCompletion(cloneAll)
5050
.WithParentRelationship(cloneAll);
5151

@@ -74,8 +74,8 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
7474
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearchUrl)
7575
.WithEnvironment("DOCUMENTATION_ELASTIC_APIKEY", elasticsearchApiKey);
7676

77-
var indexElasticsearch = builder.AddProject<Projects.docs_assembler>(ElasticsearchIndexerPlain)
78-
.WithArgs(["repo", "build-all", "--exporters", "elasticsearch", .. globalArguments])
77+
var indexElasticsearch = builder.AddProject<Projects.docs_builder>(ElasticsearchIndexerPlain)
78+
.WithArgs(["assembler", "build", "--exporters", "elasticsearch", .. globalArguments])
7979
.WithExplicitStart()
8080
.WaitForCompletion(cloneAll);
8181
indexElasticsearch = startElasticsearch
@@ -91,8 +91,8 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
9191
.WithEnvironment("DOCUMENTATION_ELASTIC_APIKEY", elasticsearchApiKey)
9292
.WithParentRelationship(elasticsearchRemote);
9393

94-
var indexElasticsearchSemantic = builder.AddProject<Projects.docs_assembler>(ElasticsearchIndexerSemantic)
95-
.WithArgs(["repo", "build-all", "--exporters", "semantic", .. globalArguments])
94+
var indexElasticsearchSemantic = builder.AddProject<Projects.docs_builder>(ElasticsearchIndexerSemantic)
95+
.WithArgs(["assembler", "build", "--exporters", "semantic", .. globalArguments])
9696
.WithEnvironment("DOCUMENTATION_ELASTIC_URL", elasticsearchLocal.GetEndpoint("http"))
9797
.WithEnvironment(context => context.EnvironmentVariables["DOCUMENTATION_ELASTIC_PASSWORD"] = elasticsearchLocal.Resource.PasswordParameter)
9898
.WithExplicitStart()
@@ -114,7 +114,7 @@ async Task BuildAspireHost(bool startElasticsearch, bool assumeCloned, bool skip
114114
.WithEnvironment("LLM_GATEWAY_FUNCTION_URL", llmUrl)
115115
.WithEnvironment("LLM_GATEWAY_SERVICE_ACCOUNT_KEY_PATH", llmServiceAccountPath)
116116
.WithHttpEndpoint(port: 4000, isProxied: false)
117-
.WithArgs(["serve-static", .. globalArguments])
117+
.WithArgs(["assembler", "serve", .. globalArguments])
118118
.WithHttpHealthCheck("/", 200)
119119
.WaitForCompletion(buildAll)
120120
.WithParentRelationship(cloneAll);

docs-builder.sln

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "diff-validate", "diff-valid
147147
actions\diff-validate\action.yml = actions\diff-validate\action.yml
148148
EndProjectSection
149149
EndProject
150+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "services", "services", "{7AACA67B-3C56-4C7C-9891-558589FC52DB}"
151+
EndProject
152+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Assembler", "src\services\Elastic.Documentation.Assembler\Elastic.Documentation.Assembler.csproj", "{094433A4-504F-4E12-959F-CCB1965C1C9A}"
153+
EndProject
154+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Services", "src\services\Elastic.Documentation.Services\Elastic.Documentation.Services.csproj", "{E6EA955D-D0A7-4749-9586-0F7256EF5C5E}"
155+
EndProject
156+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Links", "src\Elastic.Documentation.Links\Elastic.Documentation.Links.csproj", "{153FC4AD-F5B0-4100-990E-0987C86DBF01}"
157+
EndProject
158+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elastic.Documentation.Isolated", "src\services\Elastic.Documentation.Isolated\Elastic.Documentation.Isolated.csproj", "{AABD3EF7-8C86-4981-B1D2-B1F786F33069}"
159+
EndProject
150160
Global
151161
GlobalSection(SolutionConfigurationPlatforms) = preSolution
152162
Debug|Any CPU = Debug|Any CPU
@@ -256,6 +266,22 @@ Global
256266
{C6A121C5-DEB1-4FCE-9140-AF144EA98EEE}.Debug|Any CPU.Build.0 = Debug|Any CPU
257267
{C6A121C5-DEB1-4FCE-9140-AF144EA98EEE}.Release|Any CPU.ActiveCfg = Release|Any CPU
258268
{C6A121C5-DEB1-4FCE-9140-AF144EA98EEE}.Release|Any CPU.Build.0 = Release|Any CPU
269+
{094433A4-504F-4E12-959F-CCB1965C1C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
270+
{094433A4-504F-4E12-959F-CCB1965C1C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU
271+
{094433A4-504F-4E12-959F-CCB1965C1C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU
272+
{094433A4-504F-4E12-959F-CCB1965C1C9A}.Release|Any CPU.Build.0 = Release|Any CPU
273+
{E6EA955D-D0A7-4749-9586-0F7256EF5C5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
274+
{E6EA955D-D0A7-4749-9586-0F7256EF5C5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
275+
{E6EA955D-D0A7-4749-9586-0F7256EF5C5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
276+
{E6EA955D-D0A7-4749-9586-0F7256EF5C5E}.Release|Any CPU.Build.0 = Release|Any CPU
277+
{153FC4AD-F5B0-4100-990E-0987C86DBF01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
278+
{153FC4AD-F5B0-4100-990E-0987C86DBF01}.Debug|Any CPU.Build.0 = Debug|Any CPU
279+
{153FC4AD-F5B0-4100-990E-0987C86DBF01}.Release|Any CPU.ActiveCfg = Release|Any CPU
280+
{153FC4AD-F5B0-4100-990E-0987C86DBF01}.Release|Any CPU.Build.0 = Release|Any CPU
281+
{AABD3EF7-8C86-4981-B1D2-B1F786F33069}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
282+
{AABD3EF7-8C86-4981-B1D2-B1F786F33069}.Debug|Any CPU.Build.0 = Debug|Any CPU
283+
{AABD3EF7-8C86-4981-B1D2-B1F786F33069}.Release|Any CPU.ActiveCfg = Release|Any CPU
284+
{AABD3EF7-8C86-4981-B1D2-B1F786F33069}.Release|Any CPU.Build.0 = Release|Any CPU
259285
EndGlobalSection
260286
GlobalSection(NestedProjects) = preSolution
261287
{4D198E25-C211-41DC-9E84-B15E89BD7048} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
@@ -293,5 +319,10 @@ Global
293319
{AE3FC78E-167F-4B6E-88EC-84743EB748B7} = {B042CC78-5060-4091-B95A-79C71BA3908A}
294320
{C6A121C5-DEB1-4FCE-9140-AF144EA98EEE} = {B042CC78-5060-4091-B95A-79C71BA3908A}
295321
{E7C7A02B-9AB4-455A-9A64-3D326ED1A95A} = {245023D2-D3CA-47B9-831D-DAB91A2FFDC7}
322+
{7AACA67B-3C56-4C7C-9891-558589FC52DB} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
323+
{094433A4-504F-4E12-959F-CCB1965C1C9A} = {7AACA67B-3C56-4C7C-9891-558589FC52DB}
324+
{E6EA955D-D0A7-4749-9586-0F7256EF5C5E} = {7AACA67B-3C56-4C7C-9891-558589FC52DB}
325+
{153FC4AD-F5B0-4100-990E-0987C86DBF01} = {BE6011CC-1200-4957-B01F-FCCA10C5CF5A}
326+
{AABD3EF7-8C86-4981-B1D2-B1F786F33069} = {7AACA67B-3C56-4C7C-9891-558589FC52DB}
296327
EndGlobalSection
297328
EndGlobal

src/tooling/docs-assembler/Navigation/GlobalNavigationFile.cs renamed to src/Elastic.Documentation.Configuration/Navigation/GlobalNavigationFile.cs

Lines changed: 73 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,75 @@
22
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
33
// See the LICENSE file in the project root for more information
44

5+
using System.Collections.Frozen;
56
using System.Collections.Immutable;
67
using System.IO.Abstractions;
7-
using Elastic.Documentation;
8-
using Elastic.Documentation.Configuration;
98
using Elastic.Documentation.Configuration.Assembler;
9+
using Elastic.Documentation.Configuration.Builder;
1010
using Elastic.Documentation.Configuration.TableOfContents;
11+
using Elastic.Documentation.Diagnostics;
1112
using Elastic.Documentation.Navigation;
1213
using YamlDotNet.RepresentationModel;
1314

14-
namespace Documentation.Assembler.Navigation;
15+
namespace Elastic.Documentation.Configuration.Navigation;
16+
17+
public record NavigationTocMapping
18+
{
19+
public required Uri Source { get; init; }
20+
public required string SourcePathPrefix { get; init; }
21+
public required Uri TopLevelSource { get; init; }
22+
public required Uri ParentSource { get; init; }
23+
}
24+
25+
public record TocConfigurationMapping
26+
{
27+
public required NavigationTocMapping TopLevel { get; init; }
28+
public required ConfigurationFile RepositoryConfigurationFile { get; init; }
29+
public required TableOfContentsConfiguration TableOfContentsConfiguration { get; init; }
30+
}
1531

1632
public record GlobalNavigationFile : ITableOfContentsScope
1733
{
18-
private readonly AssembleContext _context;
19-
private readonly AssembleSources _assembleSources;
34+
//private readonly AssembleContext _context;
35+
private readonly IDiagnosticsCollector _collector;
36+
private readonly ConfigurationFileProvider _configurationFileProvider;
37+
private readonly AssemblyConfiguration _configuration;
38+
39+
private readonly FrozenDictionary<Uri, TocConfigurationMapping> _tocConfigurationMappings;
40+
//private readonly AssembleSources _assembleSources;
2041

2142
public IReadOnlyCollection<TocReference> TableOfContents { get; }
2243
public IReadOnlyCollection<TocReference> Phantoms { get; }
2344

2445
public IDirectoryInfo ScopeDirectory { get; }
2546

26-
public GlobalNavigationFile(AssembleContext context, AssembleSources assembleSources)
47+
public GlobalNavigationFile(
48+
IDiagnosticsCollector collector,
49+
ConfigurationFileProvider configurationFileProvider,
50+
AssemblyConfiguration configuration,
51+
FrozenDictionary<Uri, TocConfigurationMapping> tocConfigurationMappings
52+
)
2753
{
28-
_context = context;
29-
_assembleSources = assembleSources;
30-
NavigationFile = context.ConfigurationFileProvider.CreateNavigationFile(context.Configuration);
54+
//_context = context;
55+
_collector = collector;
56+
_configurationFileProvider = configurationFileProvider;
57+
_configuration = configuration;
58+
_tocConfigurationMappings = tocConfigurationMappings;
59+
NavigationFile = configurationFileProvider.CreateNavigationFile(configuration);
3160
TableOfContents = Deserialize("toc");
3261
Phantoms = Deserialize("phantoms");
3362
ScopeDirectory = NavigationFile.Directory!;
3463
}
3564

3665
private IFileInfo NavigationFile { get; }
3766

38-
public static bool ValidatePathPrefixes(AssembleContext context)
67+
public static bool ValidatePathPrefixes(
68+
IDiagnosticsCollector collector,
69+
ConfigurationFileProvider configurationFileProvider,
70+
AssemblyConfiguration configuration
71+
)
3972
{
40-
var fileProvider = context.ConfigurationFileProvider;
41-
var sourcePathPrefixes = GetAllPathPrefixes(context);
73+
var sourcePathPrefixes = GetAllPathPrefixes(collector, configurationFileProvider, configuration);
4274
var pathPrefixSet = new HashSet<string>();
4375
var valid = true;
4476
foreach (var pathPrefix in sourcePathPrefixes)
@@ -47,23 +79,36 @@ public static bool ValidatePathPrefixes(AssembleContext context)
4779
if (pathPrefixSet.Add(prefix))
4880
continue;
4981
var duplicateOf = sourcePathPrefixes.First(p => p.Host == pathPrefix.Host && p.AbsolutePath == pathPrefix.AbsolutePath);
50-
context.Collector.EmitError(fileProvider.NavigationFile, $"Duplicate path prefix: {pathPrefix} duplicate: {duplicateOf}");
82+
collector.EmitError(configurationFileProvider.NavigationFile, $"Duplicate path prefix: {pathPrefix} duplicate: {duplicateOf}");
5183
valid = false;
5284
}
5385
return valid;
5486
}
5587

5688

57-
public static ImmutableHashSet<Uri> GetAllPathPrefixes(AssembleContext context) =>
58-
GetSourceUris("toc", context);
59-
60-
public static ImmutableHashSet<Uri> GetPhantomPrefixes(AssembleContext context) =>
61-
GetSourceUris("phantoms", context);
62-
63-
private static ImmutableHashSet<Uri> GetSourceUris(string key, AssembleContext context)
89+
public static ImmutableHashSet<Uri> GetAllPathPrefixes(
90+
IDiagnosticsCollector collector,
91+
ConfigurationFileProvider configurationFileProvider,
92+
AssemblyConfiguration configuration
93+
) =>
94+
GetSourceUris("toc", collector, configurationFileProvider, configuration);
95+
96+
public static ImmutableHashSet<Uri> GetPhantomPrefixes(
97+
IDiagnosticsCollector collector,
98+
ConfigurationFileProvider configurationFileProvider,
99+
AssemblyConfiguration configuration
100+
) =>
101+
GetSourceUris("phantoms", collector, configurationFileProvider, configuration);
102+
103+
private static ImmutableHashSet<Uri> GetSourceUris(
104+
string key,
105+
IDiagnosticsCollector collector,
106+
ConfigurationFileProvider configurationFileProvider,
107+
AssemblyConfiguration configuration
108+
)
64109
{
65-
var navigationFile = context.ConfigurationFileProvider.CreateNavigationFile(context.Configuration);
66-
var reader = new YamlStreamReader(navigationFile, context.Collector);
110+
var navigationFile = configurationFileProvider.CreateNavigationFile(configuration);
111+
var reader = new YamlStreamReader(navigationFile, collector);
67112
var set = new HashSet<Uri>();
68113
foreach (var entry in reader.Read())
69114
{
@@ -145,15 +190,15 @@ static void ReadPathPrefixes(YamlStreamReader reader, KeyValuePair<YamlNode, Yam
145190
}
146191
}
147192
public void EmitWarning(string message) =>
148-
_context.Collector.EmitWarning(NavigationFile, message);
193+
_collector.EmitWarning(NavigationFile, message);
149194

150195
public void EmitError(string message) =>
151-
_context.Collector.EmitError(NavigationFile, message);
196+
_collector.EmitError(NavigationFile, message);
152197

153198
private IReadOnlyCollection<TocReference> Deserialize(string key)
154199
{
155-
var navigationFile = _context.ConfigurationFileProvider.CreateNavigationFile(_context.Configuration);
156-
var reader = new YamlStreamReader(navigationFile, _context.Collector);
200+
var navigationFile = _configurationFileProvider.CreateNavigationFile(_configuration);
201+
var reader = new YamlStreamReader(navigationFile, _collector);
157202
try
158203
{
159204
foreach (var entry in reader.Read())
@@ -232,7 +277,7 @@ private IReadOnlyCollection<TocReference> ReadChildren(string key, YamlStreamRea
232277
return null;
233278

234279

235-
if (!_assembleSources.TocConfigurationMapping.TryGetValue(sourceUri, out var mapping))
280+
if (!_tocConfigurationMappings.TryGetValue(sourceUri, out var mapping))
236281
{
237282
reader.EmitError($"Toc entry '{sourceUri}' is could not be located", tocEntry);
238283
return null;
@@ -270,7 +315,7 @@ private IReadOnlyCollection<TocReference> ReadChildren(string key, YamlStreamRea
270315
if (source is null)
271316
return pathPrefix;
272317

273-
source = source.EndsWith("://") ? source : source.TrimEnd('/') + "/";
318+
source = source.EndsWith("://", StringComparison.OrdinalIgnoreCase) ? source : source.TrimEnd('/') + "/";
274319
if (!Uri.TryCreate(source, UriKind.Absolute, out sourceUri))
275320
{
276321
reader.EmitError($"Source toc entry is not a valid uri: {source}", tocEntry);

src/Elastic.Documentation.Configuration/Paths.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,17 @@ public static class Paths
1616
private static DirectoryInfo DetermineWorkingDirectoryRoot()
1717
{
1818
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());
19-
while (directory != null &&
20-
(directory.GetFiles("*.sln").Length == 0 || directory.GetDirectories(".git").Length == 0))
19+
while (directory != null)
20+
{
21+
if (directory.GetFiles("*.sln").Length > 0)
22+
break;
23+
if (directory.GetDirectories(".git").Length > 0)
24+
break;
25+
// support for git worktrees
26+
if (directory.GetFiles(".git").Length > 0)
27+
break;
2128
directory = directory.Parent;
29+
}
2230
return directory ?? new DirectoryInfo(Directory.GetCurrentDirectory());
2331
}
2432

@@ -27,12 +35,20 @@ private static DirectoryInfo DetermineWorkingDirectoryRoot()
2735
IDirectoryInfo? sourceRoot = null;
2836
var directory = sourceDirectory;
2937
while (directory != null && directory.GetDirectories(".git").Length == 0)
38+
{
39+
if (directory.GetDirectories(".git").Length > 0)
40+
break;
41+
// support for git worktrees
42+
if (directory.GetFiles(".git").Length > 0)
43+
break;
44+
3045
directory = directory.Parent;
46+
}
3147
sourceRoot ??= directory;
3248
return sourceRoot;
3349
}
3450

35-
/// Used in debug to locate static folder so we can change js/css files while the server is running
51+
/// Used in debug to locate static folder, so we can change js/css files while the server is running
3652
public static DirectoryInfo? GetSolutionDirectory()
3753
{
3854
var directory = new DirectoryInfo(Directory.GetCurrentDirectory());

src/Elastic.Documentation.LegacyDocs/Elastic.Documentation.LegacyDocs.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
<ItemGroup>
1616
<ProjectReference Include="..\Elastic.Documentation.Configuration\Elastic.Documentation.Configuration.csproj" />
17+
<ProjectReference Include="..\services\Elastic.Documentation.Services\Elastic.Documentation.Services.csproj" />
1718
</ItemGroup>
1819

1920
<ItemGroup>

src/Elastic.Documentation.LegacyDocs/LegacyPageChecker.cs renamed to src/Elastic.Documentation.LegacyDocs/LegacyPageService.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,47 @@
33
// See the LICENSE file in the project root for more information
44

55
using Elastic.Documentation.Configuration;
6+
using Elastic.Documentation.Services;
7+
using Microsoft.Extensions.Logging;
68

79
namespace Elastic.Documentation.LegacyDocs;
810

9-
public class LegacyPageChecker
11+
public class LegacyPageService(ILoggerFactory logFactory) : IService
1012
{
13+
private readonly ILogger _logger = logFactory.CreateLogger<LegacyPageService>();
1114
private BloomFilter? _bloomFilter;
1215
private const string RootNamespace = "Elastic.Documentation.LegacyDocs";
1316
private const string FileName = "legacy-pages.bloom.bin";
1417
private const string ResourceName = $"{RootNamespace}.{FileName}";
1518
private readonly string _bloomFilterBinaryPath = Path.Combine(Paths.WorkingDirectoryRoot.FullName, "src", RootNamespace, FileName);
1619

17-
18-
public bool PathExists(string path)
20+
public bool PathExists(string path, bool logResult = false)
1921
{
2022
_bloomFilter ??= LoadBloomFilter();
21-
return _bloomFilter.Check(path);
23+
var exists = _bloomFilter.Check(path);
24+
if (logResult)
25+
_logger.LogInformation("Path {Path} {Exists} in bloom filter", path, exists ? "exists" : "not exists");
26+
return exists;
2227
}
2328

2429
private static BloomFilter LoadBloomFilter()
2530
{
26-
var assembly = typeof(LegacyPageChecker).Assembly;
31+
var assembly = typeof(LegacyPageService).Assembly;
2732
using var stream = assembly.GetManifestResourceStream(ResourceName) ?? throw new FileNotFoundException(
2833
$"Embedded resource '{ResourceName}' not found in assembly '{assembly.FullName}'. " +
2934
"Ensure the Build Action for 'legacy-pages.bloom.bin' is 'Embedded Resource' and the path/name is correct.");
3035
return BloomFilter.Load(stream);
3136
}
3237

33-
public void GenerateBloomFilterBinary(IPagesProvider pagesProvider)
38+
public bool GenerateBloomFilterBinary(IPagesProvider pagesProvider)
3439
{
3540
var pages = pagesProvider.GetPages();
3641
var enumerable = pages as string[] ?? pages.ToArray();
3742
var paths = enumerable.ToHashSet();
3843
var bloomFilter = BloomFilter.FromCollection(enumerable, 0.001);
3944
Console.WriteLine(paths.Count);
4045
bloomFilter.Save(_bloomFilterBinaryPath);
46+
_logger.LogInformation("Bloom filter generated to {Path}", _bloomFilterBinaryPath);
47+
return true;
4148
}
4249
}

0 commit comments

Comments
 (0)