-
-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Configuration should be changeable in Code #51
Comments
Hi @schmitch, currently the configuration is extract from the Play configuration object but I think we need to rework that part. See #40 (comment)
Feel free to open a pull request. |
@Mogztter yeah it's true that this needs to be reworked, however due to the fact that CommonsMailer is a injected class there is a way to work around that. Also it sucks that send give's back a string and not a Future[String] if the config get's pulled from slick3 we would need to block the database call, if this would be a Future it would be better, as a way to deprecate it would be to have a blocking send and a future send. |
Yes, there's an open issue about that: #13 |
+1 |
+1 |
+1 |
I've created a pull request but I want feedback/review before merging. Can you take a look and tell me what you think ? |
@Mogztter |
Why not... you are not ready to take the big step of Play 2.4 ? ;)
|
@Mogztter could you make a new version after you've merged this (especially for sbt/mvn)? |
I'm on vacation but I will see what I can do |
@jroper Here is the result (comparison with version 3.0.1):
|
So, generally, that means we should cut a new major version. But, maybe a different approach to configuration would be a better idea - at the moment, the client is mutable, when it gets reconfigured, it gets reconfigured globally. I think a better way to do this would be to simply remove the |
@jroper do you think that is needed at the first place, i mean most people would want to store their mailer configuration inside a database, not having many mailers. A lot of frameworks have this kind of usage. |
But at the moment there's a race condition, what if the app sends an email before you load it from the database? There's nothing stopping it from doing that. If you want to load the configuration from a database, you can do that easily, simply implement a new JSR330 provider for SMTPConfiguration that, instead of looking it up out of the Play configuration, looks it up out of the database. |
I agree on the principle but at the moment
Why not but SMTPConfiguration is related to one provider. If we implement more providers, we will have to create one factory for each provider configuration. I don't know if this is a good or bad thing ? |
So if SMTPConfiguration is provided we use this configuration else we fall back on the Play (default) configuration ? |
@jroper With this approach how a user can reconfigure the injected MailerClient at runtime (or inject another MailerClient with a different configuration) ? @Provides
def provideSMTPConfiguration() = {
new SMTPConfiguration("typesafe.org", 1234)
}
} Then all the injected |
That not exactly what you described but I think that the following code maintains binary compatibility: class CommonsMailer @Inject() (configuration: Configuration) extends MailerClient {
def this(smtpConfiguration: SMTPConfiguration) = {
this(Configuration.from(smtpConfiguration) /* the method doesn't exist, but you get the idea */)
}
// ...
} That allow users to programmatically configure the mailer client by instantiating CommonsMailer(SMTPConfiguration("typesafe.org", 1234)) Maybe a better (but breaking compatibility) solution would be to:
I don't know how to do the last part but that way we don't force users to do manual instantiation because they can implement a JSR330 provider for SMTPConfiguration and use @jroper Wdyt ? |
Any Updates on this? |
I've opened a new pull request to fix the global reconfiguration (mutable state) but I do need feedback because I can't decide if this is a better approach or not. I would love to hear from a Scala / Guice expert 😄 |
@Mogztter, what version should be released? Should there be any new forks for the repo to maintain old versions? |
@jroper I think we should create the branch
|
Wouldn't it be better that the Plugin version matches the Play Version? so creating a play2-mailer - 2.4.2 would be best? |
Yes and no 😄 |
Matching the version numbers would essentially force play-mailer to wait for a new Play major release before it can release any breaking changes. |
@Mogztter sounds good to me. If you can setup the branches, I'll cut the release once you're done. |
I've created branch |
@jroper do you need anything else to cut the release ? |
4.0.0-M1 is released, pending maven central sync to CDN nodes. |
Thanks @jroper, I think we can now close this issue 🎉 |
Hello, currently the configuration of the Mailer is only changeable inside the application.conf,
however that is aweful since sometimes you wan't to make it User Configurable.
The text was updated successfully, but these errors were encountered: