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

Persistence API: add CurrentLastSequenceNumberByPersistenceIdQuery #1773

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

pjfanning
Copy link
Contributor

@pjfanning pjfanning added this to the 1.2.0-M2 milestone Feb 16, 2025
trait CurrentLastKnownSequenceNumberByPersistenceIdQuery extends ReadJournal {

/**
* Returns the last known sequence number for the given `persistenceId`. Empty if the `persistenceId` is unknown.
Copy link
Member

Choose a reason for hiding this comment

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

Optional should use the value is absent instead of Empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think 'empty' makes since this is the terminology used by scala.Option and java Optional.

* A trait that enables querying the current last known sequence number for a given `persistenceId`.
* @since 1.2.0
*/
trait CurrentLastKnownSequenceNumberByPersistenceIdQuery extends ReadJournal {
Copy link
Member

@He-Pin He-Pin Feb 19, 2025

Choose a reason for hiding this comment

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

LastKnownSequenceNumberQuery ?

Choose a reason for hiding this comment

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

Just to highlight the intent behind the Current in name: It seemed to me that "final" queries like CurrentEventsByPersistenceIdQuery are prefixed with 'Current', while continuous corresponding queries like EventsByPersistenceIdQuery drop this prefix. The ByPersistenceId clarifies the scope of query. Even though a LastKnownSequenceNumberByPersistenceIdQuery doesn't exist yet, one could imagine a query that continuously emits the last known sequence number for persistence id in future and thus I had preferred to 1. not block the name already 2. align to existing naming schema.

Copy link
Member

@He-Pin He-Pin Feb 19, 2025

Choose a reason for hiding this comment

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

I just think the name is too long, maybe CurrentLastKnownSequenceNumberQuery, otherwise , if we need add more methods to this trait, then we need another trait.

Copy link
Member

@ptrdom ptrdom Feb 19, 2025

Choose a reason for hiding this comment

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

How about dropping the Known from the name? Current already implies it in a way. EventSourcedBehavior.lastSequenceNumber already exist, so naming would align.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would CurrentLastSequenceNumberQuery work?

Copy link
Member

Choose a reason for hiding this comment

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

I think CurrentLastSequenceNumberByPersistenceIdQuery is good if we are sticking to the style of having a trait per least amount of methods, which does make sense - for example each journal might want to implement CurrentLastSequenceNumberByPersistenceIdQuery, but not necessarily CurrentLastSequenceNumberBySliceQuery or CurrentLastSequenceNumberByTagQuery if we ever implement them.

Copy link
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

Overall look good to me

@pjfanning pjfanning marked this pull request as draft February 19, 2025 19:40
Copy link
Member

@Roiocam Roiocam left a comment

Choose a reason for hiding this comment

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

LGTM, but the function name kind of too long

@pjfanning pjfanning changed the title Persistence API: add CurrentLastKnownSequenceNumberByPersistenceIdQuery Persistence API: add CurrentLastSequenceNumberByPersistenceIdQuery Feb 21, 2025
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.

5 participants