Class RouterChainFactory

java.lang.Object
io.kroxylicious.proxy.bootstrap.RouterChainFactory
All Implemented Interfaces:
AutoCloseable

public class RouterChainFactory extends Object implements AutoCloseable
Abstracts the creation of router instances, hiding the configuration required for instantiation at the point at which instances are created.

Each virtual cluster that references a router gets its own initialisation of that router's factory, so shared state (e.g. caches, metrics) is per-virtual-cluster.

  • Constructor Details

  • Method Details

    • forVirtualCluster

      public static RouterChainFactory forVirtualCluster(PluginFactoryRegistry pfr, VirtualCluster vc, @Nullable Map<String,RouterDefinition> routersByName)
      Creates a RouterChainFactory for a single virtual cluster. The factory initialises only the routers reachable from vc's router graph.
      Parameters:
      pfr - the plugin factory registry
      vc - the virtual cluster whose router graph to initialise
      routersByName - all router definitions by name (the graph may reference any of them)
      Returns:
      a new factory whose lifetime should match that of the virtual cluster
    • createRouter

      public io.kroxylicious.proxy.router.Router createRouter(String routerName, String virtualClusterName)
      Creates a new router instance for the given router name and virtual cluster.
      Parameters:
      routerName - the name of the router definition
      virtualClusterName - the name of the virtual cluster
      Returns:
      the created router instance
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable