Skip to content

Commit

Permalink
Merge pull request #1673 from Cratis:fix/default-database
Browse files Browse the repository at this point in the history
Making the MongoDB database default to the chronicle one, which is what is expected
  • Loading branch information
einari authored Jan 23, 2025
2 parents 2bea61c + dad02f9 commit f120b8f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Source/Kernel/Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
.UseOrleans(_ => _
.UseLocalhostClustering()
.AddChronicleToSilo(_ => _
.WithMongoDB(chronicleOptions.Storage.ConnectionDetails, WellKnownDatabaseNames.Chronicle))
.WithMongoDB(chronicleOptions))
.UseDashboard(options =>
{
options.Host = "*";
Expand Down
14 changes: 12 additions & 2 deletions Source/Kernel/Storage.MongoDB/MongoDBChronicleBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright (c) Cratis. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Cratis.Chronicle.Concepts.Configuration;
using Cratis.Chronicle.Storage;
using Cratis.Chronicle.Storage.Compliance;
using Cratis.Chronicle.Storage.MongoDB;
Expand All @@ -18,14 +19,23 @@ public static class MongoDBChronicleBuilderExtensions
{
static bool _mongoDBArtifactsInitialized;

/// <summary>
/// Configure Chronicle to use MongoDB, based on the <see cref="ChronicleOptions"/>.
/// </summary>
/// <param name="builder"><see cref="IChronicleBuilder"/> to configure.</param>
/// <param name="options"><see cref="ChronicleOptions"/> to use.</param>
/// <returns><see cref="IChronicleBuilder"/> for continuation.</returns>
public static IChronicleBuilder WithMongoDB(this IChronicleBuilder builder, ChronicleOptions options) =>
builder.WithMongoDB(options.Storage.ConnectionDetails, WellKnownDatabaseNames.Chronicle);

/// <summary>
/// Configure Chronicle to use MongoDB.
/// </summary>
/// <param name="builder"><see cref="IChronicleBuilder"/> to configure.</param>
/// <param name="server">Connection string for the MongoDB server.</param>
/// <param name="database">Name of the database to use.</param>
/// <param name="database">Name of the database to use. Defaults to the <see cref="WellKnownDatabaseNames.Chronicle"/>.</param>
/// <returns><see cref="IChronicleBuilder"/> for continuation.</returns>
public static IChronicleBuilder WithMongoDB(this IChronicleBuilder builder, string server, string database)
public static IChronicleBuilder WithMongoDB(this IChronicleBuilder builder, string server, string database = WellKnownDatabaseNames.Chronicle)
{
builder.SiloBuilder
.UseMongoDBClient(server)
Expand Down

0 comments on commit f120b8f

Please sign in to comment.