Interface RouterFactoryContext
RouterFactory initialisation and router creation,
providing access to the plugin registry and router identity.-
Method Summary
Modifier and TypeMethodDescriptionvoidDeclares that this router supports routes targeting the same cluster.pluginImplementationNames(Class<P> pluginClass) Returns the implementation names of the registered instances of the given plugin type.<P> PpluginInstance(Class<P> pluginClass, String implementationName) Gets a plugin instance for the given plugin type and name.Returns the names of the routes configured for this router.Returns the name of this router, as declared in the router definition.Returns aTopologyServicefor this router level.Returns the name of the virtual cluster that owns this router.
-
Method Details
-
virtualClusterName
String virtualClusterName()Returns the name of the virtual cluster that owns this router.- Returns:
- the virtual cluster name
-
routerName
String routerName()Returns the name of this router, as declared in the router definition.- Returns:
- the router name
-
pluginInstance
Gets a plugin instance for the given plugin type and name.- Type Parameters:
P- the plugin type- Parameters:
pluginClass- the plugin classimplementationName- the plugin implementation name- Returns:
- the plugin instance
- Throws:
UnknownPluginInstanceException- if the named implementation is unknown
-
routeNames
Returns the names of the routes configured for this router.These are the route names declared in the router definition, not route names that appear in the router's plugin configuration. Router implementations can use this during
RouterFactory.initialize(io.kroxylicious.proxy.router.RouterFactoryContext, C)to validate that route names referenced in the plugin configuration actually exist.- Returns:
- an unmodifiable set of route names
-
pluginImplementationNames
Returns the implementation names of the registered instances of the given plugin type.- Type Parameters:
P- the plugin type- Parameters:
pluginClass- the plugin class- Returns:
- the set of known implementation names
-
topologyService
TopologyService topologyService()Returns aTopologyServicefor this router level.The runtime creates the underlying topology cache on first call and populates it from METADATA responses flowing through the routing pipeline. If no router at a level calls this method, no cache is created and no cost is incurred.
When called during
RouterFactory.initialize(io.kroxylicious.proxy.router.RouterFactoryContext, C), this triggers cache creation as an opt-in side effect. The returned instance should not be stored in the factory's initialization data.When called during
RouterFactory.createRouter(io.kroxylicious.proxy.router.RouterFactoryContext, I), this returns a fresh per-connection instance backed by the shared cache. This is the instance the router should use for discovery methods (TopologyService.leaders(java.util.Map<java.lang.String, java.util.Set<java.lang.String>>),TopologyService.coordinators(java.lang.String, byte, java.util.Set<java.lang.String>), etc.).- Returns:
- the topology service for this router level
-