Package io.kroxylicious.proxy.bootstrap
Class FilterChainFactory
java.lang.Object
io.kroxylicious.proxy.bootstrap.FilterChainFactory
- All Implemented Interfaces:
AutoCloseable
Builds per-connection filter instances for a single virtual cluster's filter chain.
Scope
AFilterChainFactory is scoped to one VirtualClusterModel.
Its lifetime is bound to that VCM — constructed when the VCM is built, closed when the VCM
is closed (driven by VirtualClusterRegistry when the lifecycle reaches
Stopped).
What it holds
- An ordered list of
NamedFilterDefinitions — the VC's filter chain, as resolved fromVirtualCluster.filters()(ordefaultFilterswhen the cluster opts in to the proxy-wide default chain). - A per-name map of initialized
FilterChainFactory.Wrappers. EachWrapperowns the expensiveinitResult(KMS clients, caches, rule files, etc.) produced byFilterFactory.initialize. Wrappers are deduped by name — a chain that referencesaudittwice (e.g. before-and-after positions) initializes theauditfactory once and reuses theinitResultacross both positions.
What it does
createFilters(FilterFactoryContext) returns a fresh list of Filter
instances for one downstream channel. The chain order is the order this factory was
constructed with; instances are fresh per-call, but the underlying initResult
is shared across all calls to this factory (i.e. across all connections to the same VC).-
Constructor Summary
ConstructorsConstructorDescriptionFilterChainFactory(PluginFactoryRegistry pfr, List<NamedFilterDefinition> filterChain) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()createFilters(io.kroxylicious.proxy.filter.FilterFactoryContext context) Creates a fresh list ofFilterinstances for the chain this factory was built with.static FilterChainFactoryempty()Returns aFilterChainFactorywith an empty filter chain, for callers that have no filters to apply and therefore noPluginFactoryRegistryto supply (for example virtual clusters that opt out of the default chain, and tests that do not exercise the chain).
-
Constructor Details
-
FilterChainFactory
-
-
Method Details
-
empty
Returns aFilterChainFactorywith an empty filter chain, for callers that have no filters to apply and therefore noPluginFactoryRegistryto supply (for example virtual clusters that opt out of the default chain, and tests that do not exercise the chain).- Returns:
- an empty
FilterChainFactory
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
createFilters
public List<FilterAndInvoker> createFilters(io.kroxylicious.proxy.filter.FilterFactoryContext context) Creates a fresh list ofFilterinstances for the chain this factory was built with. Returned instances are per-call — every connection gets its own filter instances — but the underlyinginitResultis shared across all connections through theFilterChainFactory.Wrappers held by this factory.- Parameters:
context- the filter factory context (typically per-connection)- Returns:
- the new chain, in the order the factory was constructed with; empty if this factory was constructed with a null or empty chain
-