This repository has been archived by the owner on May 29, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ebd2078
commit aca05fa
Showing
13 changed files
with
247 additions
and
225 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
d60.Cirqus/Config/Configurers/AggregateRootRepositoryConfigurationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,56 @@ | ||
using System; | ||
using d60.Cirqus.Aggregates; | ||
using d60.Cirqus.Events; | ||
using d60.Cirqus.Serialization; | ||
using d60.Cirqus.Snapshotting; | ||
|
||
namespace d60.Cirqus.Config.Configurers | ||
{ | ||
public class AggregateRootRepositoryConfigurationBuilder : ConfigurationBuilder<IAggregateRootRepository> | ||
{ | ||
public AggregateRootRepositoryConfigurationBuilder(IRegistrar registrar) : base(registrar) { } | ||
|
||
/// <summary> | ||
/// Registers a <see cref="DefaultAggregateRootRepository"/> as the <see cref="IAggregateRootRepository"/> implementation. Since this is the | ||
/// default, there's no need to call this method explicitly. | ||
/// </summary> | ||
public void UseDefault() | ||
{ | ||
Register(context => | ||
new DefaultAggregateRootRepository( | ||
context.Get<IEventStore>(), | ||
context.Get<IDomainEventSerializer>(), | ||
context.Get<IDomainTypeNameMapper>())); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a <see cref="FactoryBasedAggregateRootRepository"/> as the <see cref="IAggregateRootRepository"/> implementation. | ||
/// </summary> | ||
public void UseFactoryMethod(Func<Type, AggregateRoot> factoryMethod) | ||
{ | ||
Register(context => | ||
new FactoryBasedAggregateRootRepository( | ||
context.Get<IEventStore>(), | ||
context.Get<IDomainEventSerializer>(), | ||
context.Get<IDomainTypeNameMapper>(), | ||
factoryMethod)); | ||
} | ||
|
||
/// <summary> | ||
/// Registers a <see cref="IAggregateRootRepository"/> as a decorator in front of the existing <see cref="InMemorySnapshotCache"/> | ||
/// which will use an <see cref="CachingAggregateRootRepositoryDecorator"/> to cache aggregate roots. | ||
/// </summary> | ||
public void EnableInMemorySnapshotCaching(int approximateMaxNumberOfCacheEntries) | ||
{ | ||
Decorate(context => | ||
new CachingAggregateRootRepositoryDecorator( | ||
context.Get<IAggregateRootRepository>(), | ||
new InMemorySnapshotCache | ||
{ | ||
ApproximateMaxNumberOfCacheEntries = approximateMaxNumberOfCacheEntries | ||
}, | ||
context.Get<IEventStore>(), | ||
context.Get<IDomainEventSerializer>())); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 59 additions & 4 deletions
63
d60.Cirqus/Config/Configurers/EventDispatcherConfigurationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletion
30
d60.Cirqus/Config/Configurers/LoggingConfigurationBuilder.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,35 @@ | ||
namespace d60.Cirqus.Config.Configurers | ||
using d60.Cirqus.Logging; | ||
using d60.Cirqus.Logging.Console; | ||
using d60.Cirqus.Logging.Null; | ||
|
||
namespace d60.Cirqus.Config.Configurers | ||
{ | ||
public class LoggingConfigurationBuilder : ConfigurationBuilder | ||
{ | ||
public LoggingConfigurationBuilder(IRegistrar registrar) : base(registrar) { } | ||
|
||
/// <summary> | ||
/// Configures Cirqus to log using the console. | ||
/// </summary> | ||
public void UseConsole(Logger.Level minLevel = Logger.Level.Info) | ||
{ | ||
Use(new ConsoleLoggerFactory(minLevel: minLevel)); | ||
} | ||
|
||
/// <summary> | ||
/// Configures Cirqus to not log anything at all. | ||
/// </summary> | ||
public void None() | ||
{ | ||
Use(new NullLoggerFactory()); | ||
} | ||
|
||
/// <summary> | ||
/// Configures Cirqus get its logger using specified factory. | ||
/// </summary> | ||
public void Use(CirqusLoggerFactory factory) | ||
{ | ||
CirqusLoggerFactory.Current = factory; | ||
} | ||
} | ||
} |
Oops, something went wrong.