first cut: Cassandra flows with support for conditional writes#3165
Draft
leviramsey wants to merge 1 commit intoakka:mainfrom
Draft
first cut: Cassandra flows with support for conditional writes#3165leviramsey wants to merge 1 commit intoakka:mainfrom
leviramsey wants to merge 1 commit intoakka:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
"Conditional" write flows result in
Either[T, AsyncResultSet]: theLeft[T]case is for when the write was applied, theRight[AsyncResultSet]case is when the write wasn't applied (e.g. in anINSERT ... IF NOT EXISTSthere was already a row). Per the Cassandra docs aroundwasApplied, if the query is an unconditional write, this will always be aLeft(for those, the conditional version of the flow is effectively just a less efficient version (extra wrapping/unwrapping) of the existing flow). I'm open to flipping theEither, but my sense is that this doesn't perfectly map onto the usual right-biasing conventions (the more interesting result is theAsyncResultSetIMO, even though that could be thought of as the failure).The Java API is a work in progress: this feels like how a sum type would be encoded in a lightweight way in Java and I don't know if it makes sense to expose functional combinators: since the typical next stage in the Scala API would be a
fold, I think Java code like:Perhaps the
foldcould be incorporated into the stage by requiring anAsyncResultSet => T, but that actually seems like a fairly niche use case