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

Warning when there are async projections but no daemon. Closes GH-2509 #2511

Merged
merged 1 commit into from
Mar 1, 2023
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
2 changes: 1 addition & 1 deletion docs/configuration/storeoptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static DocumentStore For(Action<StoreOptions> configure)
return new DocumentStore(options);
}
```
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/DocumentStore.cs#L472-L482' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_documentstore.for' title='Start of snippet'>anchor</a></sup>
<sup><a href='https://github.com/JasperFx/marten/blob/master/src/Marten/DocumentStore.cs#L490-L500' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_documentstore.for' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The major parts of `StoreOptions` are shown in the class diagram below:
Expand Down
18 changes: 18 additions & 0 deletions src/Marten/DocumentStore.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using JasperFx.Core;
using JasperFx.Core.Reflection;
using Marten.Events;
using Marten.Events.Daemon;
using Marten.Events.Daemon.HighWater;
using Marten.Events.Daemon.Resiliency;
using Marten.Events.Projections;
using Marten.Exceptions;
using Marten.Internal.Sessions;
using Marten.Schema;
Expand Down Expand Up @@ -59,6 +63,20 @@ public DocumentStore(StoreOptions options)
_identityMapCompiledQueries = new CompiledQueryCollection(DocumentTracking.IdentityOnly, this);
_dirtyTrackedCompiledQueries = new CompiledQueryCollection(DocumentTracking.DirtyTracking, this);
_queryOnlyCompiledQueries = new CompiledQueryCollection(DocumentTracking.QueryOnly, this);

warnIfAsyncDaemonIsDisabledWithAsyncProjections();
}

private void warnIfAsyncDaemonIsDisabledWithAsyncProjections()
{
if (Options.Projections.HasAnyAsyncProjections() && Options.Projections.AsyncMode == DaemonMode.Disabled)
{
Console.WriteLine("Warning: The async daemon is disabled.");
var asyncProjectionList =
Options.Projections.All.Where(x => x.Lifecycle == ProjectionLifecycle.Async).Select(x => x.ToString())!
.Join(", ");
Console.WriteLine($"Projections {asyncProjectionList} will not be executed without the async daemon enabled");
}
}

public ITenancy Tenancy => Options.Tenancy;
Expand Down