Package io.kroxylicious.proxy.bootstrap
Class RouterChainFactory
java.lang.Object
io.kroxylicious.proxy.bootstrap.RouterChainFactory
- All Implemented Interfaces:
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 Summary
ConstructorsConstructorDescriptionRouterChainFactory(PluginFactoryRegistry pfr, List<VirtualCluster> virtualClusters, List<RouterDefinition> routerDefinitions) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()io.kroxylicious.proxy.router.RoutercreateRouter(String routerName, String virtualClusterName) Creates a new router instance for the given router name and virtual cluster.static RouterChainFactoryforVirtualCluster(PluginFactoryRegistry pfr, VirtualCluster vc, Map<String, RouterDefinition> routersByName) Creates aRouterChainFactoryfor a single virtual cluster.
-
Constructor Details
-
RouterChainFactory
public RouterChainFactory(PluginFactoryRegistry pfr, List<VirtualCluster> virtualClusters, @Nullable List<RouterDefinition> routerDefinitions)
-
-
Method Details
-
forVirtualCluster
public static RouterChainFactory forVirtualCluster(PluginFactoryRegistry pfr, VirtualCluster vc, @Nullable Map<String, RouterDefinition> routersByName) Creates aRouterChainFactoryfor a single virtual cluster. The factory initialises only the routers reachable fromvc's router graph.- Parameters:
pfr- the plugin factory registryvc- the virtual cluster whose router graph to initialiseroutersByName- 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 definitionvirtualClusterName- the name of the virtual cluster- Returns:
- the created router instance
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-