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

Volatile offset store #128

Merged
merged 3 commits into from
Nov 16, 2023
Merged

Volatile offset store #128

merged 3 commits into from
Nov 16, 2023

Conversation

huntc
Copy link
Collaborator

@huntc huntc commented Nov 15, 2023

This commit permits a projection consumer to receive a volatile offset store for the purposes of always sourcing events from the start of a journal. This is used, for example, when sourcing events for an http connection where no start offset is provided.

The store can be used with all both sequence and timestamp offsets.

As an extra convenience, the tuple returned from the offset store task functions is now passed directly into the the projection consumer. The projection consumer will take care of running the offset store task and saves the caller from having to spawn it. Under the covers, the offset store task is joined with the projection consumer task, which are subsequently spawned as one.

Related: https://github.com/lightbend/akka-projection-temp/pull/23

This commit permits a projection consumer to optionally receive an offset store. Where it is not supplied, the source is requested to provided all of the events that it has.
@huntc huntc marked this pull request as ready for review November 15, 2023 05:10
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, but thinking about...

envelope
} else {
envelope
}
} else {
envelope
Copy link
Member

Choose a reason for hiding this comment

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

Using no offset store together with remote gRPC projections will result in weird results, but I guess we don't have an easy way to fail fast for that "unsupported" combination? Maybe we should anyway fail here when it is a Offset::Timestamp with an error message saying that an offset store is required when using gRPC projections?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Depends what we mean by fail... I want avoid panicking as the source can be from anywhere, including something remote. We don't want remote providers of events to be able to halt our process.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry, looking further... we can fail as we do for other conditions such as when there's a problem with the offset store. The existing failures were considered in the light of being transient, but I think I've already broken that rule.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

UPDATE: offset stores are always provided as before. I've introduced a new volatile_offset_store::task function to produce an in-memory store designed to always start from the beginning of a journal. The type of offset is immaterial.

...and joins the offset store with the consumer for convenience. Also saves creating another task for the projection as these two things will always go hand-in-hand.
@huntc huntc changed the title Optional offset store Volatile offset store Nov 16, 2023
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.

LGTM, excellent alternative!

@huntc huntc merged commit d259516 into main Nov 16, 2023
1 check passed
@huntc huntc deleted the optional-offset-store branch November 16, 2023 08:05
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.

2 participants