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
EventSeq in Typed EventAdapter, #26909 #27130
Conversation
@@ -484,70 +475,6 @@ class EventSourcedBehaviorSpec extends ScalaTestWithActorTestKit(EventSourcedBeh | |||
events shouldEqual List(EventEnvelope(Sequence(1), pid.id, 1, Incremented(1))) | |||
} | |||
|
|||
"adapt events" in { |
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.
moved to other test
probe.expectMessage("A1BCD3e") | ||
} | ||
|
||
"adapt events" in { |
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.
below were existing tests that moved here
} | ||
|
||
/** INTERNAL API */ | ||
@InternalApi private[akka] final case class SingleEventSeq[A](event: A) extends EventSeq[A] { |
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.
tried to make this AnyVal
but not possible since extends EventSeq
Test FAILed. |
Test PASSed. |
05d67b7
to
f72d082
Compare
Test PASSed. |
Test PASSed. |
* Tests for usage of EventSeq * Moved event adapter tests from EventSourcedBehaviorSpec to new EventSourcedEventAdapterSpec * Also support for the event adapter manifest * Note in migration guide
adc5251
to
decf338
Compare
Test PASSed. |
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.
The EventSeq
part itself looks great.
The addition of the manifest seems like a good idea, but perhaps it would be good to have a motivating example in the tests?
* <ul> | ||
* <li>extracting events from "envelopes"</li> | ||
* <li>manually converting to the Journals storage format, such as JSON, BSON or any specialised binary format</li> | ||
* <li>adapting incoming events from a "data model" to the "domain model"</li> |
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.
Great to make this more clear!
It looks like we're describing this from the toJournal
perspective, so perhaps:
* <li>adapting incoming events from a "data model" to the "domain model"</li> | |
* <li>adapting events from a "domain model" to the "data model"</li> |
?
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's supposed to describe what it can be used for, in both directions, clarified somewhat in 83e2bbb
* Not used in new records stored with Akka v2.4, but | ||
* old records from v2.3 may have this as `true` if | ||
* it was a non-permanent delete. | ||
*/ | ||
def deleted: Boolean | ||
|
||
/** | ||
* Sender of this message. | ||
* Not used, can be `null` |
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.
Deprecate?
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.
created issue #27278
*/ | ||
def withManifest(manifest: String): PersistentRepr | ||
|
||
/** | ||
* Not used, can always be `false`. |
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.
Deprecate?
this | ||
} catch { | ||
case NonFatal(ex) => | ||
state = state.copy(repr.sequenceNr) | ||
onRecoveryFailure(ex, Some(event)) | ||
onRecoveryFailure(ex, Option(eventForErrorReporting.getOrElse(null))) |
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.
onRecoveryFailure(ex, Option(eventForErrorReporting.getOrElse(null))) | |
onRecoveryFailure(ex, Option(eventForErrorReporting.orNull)) |
(might be neat to have an toOption
on OptionVal
?)
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.
added in 83e2bbb
import com.typesafe.config.ConfigFactory | ||
import org.scalatest.WordSpecLike | ||
|
||
object EventSourcedEventAdapterSpec { |
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.
Nice to separate those tests
override def toJournal(e: String): String = e.toUpperCase() | ||
|
||
override def fromJournal(p: String, manifest: String): EventSeq[String] = { | ||
EventSeq.single(p + manifest) |
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.
Heh, that's a nice hack to be able to verify the manifest was retained... would be nicer to have a test where the manifest is used for something 'real', though.
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 added the manifest
because it is supported in Classic and backend journals support it. It has the same purpose as string manifest in serializers. Leaving it as this here because I don't think it's an important feature.
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.
LGTM
Test PASSed. |
new EventSourcedEventAdapterSpec
Refs #26909