These are chat archives for petabridge/akka-bootcamp

24th
Apr 2017
Yip-Yip
@Yip-Yip
Apr 24 2017 05:20
Is passing Iactorrefs via messages good practice ??
Also is a factory Service containing top lvl IActorrefs an ok approach ?
mwardm
@mwardm
Apr 24 2017 19:28
@Yip-Yip I've seen it written that it's okay to pass iactorrefs when required. Since you can get the sender from the context - and you can maintain the previous sender in the chain by Forwarding a message - I guess you could argue it's only necessary when an actor needs to be told who to send a message to that can't be inferred from those.
mwardm
@mwardm
Apr 24 2017 19:33
I'll be interested myself to see suggestions for the "top-level actors" bit of your question. (I've just created some in an initialisation method and saved them in some public static variables myself, which is based on the recommendations I've seen for when you initialise a system in a web app. I'm not entirely happy with it though.)
Yip-Yip
@Yip-Yip
Apr 24 2017 21:46
public static class ActorSystemRefs
{
/// <summary>
/// Reference to the <see cref="ActorSystem"/>
/// </summary>
public static ActorSystem System;
    /// <summary>
    /// Dependency injection resolver for Akka.NET actors
    /// </summary>
    public static IDependencyResolver DiResolver;

    /// <summary>
    /// Autofac
    /// </summary>
    public static IContainer DiContainer { get; set; }

    /// <summary>
    /// Scope
    /// </summary>
    public static ILifetimeScope Scope { get; set; }

    /// <summary>
    /// Validator
    /// </summary>
    public static IActorRef VrWebValidatoRef { get; set; }

    /// <summary>
    /// ConsoleWriterRef
    /// </summary>
    public static IActorRef ConsoleWriterRef { get; set; }

    /// <summary>
    /// ConsoleReaderRef
    /// </summary>
    public static IActorRef ConsoleReaderRef { get; set; }



}
Im starting to warm to it myself ... will see how it translates for testability
@mwardm forwarding maitains sender i didnt know thanks for that ;)