-
Notifications
You must be signed in to change notification settings - Fork 35
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
atLeastOnce parameters #59
Comments
I often prefer a builder approach because fluent APIs are really good for discoverability even when we pay the cost of writing a few inner stage classes. We can even close the builder with the event handler (function or trait) and builds the final projection. |
If we create a |
Settings are good for general configuration, but here it was about parameters that are specific to a method, and are not used for other methods. atLeastOnce vs atMostOnce. |
Can we then pass a strategy instance, for example: CassandraProjection(
projectionId,
sourceProvider,
AtLeastOnce(100, 1.second),
handler) and CassandraProjection(
projectionId,
sourceProvider,
AtMostOnce,
handler) |
Or maybe we prefer build style? CassandraProjection(
projectionId,
sourceProvider,
handler).atLeastOnce(100, 1.second)
and CassandraProjection(
projectionId,
sourceProvider,
handler).atMostOnce |
Now that the handler isn't a function anymore, it doesn't need to be the last in the list, and we can close the builder by declaring how we want to treat the commits. |
I think the builder is not better than what we have. Builders are great for optional parameters, but these are mandatory choices. I don't think the strategy is easier to use, not as nice for IDE code completion. Additionally, very few will use atMostOnce. I have some experiments for grouping lying around and I think we need to add that to the mix before deciding here. |
Looking forward to it |
Or we move the two parameters for atLeastOnce to config (ProjectionSettings). Don’t think they will tuned much per projection. |
I understood that your idea is that those are mandatory parameters, like method arguments, and therefore should not be on the settings. Moreover, the settings are good for all projections, not only for at-least-once |
Yes, that was my initial thinking, but it should be possible to have default that normally works and then it can be tuned if needed instead. |
But then in that case we will have at-least-once settings that are exposed at API level, but maybe be useless. Like when using |
Unless we return a |
yes, that's nice. Defaults from config and possibility to amend. |
Implemented in #175 |
The
CassandraProjection.atLeastOnce
maybe has too many parameters to be convenient?We could remove
saveOffsetAfterElements
andsaveOffsetAfterDuration
and place them in configuration.Then have a builder style api to define them programmatically.
atLeastOnce
would then returnAtLeastOnceCassandraProjection extends CassandraProjection
which has the additionalwithSaveOffsetAfterElements
andwithSaveOffsetAfterDuration
.Probably not nice with the handler as second parameter list, but we talked about making the handler a trait instead of a function and then it will not be a second parameter list.
The text was updated successfully, but these errors were encountered: