-
Notifications
You must be signed in to change notification settings - Fork 143
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
Configuring persistence plugins at runtime for EventSourcedBehavior #1518
base: main
Are you sure you want to change the base?
Configuring persistence plugins at runtime for EventSourcedBehavior #1518
Conversation
@@ -112,9 +112,12 @@ object PersistenceTestKitPlugin { | |||
* Persistence testkit plugin for snapshots. | |||
*/ | |||
@InternalApi | |||
class PersistenceTestKitSnapshotPlugin extends SnapshotStore { | |||
class PersistenceTestKitSnapshotPlugin(@unused cfg: Config, cfgPath: String) extends SnapshotStore { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do we need an unused parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is because of this bit of code:
pekko/persistence/src/main/scala/org/apache/pekko/persistence/Persistence.scala
Lines 413 to 425 in 2421458
val pluginActorArgs: List[AnyRef] = | |
try { | |
Reflect.findConstructor(pluginClass, List(pluginConfig, configPath)) // will throw if not found | |
List(pluginConfig, configPath) | |
} catch { | |
case NonFatal(_) => | |
try { | |
Reflect.findConstructor(pluginClass, List(pluginConfig)) // will throw if not found | |
List(pluginConfig) | |
} catch { | |
case NonFatal(_) => Nil | |
} // otherwise use empty constructor | |
} |
Easiest solution seemed to work around this the same as it is done in
PersistenceTestKitPlugin
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if the param is used, can you removed the @unused
annotation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is used only through reflection, so compilation throws the following if @unused
is removed:
parameter cfg in class PersistenceTestKitSnapshotPlugin is never used
[error] Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=unused-params, site=org.apache.pekko.persistence.testkit.PersistenceTestKitSnapshotPlugin.cfg
[error] class PersistenceTestKitSnapshotPlugin(cfg: Config, cfgPath: String) extends SnapshotStore {
[error] ^
[error] one error found
[error] (persistence-testkit / Compile / compileIncremental) Compilation failed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fair enough - could you add a code comment explaining the @unused
?
...n/scala/org/apache/pekko/persistence/testkit/internal/SnapshotStorageEmulatorExtension.scala
Outdated
Show resolved
Hide resolved
...stkit/src/test/scala/org/apache/pekko/persistence/testkit/scaladsl/RuntimeJournalsSpec.scala
Show resolved
Hide resolved
...stkit/src/test/scala/org/apache/pekko/persistence/testkit/scaladsl/RuntimeJournalsSpec.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are quite a lot of changes to constructors - even if they are for internal classes
I don't know but we might want to consider adding secondary constructors that match the existing param lists in the 1.1.2-RC1 release.
...istence-typed/src/main/scala/org/apache/pekko/persistence/typed/internal/BehaviorSetup.scala
Outdated
Show resolved
Hide resolved
@@ -13,10 +13,12 @@ | |||
|
|||
package org.apache.pekko.persistence.typed.internal | |||
|
|||
import com.typesafe.config.ConfigFactory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep the scala namespace imports at the start
...istence-typed/src/main/scala/org/apache/pekko/persistence/typed/internal/BehaviorSetup.scala
Outdated
Show resolved
Hide resolved
@@ -107,14 +113,18 @@ private[pekko] final class BehaviorSetup[C, E, S]( | |||
|
|||
private var recoveryTimer: OptionVal[Cancellable] = OptionVal.None | |||
|
|||
val recoveryEventTimeout: FiniteDuration = persistence |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is accessed in multiple places of EventSourcedBehavior
state machine - ReplayingEvents
and ReplayingSnapshot
are using this to make error messages, so cannot be made private. Please advise if some different solution is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a @since 1.1.3
annotation to any new public classes, variables or functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just double-checking - is this required for public members of classes marked with @InternalApi
and private[pekko]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure - this whole PR is looking like something we might need to stick in a future major release as opposed to an upcoming patch release. Leave the since annotations out for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood. Is there any issue with creating a PR with this code in Akka repository? Wondering about any potential license conflicts, would not want interaction with BSL repositories voiding Pekko of this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to submit this to Akka. You own this code and submitting it Akka does not change that. The problem will only arise if you collaborate on some of the code with a Lightbend employee and then take that collaboration and try to submit that to us.
There are binary compat problems that will require adding an exclude file for.
|
@@ -16,6 +16,8 @@ package org.apache.pekko.persistence.typed.javadsl | |||
import java.util.Collections | |||
import java.util.Optional | |||
|
|||
import scala.jdk.OptionConverters._ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a Pekko OptionConverters - can you use that? org.pekko.util
We can't use scala.jdk.OptionConverters because we still support Scala 2.12
Resolves #1513.