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: Start projection from custom offset #934

Closed

Conversation

patriknw
Copy link
Member

  • support a way for the user to define the offset that is used when starting the Projection
  • optionally load the existing stored offset and pass that to the user function
  • some rather messy jugling of SourceProvider adapters

On top of #933

  • decide on naming and api
  • more (all) SourceProvider implementation can use this
  • test
  • docs

* support a way for the user to define the offset that is used when starting the Projection
* optionally load the existing stored offset and pass that to the user function
* some rather messy jugling of SourceProvider adapters
@patriknw
Copy link
Member Author

I think I have a better idea for how to do this, closing until updated.

@patriknw patriknw closed this Jun 28, 2023
@patriknw patriknw reopened this Jun 28, 2023
*/
final class CustomStartOffsetSourceProvider[Offset, Envelope](
loadFromOffsetStore: Boolean,
adjustStartOffset: Option[Offset] => Future[Option[Offset]],
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 idea is that the user would decorate the ordinary SourceProvider by wrapping it with this

@InternalApi private[projection] object BySliceSourceProviderAdapter {
def apply[Offset, Envelope](
sourceProvider: javadsl.SourceProvider[Offset, Envelope]): scaladsl.SourceProvider[Offset, Envelope] =
sourceProvider match {
Copy link
Member Author

Choose a reason for hiding this comment

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

this javadsl -> scaladsl adapter is still rather messy, but need to unwrap the CustomStartOffsetSourceProvider decoration and implement it here instead to keep the BySlicesSourceProvider type

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it will be a problem also for the normal scaladsl case. I'll have to take another look at that.

@patriknw
Copy link
Member Author

This will not fly because of the optional traits that we look for: BySlicesSourceProvider, EventTimestampQuery, LoadEventQuery

I'll open a new PR with a different approach.

@patriknw patriknw closed this Jun 29, 2023
@patriknw patriknw deleted the wip-start-offset-patriknw branch June 29, 2023 07:23
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.

1 participant