akka / akka-projection

Akka Projections is intended for building systems with the CQRS pattern, and facilitate in event-based service-to-service communication.
https://doc.akka.io/libraries/akka-projection/current/
Other
102 stars 35 forks source link

SlickProjection should not require a Slick DatabaseConfig #479

Open jroper opened 4 years ago

jroper commented 4 years ago

SlickProjection currently requires passing a Slick DatabaseConfig object, which is a class designed for use with Slick when configuring Slick in a stand alone manner using Slicks own configuration mechanism in typesafe config. If you're using Slick in the context of something else that manages Slick configuration and connections for you, for example, if you're using akka-persistence-jdbc, which defines an Akka extension that loads configuration and configures Slick so that many things (journal, snapshot, persistence query etc) can share the same configuration and connection pools, or if you're using Play that likewise supplies similar APIs, you won't have a DatabaseConfig that you can pass to SlickProjection, and your only option will be to instantiate one yourself from scratch, which will require duplicating the Slick configuration in your config files (connection urls, database driver fqcns, username/password etc), and will also result in multiple connection pools for the same database being created, which the user will then have to shut down themselves instead of being able to rely on the framework supplied mechanism to shut it down.

SlickProjection should therefore not require passing a DatabaseConfig, but should be overloaded to allow passing a Slick Profile and Database instance instead.

octonato commented 4 years ago

That makes sense and we should have thought about it earlier.

It also makes me think about shutdown ordering. I think it's a problem that it's not entirely solved in Lagom as the pool can be closed while the read-side are still trying to use it.