Skip to content

Commit

Permalink
warning when there are async projections but no daemon. Closes GH-2509
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy D. Miller authored and jeremydmiller committed Mar 1, 2023
1 parent 8488500 commit 229cca9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
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

0 comments on commit 229cca9

Please sign in to comment.