io.vlingo.lattice.router.LoadBalancingCommandRouter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vlingo-lattice Show documentation
Show all versions of vlingo-lattice Show documentation
Tooling for reactive Domain-Driven Design projects that are highly concurrent. Includes compute grid, actor caching, spaces, cross-node cluster messaging, CQRS, and Event Sourcing support.
// Copyright © 2012-2020 VLINGO LABS. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
package io.vlingo.lattice.router;
import io.vlingo.actors.Definition;
import io.vlingo.actors.RouterSpecification;
import io.vlingo.actors.SmallestMailboxRouter;
import io.vlingo.lattice.model.Command;
/**
* The {@code CommandRouter} implementation for load-balancing on the {@code RoutableCommand}.
*/
public class LoadBalancingCommandRouter extends SmallestMailboxRouter implements CommandRouter {
/**
* Constructs my default state.
* @param totalRoutees the int number or routees to create
*/
public LoadBalancingCommandRouter(final int totalRoutees) {
super(new RouterSpecification(
totalRoutees,
Definition.has(CommandRouterWorkerActor.class, Definition.NoParameters),
CommandRouter.class));
}
/**
* Route to least busy routee.
* @see io.vlingo.lattice.router.CommandRouter#route(io.vlingo.lattice.router.RoutableCommand)
*/
@Override
public void route(final RoutableCommand
command) {
dispatchCommand(CommandRouter::route, command);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy