Skip to content

How to detect if the actor system is running Phobos? #92

@object

Description

@object

While adding support to cusomtized actor type names (see my prefious issue), we hit a problem with unit test failures due to InvalidCastException (attempt to cast LocalRefProvider to PhobosActorRefProvider). And the cast was invalid indeed because our unit tests don't use Phobos, they use ActorSystem instance obtained from the Akka.TestKit. So the following code failed:

        props.ToProps().WithInstrumentation(system, _.WithActorTypeName(actorTypeName))

To fix the tests we had to check ActorSystem.Settings.ProvideClass string:

        if system.Settings.ProviderClass.StartsWith "Phobos.Actor" then
            props.ToProps().WithInstrumentation(system, _.WithActorTypeName(actorTypeName))
        else
            props.ToProps()

The check should support both providers from both Phobos.Actor and Phobos.Actor.Cluster. But this check is fragile.
Is there an alternative way to detect it the actor system is powered by Phobos, without comparing magic strings?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions