Skip to content

Commit 4805677

Browse files
authored
Reduce visibility of the packages and clarify Liblog dependency (#8)
* Reduced the visibility of the adapter to `internal` * Fixed the namespaces that Liblog uses * Clarified the purpose of Liblog and how to hide it
1 parent 4df239b commit 4805677

6 files changed

Lines changed: 45 additions & 35 deletions

File tree

LiquidProjections.PollingEventStore.sln.DotSettings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_FOREACH/@EntryValue">Required</s:String>
88
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_IFELSE/@EntryValue">Required</s:String>
99
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpCodeStyle/BRACES_FOR_WHILE/@EntryValue">Required</s:String>
10+
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String>
1011
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_ANONYMOUSMETHOD_ON_SINGLE_LINE/@EntryValue">False</s:Boolean>
1112
<s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_WHILE_ON_NEW_LINE/@EntryValue">True</s:Boolean>
1213
<s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_LIMIT/@EntryValue">130</s:Int64>
@@ -55,7 +56,12 @@
5556
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=NAMESPACE_005FALIAS/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
5657
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FFIELD/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
5758
<s:String x:Key="/Default/CodeStyle/Naming/XamlNaming/UserRules/=XAML_005FRESOURCE/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
59+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
60+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpKeepExistingMigration/@EntryIndexedValue">True</s:Boolean>
61+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpPlaceEmbeddedOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
62+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpRenamePlacementToArrangementMigration/@EntryIndexedValue">True</s:Boolean>
5863
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
64+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002ECSharpPlaceAttributeOnSameLineMigration/@EntryIndexedValue">True</s:Boolean>
5965
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
6066
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
6167
<s:Boolean x:Key="/Default/Environment/UnitTesting/DisabledProviders/=MSTest/@EntryIndexedValue">True</s:Boolean>

README.MD

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Liquid Projections [![Build status](https://ci.appveyor.com/api/projects/status/5j2rboeh9vg8773w/branch/master?svg=true)](https://ci.appveyor.com/project/dennisdoomen/liquidprojections-pollingeventstore-ctw8n/branch/master)
22

33
## What is this?
4-
An adapter for event stores that cannot actively push events to [LiquidProjections](https://github.com/liquidprojections/LiquidProjections). It efficiently support multiple concurrent subscribers each interested in a different checkpoint without hitting the underlying event store concurrently
4+
A source-only Nuget package for event stores that cannot actively push events to [LiquidProjections](https://github.com/liquidprojections/LiquidProjections). It efficiently support multiple concurrent subscribers each interested in a different checkpoint without hitting the underlying event store concurrently.
5+
6+
## Important Notes
7+
* This library uses [Liblog](https://github.com/damianh/LibLog) to log details about asynchronous exceptions to your logging framework of choice. You can also have it log more diagnostic messages by setting the `LIQUIDPROJECTIONS_DIAGNOSTICS` condition symbol.
8+
* If you use this library inside your own packaged library, make sure you set the `LIBLOG_PROVIDERS_ONLY` compiler symbol to prevent the LibLog package from leaking into your consumers.

Src/LiquidProjections.PollingEventStore/LibLog.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@
4040

4141
using System.Diagnostics.CodeAnalysis;
4242

43-
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "LiquidProjections.NEventStore.Logging")]
44-
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "LiquidProjections.NEventStore.Logging.Logger.#Invoke(LiquidProjections.NEventStore.Logging.LogLevel,System.Func`1<System.String>,System.Exception,System.Object[])")]
43+
[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "LiquidProjections.PollingEventStoreAdapter.Logging")]
44+
[assembly: SuppressMessage("Microsoft.Design", "CA1026:DefaultParametersShouldNotBeUsed", Scope = "member", Target = "LiquidProjections.PollingEventStoreAdapter.Logging.Logger.#Invoke(LiquidProjections.PollingEventStoreAdapter.Logging.LogLevel,System.Func`1<System.String>,System.Exception,System.Object[])")]
4545

4646
// If you copied this file manually, you need to change all "YourRootNameSpace" so not to clash with other libraries
4747
// that use LibLog
4848
#if LIBLOG_PROVIDERS_ONLY
49-
namespace LiquidProjections.NEventStore.LibLog
49+
namespace LiquidProjections.PollingEventStoreAdapter.LibLog
5050
#else
51-
namespace LiquidProjections.NEventStore.Logging
51+
namespace LiquidProjections.PollingEventStoreAdapter.Logging
5252
#endif
5353
{
5454
using System.Collections.Generic;
5555
using System.Diagnostics.CodeAnalysis;
5656
#if LIBLOG_PROVIDERS_ONLY
57-
using LiquidProjections.NEventStore.LibLog.LogProviders;
57+
using LiquidProjections.PollingEventStoreAdapter.LibLog.LogProviders;
5858
#else
59-
using LiquidProjections.NEventStore.Logging.LogProviders;
59+
using LiquidProjections.PollingEventStoreAdapter.Logging.LogProviders;
6060
#endif
6161
using System;
6262
#if !LIBLOG_PROVIDERS_ONLY
@@ -714,9 +714,9 @@ public bool Log(LogLevel logLevel, Func<string> messageFunc, Exception exception
714714
}
715715

716716
#if LIBLOG_PROVIDERS_ONLY
717-
namespace LiquidProjections.NEventStore.LibLog.LogProviders
717+
namespace LiquidProjections.PollingEventStoreAdapter.LibLog.LogProviders
718718
#else
719-
namespace LiquidProjections.NEventStore.Logging.LogProviders
719+
namespace LiquidProjections.PollingEventStoreAdapter.Logging.LogProviders
720720
#endif
721721
{
722722
using System;
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2-
32
<PropertyGroup>
43
<TargetFramework>netstandard1.1</TargetFramework>
54
</PropertyGroup>
6-
75
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
8-
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_1;LIBLOG_PORTABLE</DefineConstants>
6+
<DefineConstants>TRACE;RELEASE;NETSTANDARD1_1;LIBLOG_PORTABLE;RELEASE;NETSTANDARD1_1;LIQUIDPROJECTIONS_BUILD_TIME</DefineConstants>
97
</PropertyGroup>
10-
118
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
12-
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_1;LIBLOG_PORTABLE</DefineConstants>
9+
<DefineConstants>TRACE;DEBUG;NETSTANDARD1_1;LIBLOG_PORTABLE;DEBUG;NETSTANDARD1_1;LIQUIDPROJECTIONS_BUILD_TIME;LIQUIDPROJECTIONS_DIAGNOSTICS</DefineConstants>
1310
</PropertyGroup>
14-
1511
<ItemGroup>
1612
<PackageReference Include="LiquidProjections.Abstractions" Version="2.3.0" />
1713
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
1814
<PackageReference Include="System.Dynamic.Runtime" Version="4.3.0" />
1915
</ItemGroup>
20-
2116
</Project>

Src/LiquidProjections.PollingEventStore/PollingEventStoreAdapter.cs

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Threading;
55
using System.Threading.Tasks;
66
using LiquidProjections.Abstractions;
7-
using LiquidProjections.NEventStore.Logging;
7+
using LiquidProjections.PollingEventStoreAdapter.Logging;
88

99
namespace LiquidProjections.PollingEventStore
1010
{
@@ -16,7 +16,12 @@ namespace LiquidProjections.PollingEventStore
1616
/// If the implementation of <see cref="IPassiveEventStore"/> implements <see cref="IDisposable"/>, disposing
1717
/// the <see cref="PollingEventStoreAdapter"/> will also dispose the event store.
1818
/// </remarks>
19-
public class PollingEventStoreAdapter : IDisposable
19+
#if LIQUIDPROJECTIONS_BUILD_TIME
20+
public
21+
#else
22+
internal
23+
#endif
24+
class PollingEventStoreAdapter : IDisposable
2025
{
2126
private readonly TimeSpan pollInterval;
2227
private readonly int maxPageSize;
@@ -138,7 +143,7 @@ private Page TryGetNextPageFromCache(long previousCheckpoint, string subscriptio
138143
}
139144
}
140145

141-
#if DEBUG
146+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
142147
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
143148
$"Subscription {subscriptionId} has found a page of size {resultPage.Count} " +
144149
$"from checkpoint {resultPage.First().Checkpoint} " +
@@ -148,7 +153,7 @@ private Page TryGetNextPageFromCache(long previousCheckpoint, string subscriptio
148153
return new Page(previousCheckpoint, resultPage);
149154
}
150155

151-
#if DEBUG
156+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
152157
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
153158
$"Subscription {subscriptionId} has not found the next transaction in the cache.");
154159
#endif
@@ -158,7 +163,7 @@ private Page TryGetNextPageFromCache(long previousCheckpoint, string subscriptio
158163

159164
private void StartPreloadingNextPage(long previousCheckpoint, string subscriptionId)
160165
{
161-
#if DEBUG
166+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
162167
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
163168
$"Subscription {subscriptionId} has started preloading transactions " +
164169
$"after checkpoint {previousCheckpoint}.");
@@ -174,7 +179,7 @@ private async Task<Page> LoadNextPageSequentially(long previousCheckpoint, strin
174179
{
175180
if (isDisposed)
176181
{
177-
#if DEBUG
182+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
178183
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
179184
$"Page loading for subscription {subscriptionId} cancelled because the adapter is disposed.");
180185
#endif
@@ -193,7 +198,7 @@ private async Task<Page> LoadNextPageSequentially(long previousCheckpoint, strin
193198
{
194199
TimeSpan delay = pollInterval - timeAfterPreviousRequest;
195200

196-
#if DEBUG
201+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
197202
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
198203
$"Subscription {subscriptionId} is waiting " +
199204
$"for {delay} before checking for new transactions.");
@@ -242,15 +247,15 @@ private Task<Page> TryLoadNextPageSequentiallyOrWaitForCurrentLoadingToFinish(lo
242247
{
243248
if (isTaskOwner)
244249
{
245-
#if DEBUG
250+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
246251
LogProvider.GetLogger(typeof(PollingEventStoreAdapter))
247252
.Debug(() => $"Subscription {subscriptionId} created a loader {loader.Id} " +
248253
$"for a page after checkpoint {previousCheckpoint}.");
249254
#endif
250255

251256
if (isDisposed)
252257
{
253-
#if DEBUG
258+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
254259
LogProvider.GetLogger(typeof(PollingEventStoreAdapter))
255260
.Debug(() => $"The loader {loader.Id} is cancelled because the adapter is disposed.");
256261
#endif
@@ -267,7 +272,7 @@ private Task<Page> TryLoadNextPageSequentiallyOrWaitForCurrentLoadingToFinish(lo
267272
}
268273
else
269274
{
270-
#if DEBUG
275+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
271276
LogProvider.GetLogger(typeof(PollingEventStoreAdapter))
272277
.Debug(() => $"Subscription {subscriptionId} is waiting for loader {loader.Id}.");
273278
#endif
@@ -288,7 +293,7 @@ private async Task TryLoadNextPageAndMakeLoaderComplete(long previousCheckpoint,
288293
}
289294
finally
290295
{
291-
#if DEBUG
296+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
292297
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
293298
$"Loader for subscription {subscriptionId} is no longer the current one.");
294299
#endif
@@ -297,7 +302,7 @@ private async Task TryLoadNextPageAndMakeLoaderComplete(long previousCheckpoint,
297302
}
298303
catch (Exception exception)
299304
{
300-
#if DEBUG
305+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
301306
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).DebugException(
302307
$"Loader for subscription {subscriptionId} has failed.",
303308
exception);
@@ -307,7 +312,7 @@ private async Task TryLoadNextPageAndMakeLoaderComplete(long previousCheckpoint,
307312
return;
308313
}
309314

310-
#if DEBUG
315+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
311316
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
312317
$"Loader for subscription {subscriptionId} has completed.");
313318
#endif
@@ -322,7 +327,7 @@ private async Task<Page> TryLoadNextPage(long previousCheckpoint, string subscri
322327
Page cachedPage = TryGetNextPageFromCache(previousCheckpoint, subscriptionId);
323328
if (cachedPage.Transactions.Count > 0)
324329
{
325-
#if DEBUG
330+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
326331
LogProvider.GetLogger(typeof(PollingEventStoreAdapter))
327332
.Debug(() =>
328333
$"Loader for subscription {subscriptionId} has found a page in the cache.");
@@ -362,15 +367,15 @@ private async Task<Page> TryLoadNextPage(long previousCheckpoint, string subscri
362367

363368
if (transactions.Count > 0)
364369
{
365-
#if DEBUG
370+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
366371
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
367372
$"Loader for subscription {subscriptionId ?? "without ID"} has loaded {transactions.Count} transactions " +
368373
$"from checkpoint {transactions.First().Checkpoint} to checkpoint {transactions.Last().Checkpoint}.");
369374
#endif
370375

371376
if (transactionCacheByPreviousCheckpoint != null)
372377
{
373-
/* Add to cache in reverse order to prevent other projectors
378+
/* Add to cache in reverse order to prevent other projectors
374379
from requesting already loaded transactions which are not added to cache yet. */
375380
for (int index = transactions.Count - 1; index > 0; index--)
376381
{
@@ -379,7 +384,7 @@ from requesting already loaded transactions which are not added to cache yet. */
379384

380385
transactionCacheByPreviousCheckpoint.Set(previousCheckpoint, transactions[0]);
381386

382-
#if DEBUG
387+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
383388
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
384389
$"Loader for subscription {subscriptionId ?? "without ID"} has cached {transactions.Count} transactions " +
385390
$"from checkpoint {transactions.First().Checkpoint} to checkpoint {transactions.Last().Checkpoint}.");
@@ -388,7 +393,7 @@ from requesting already loaded transactions which are not added to cache yet. */
388393
}
389394
else
390395
{
391-
#if DEBUG
396+
#if LIQUIDPROJECTIONS_DIAGNOSTICS
392397
LogProvider.GetLogger(typeof(PollingEventStoreAdapter)).Debug(() =>
393398
$"Loader for subscription {subscriptionId} has discovered " +
394399
$"that there are no new transactions yet. Next request for the new transactions will be delayed.");

Src/LiquidProjections.PollingEventStore/Subscription.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
using System.Threading;
44
using System.Threading.Tasks;
55
using LiquidProjections.Abstractions;
6-
using LiquidProjections.NEventStore.Logging;
6+
using LiquidProjections.PollingEventStoreAdapter.Logging;
77

88
namespace LiquidProjections.PollingEventStore
99
{

0 commit comments

Comments
 (0)