Skip to content

Commit

Permalink
fix: add catchup size by setting
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneD authored and jvandaal committed Jan 31, 2024
1 parent 606d019 commit affe2dc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
35 changes: 23 additions & 12 deletions src/PostalRegistry.Projector/Infrastructure/Modules/ApiModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public class ApiModule : Module
private readonly IServiceCollection _services;
private readonly ILoggerFactory _loggerFactory;

private readonly ConnectedProjectionSettings _connectedProjectionSettings;

public ApiModule(
IConfiguration configuration,
IServiceCollection services,
Expand All @@ -41,6 +43,13 @@ public ApiModule(
_configuration = configuration;
_services = services;
_loggerFactory = loggerFactory;

var catchUpSize = configuration.GetValue<int>("CatchUpSize", 100);

_connectedProjectionSettings = ConnectedProjectionSettings
.Configure(x => x
.ConfigureCatchUpPageSize(catchUpSize)
.ConfigureCatchUpUpdatePositionMessageInterval(catchUpSize));
}

protected override void Load(ContainerBuilder builder)
Expand All @@ -59,10 +68,9 @@ protected override void Load(ContainerBuilder builder)
private void RegisterProjectionSetup(ContainerBuilder builder)
{
builder.RegisterModule(
new EventHandlingModule(
typeof(DomainAssemblyMarker).Assembly,
EventsJsonSerializerSettingsProvider.CreateSerializerSettings()))

new EventHandlingModule(
typeof(DomainAssemblyMarker).Assembly,
EventsJsonSerializerSettingsProvider.CreateSerializerSettings()))
.RegisterModule<EnvelopeModule>()
.RegisterEventstreamModule(_configuration)
.RegisterModule(new ProjectorModule(_configuration));
Expand All @@ -71,7 +79,7 @@ private void RegisterProjectionSetup(ContainerBuilder builder)
RegisterLastChangedProjections(builder);
RegisterLegacyProjections(builder);

if(_configuration.GetSection("Integration").GetValue("Enabled", false))
if (_configuration.GetSection("Integration").GetValue("Enabled", false))
RegisterIntegrationProjections(builder);
}

Expand All @@ -83,13 +91,14 @@ private void RegisterIntegrationProjections(ContainerBuilder builder)
_configuration,
_services,
_loggerFactory));

builder
.RegisterProjectionMigrator<IntegrationContextMigrationFactory>(
_configuration,
_loggerFactory)
.RegisterProjections<PostalLatestItemProjections, IntegrationContext>(
context => new PostalLatestItemProjections(context.Resolve<IOptions<IntegrationOptions>>()),
ConnectedProjectionSettings.Default);
_connectedProjectionSettings);
}

private void RegisterExtractProjections(ContainerBuilder builder)
Expand All @@ -105,8 +114,9 @@ private void RegisterExtractProjections(ContainerBuilder builder)
_configuration,
_loggerFactory)
.RegisterProjections<PostalInformationExtractProjections, ExtractContext>(
context => new PostalInformationExtractProjections(context.Resolve<IOptions<ExtractConfig>>(), DbaseCodePage.Western_European_ANSI.ToEncoding()),
ConnectedProjectionSettings.Default);
context => new PostalInformationExtractProjections(context.Resolve<IOptions<ExtractConfig>>(),
DbaseCodePage.Western_European_ANSI.ToEncoding()),
_connectedProjectionSettings);
}

private void RegisterLastChangedProjections(ContainerBuilder builder)
Expand All @@ -119,13 +129,14 @@ private void RegisterLastChangedProjections(ContainerBuilder builder)
_loggerFactory));

builder
.RegisterProjectionMigrator<PostalRegistry.Projections.LastChangedList.LastChangedListContextMigrationFactory>(
.RegisterProjectionMigrator<
PostalRegistry.Projections.LastChangedList.LastChangedListContextMigrationFactory>(
_configuration,
_loggerFactory)
.RegisterProjectionMigrator<DataMigrationContextMigrationFactory>(
_configuration,
_loggerFactory)
.RegisterProjections<LastChangedListProjections, LastChangedListContext>(ConnectedProjectionSettings.Default);
.RegisterProjections<LastChangedListProjections, LastChangedListContext>(_connectedProjectionSettings);
}

private void RegisterLegacyProjections(ContainerBuilder builder)
Expand All @@ -140,8 +151,8 @@ private void RegisterLegacyProjections(ContainerBuilder builder)
.RegisterProjectionMigrator<LegacyContextMigrationFactory>(
_configuration,
_loggerFactory)
.RegisterProjections<PostalInformationProjections, LegacyContext>(ConnectedProjectionSettings.Default)
.RegisterProjections<PostalInformationSyndicationProjections, LegacyContext>(ConnectedProjectionSettings.Default);
.RegisterProjections<PostalInformationProjections, LegacyContext>(_connectedProjectionSettings)
.RegisterProjections<PostalInformationSyndicationProjections, LegacyContext>(_connectedProjectionSettings);
}
}
}
2 changes: 2 additions & 0 deletions src/PostalRegistry.Projector/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
"IntegrationProjectionsAdmin": "."
},

"CatchUpSize": 100,

"DataDog": {
"Enabled": false,
"Debug": false,
Expand Down

0 comments on commit affe2dc

Please sign in to comment.