-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMetricsPublisherActorProvider.cs
28 lines (26 loc) · 1.15 KB
/
MetricsPublisherActorProvider.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
using System;
using System.Linq.Expressions;
using Akka.Actor;
namespace SnD.Sdk.Metrics.Actors;
/// <summary>
/// Factory for creating metrics publisher actor instances.
/// </summary>
public static class MetricsPublisherActorProvider
{
/// <summary>
/// Start a new instance of the metrics publisher actor.
/// </summary>
/// <param name="actorSystem">Actor system used to control the actor.</param>
/// <param name="factory">Factory method for creating the actor instance.</param>
/// <param name="name">Optional Actor name (can be omitted if application requires the singleton actor).
/// In this case the name of the class <see cref="MetricsPublisherActor"/> will be used.</param>
/// <typeparam name="TActorType">The concrete class name for the actor.</typeparam>
/// <returns>Actor reference.</returns>
public static IActorRef StartMetricsPublisher<TActorType>(this IActorRefFactory actorSystem,
Expression<Func<TActorType>> factory,
string name = null)
where TActorType : MetricsPublisherActor
{
return actorSystem.ActorOf(Props.Create(factory), name ?? nameof(MetricsPublisherActor));
}
}