belliottsmith commented on code in PR #10:
URL: https://github.com/apache/cassandra-accord/pull/10#discussion_r990761552
##########
accord-core/src/main/java/accord/messages/Apply.java:
##########
@@ -54,15 +63,59 @@ public Apply(Node.Id to, Topologies topologies, TxnId
txnId, Txn txn, Key homeKe
this.result = result;
}
+ @VisibleForImplementation
+ public Apply(Keys scope, long waitForEpoch, TxnId txnId, Txn txn, Key
homeKey, Timestamp executeAt, Deps deps, Writes writes, Result result)
+ {
+ super(scope, waitForEpoch);
+ this.txnId = txnId;
+ this.txn = txn;
+ this.homeKey = homeKey;
+ this.executeAt = executeAt;
+ this.deps = deps;
+ this.writes = writes;
+ this.result = result;
+ }
+
+ static Future<Void> waitAndReduce(Future<Void> left, Future<Void> right)
Review Comment:
To summarise the technical disagreement as I see it, here are the problems
raised with each approach:
**Callbacks**
[1] May not be invoked in some no-op scenario, where an immediate `Future`
might be
[2] May be invoked erroneously
**Future**
[3] May block threads erroneously
[4] May not handle exceptional completion
[5] _Inherently_ less efficient
[6] Is more opinionated - once we’re working with `Future` it is hard to
escape, and it gets woven through the APIs. Contrariwise, it is zero cost to
convert a callback to a `Future`
[7] Worse debuggability
Now, I have demonstrated a callback API that eliminates [1], leaving only
[2]. But I have yet to see an example of this kind of error, except perhaps the
invoking-more-than-once variant, that we also have trivial mechanisms for.
However, I have _additionally_ proposed introducing linter support to
address both [1] and [2], failing compilation if a callback is neither invoked
directly nor passed to a child function on any branch.
Whereas [3] we have an example of _right here_, and [4] is something that I
have seen often (indeed, it was an issue previously in this library). I cannot
see how they can be effectively addressed with linters, either.
Given the above, I think it is objectively the case that callbacks are more
suitable in cases where they are sufficient. I would appreciate it if you could
engage with my suggestions that address your concerns with callbacks, and
justify why you think the concerns I raise with `Future` are _less_ impactful
than those you have raised with callbacks.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]