belliottsmith commented on code in PR #33: URL: https://github.com/apache/cassandra-accord/pull/33#discussion_r1099887144
########## accord-core/src/main/java/accord/local/Commands.java: ########## @@ -0,0 +1,1073 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package accord.local; + +import accord.api.ProgressLog.ProgressShard; +import accord.api.Result; +import accord.api.RoutingKey; +import accord.local.Command.WaitingOn; +import accord.primitives.*; +import accord.utils.Invariants; +import accord.utils.async.AsyncChain; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +import java.util.Arrays; +import java.util.Map; +import java.util.function.Consumer; +import java.util.function.Function; + +import static accord.api.ProgressLog.ProgressShard.*; +import static accord.api.ProgressLog.ProgressShard.Local; +import static accord.local.Commands.EnsureAction.*; +import static accord.local.Status.*; +import static accord.local.Status.Known.ExecuteAtOnly; +import static accord.primitives.Route.isFullRoute; + +public class Commands Review Comment: I'm definitely not certain either way, just raising it for some discussion so we can iron it out. I think it is good that we haven't crowded out the `Command` file, but also not great that there's an imperfect separation of concerns. The constraints of how the state machine is advanced are in part encoded in `Command`, and we also reference `Commands` and `CommandsForKey`. Static methods also tend to be a bit more cluttered, and have to cast between `Command` types that mightn't be necessary for instance methods. For instance, it's possible that putting `Command` in its own package with all its versions in separate class files might make it tractable to put the functionality of `Commands` in the relevant type, and use the class hierarchy to in part encode the variations in behaviour. Or, we might simply define `Command` as an almost-empty placeholder that _only_ defines the methods in `Commands` AND the existing abstract methods only, then have `AbstractCommand` in a separate class that defines the state machine types. We can still benefit from instance methods (that just map directly from their current static methods in `Commands`) and perhaps have slightly cleaner separation of concerns. It might be that neither of these are cleaner, but exploring the possible structures here will have long term impact. -- 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]

