The presence of a dependency in a constructor is not random, it is very common. There is nothing wrong.
You can create a default static requisition method on CurrencyActor that takes your dependencies:
public static Props CreateProps(string currency, Irepository repo)
{
return Props.Create(() => new CurrrncyActor(currency, repo));
}
Then create as many as you want:
var usCurrency = system.ActorOf(CurrencyActor.CreateProps("US", someRepo), "US");
var swedishCurrency = system.ActorOf(CurrencyActor.CreateProps("SEK", someRepo), "SEK");
[Update]
Regarding the use of DI containers with Akka, this has been indicated as not. 2 of 7 best mistakes people make when using akka.net
https://petabridge.com/blog/top-7-akkadotnet-stumbling-blocks/
, , DI.
. , , Autofac -
[ 2]
, - , , :
public class MatchesSupervisor : ReceiveActor
{
List<IActorRef> _matches = new List<IActorRef>();
public void MatchesSupervisor()
{
Receive<SomeCommandToStartANewMatch>(msg =>
{
_matches.Add(Context.ActorOf(MatchActor.Create(msg.SomeMatchId)));
}
}
}
DI, MatchActor - , IRepository, MatchesSupervisor, , MatchActor, .
, , - , - .
( ipad, , , , , MatchActor, , , )
, !