play config to akka typesafe config?

23 views
Skip to first unread message

Curt Siffert

unread,
Jun 14, 2017, 9:23:44 PM6/14/17
to Play Framework
In one of our services, we are extending GuiceApplicationLoader to dynamically load some new configuration values (only discoverable at runtime) into our play.api.Configuration object.

The problem is that we are also using an actor system in this app, and the com.typesafe.config.Config that we get from context.system.settings.config appears not to have these configuration values that were dynamically loaded into play.api.Configuration .

Is there a way to ensure that an actor's context.system.settings.config will be derived from the dynamically adjusted play.api.Configuration object?

We used to pull the play.api.Configuration object (via Play.current.configuration) into these areas of the code but we don't anymore because of deprecation.

It seems the two alternatives are to figure out how to DI the play.api.Configuration into our actors (that feels unclean), or to repeat the same dynamic configuration process when we create the actor system, if we can ensure that all other actors will find those values. But I wonder if I am missing a simpler way.

We are on Play 2.4 and are unable to upgrade to Play 2.5 at this time.

Thanks,
Curt Siffert

Greg Methvin

unread,
Jun 15, 2017, 4:11:16 AM6/15/17
to play-framework
If you're overriding the binding for Configuration at runtime, you should at least be seeing the config values. The ActorSystemProvider used by Play depends on Configuration, so should use whichever one is bound: https://github.com/playframework/playframework/blob/2.4.x/framework/src/play/src/main/scala/play/api/libs/concurrent/Akka.scala#L249.

Getting the Config from the ActorSystem inside the actor seems like a weird way of passing configuration. Are you trying to look at one of the Akka config values?

If it's your own config value it should definitely be passed in separately. I'd suggest to create a type-safe case class for holding the config values you care about, and pass that object (or have it injected) to the constructor of the actor.

--
You received this message because you are subscribed to the Google Groups "Play Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framework+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/play-framework/27fd7000-de26-4562-83c6-acb03aeb1156%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Greg Methvin
Tech Lead - Play Framework

Reply all
Reply to author
Forward
0 new messages