Skip to content
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

feat: JDK 17+ persistence APIs #32420

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

johanandren
Copy link
Member

@johanandren johanandren commented May 16, 2024

No description provided.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

* Behavior
* For Java versions before 17, see [[EventSourcedBehavior]]
*/
abstract class EventSourcedOnCommandBehavior[Command, Event, State](
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need one for EventSourcedBehaviorWithEnforcedReplies too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, soon in a new push.

*
* Use [[EventSourcedBehavior#newSignalHandlerBuilder]] to define the signal handler.
*/
protected def signalHandler(): SignalHandler[State] = SignalHandler.empty[State]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be onSignal without the SignalHandler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the signal handler is more like a partial function, so might be nicer with a builder kind of thing still, rather than have to catch-all-behavior-unhandled

case EmptyEventsListAndThenLog emptyEventsListAndThenLog -> emptyEventsListAndThenLog(state, emptyEventsListAndThenLog);
case StopThenLog stopThenLog -> stopThenLog(state, stopThenLog);
case IncrementTwiceAndLog incrementTwiceAndLog -> incrementTwiceAndLog(state, incrementTwiceAndLog);
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@johanandren
Copy link
Member Author

Not sure if we maybe need one of each for the WithEnforcedReplies as well, maybe good enough with these?

@johanandren
Copy link
Member Author

I put the examples under the respective "Style Guide", not entirely happy with that but better than nothing. Didn't showcase the replicated API anywhere yet.

@johanandren johanandren changed the title WIP JDK 17+ persistence APIs feat: JDK 17+ persistence APIs May 20, 2024
@johanandren johanandren marked this pull request as ready for review May 20, 2024 07:13
@johanandren
Copy link
Member Author

I believe replication with akka-projection-grpc will just work (tm) since the API there expect a Behavior[Command] back from user replication behavior factory.

@johanandren
Copy link
Member Author

Ready for final review

@patriknw
Copy link
Member

Not sure if we maybe need one of each for the WithEnforcedReplies as well, maybe good enough with these?

Um, some people (read @octonato ) think that is very important, or at least that was the opinion when we introduced it.

Copy link
Member

@patriknw patriknw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good

@@ -14,6 +14,8 @@ import akka.persistence.typed.internal.ReplicationContextImpl

/**
* Base class for replicated event sourced behaviors.
*
* For projects using Java 17 and newer, also see [[EventSourcedOnCommandBehavior]]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReplicatedEventSourcedOnCommandBehavior


## Leveraging Java 21 features

When building durable state entities in a project using Java 21 or newer, the @javadoc[DurableStateOnCommandBehavior](akka.persistence.typed.statejavadsl.DurableStateOnCommandBehavior)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole naming with OnCommand is pretty weird, but I don't have any other suggestion than following the track of OnMessage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I went with that is that there never is an onMessage method here, what you define is onCommand and onEvent. The choice is if we are inconsistent with this API itself, or with another class further away.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean that the OnMessage naming is not great to begin with, but I see no other option than continue and here the corresponding would be OnCommand as you have done.

* @param allReplicasAndQueryPlugins All replica ids and a query plugin per replica id. These need to be known to receive events from all replicas
* and configured with the query plugin for the journal that each replica uses.
*/
def onCommandPerReplicaJournalConfig[Command, Event, State](
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mouthful, but could be good with same prefix:
perReplicaJournalConfigForEventSourcedOnCommandBehavior

similar with commonJournalConfig

@johanandren
Copy link
Member Author

Um, some people think that is very important, or at least that was the opinion when we introduced it.

Allright, I better add an EventSourcedOnCommandWithReplyBehavior then...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants