Skip to content

Commit

Permalink
Add WithExtensions support (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
Arkatufus authored Aug 11, 2022
1 parent b816285 commit fd5fa2d
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Akka.Hosting/AkkaHostingExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using Akka.Actor;
using Akka.Actor.Setup;
using Akka.Configuration;
Expand Down Expand Up @@ -145,5 +146,31 @@ public static AkkaConfigurationBuilder WithActors(this AkkaConfigurationBuilder
return builder.StartActors(actorStarter);
}

/// <summary>
/// Adds a list of Akka.NET extensions that will be started automatically when the <see cref="ActorSystem"/>
/// starts up.
/// </summary>
/// <example>
/// <code>
/// // Starts distributed pub-sub, cluster metrics, and cluster bootstrap extensions at start-up
/// builder.WithExtensions(
/// typeof(DistributedPubSubExtensionProvider),
/// typeof(ClusterMetricsExtensionProvider),
/// typeof(ClusterBootstrapProvider));
/// </code>
/// </example>
/// <param name="builder">The builder instance being configured.</param>
/// <param name="extensions">A list of extension providers that will be automatically started
/// when the <see cref="ActorSystem"/> starts</param>
/// <returns>The same <see cref="AkkaConfigurationBuilder"/> instance originally passed in.</returns>
public static AkkaConfigurationBuilder WithExtensions(
this AkkaConfigurationBuilder builder,
params Type[] extensions)
{
builder.AddHocon(
$"akka.extensions=[{string.Join(", ", extensions.Select(s => $"\"{s.AssemblyQualifiedName}\""))}]",
HoconAddMode.Prepend);
return builder;
}
}
}

0 comments on commit fd5fa2d

Please sign in to comment.