io.kroxylicious.proxy.internal.package-info Maven / Gradle / Ivy
/*
* Copyright Kroxylicious Authors.
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
/**
* io.kroxylicious.proxy.internal contains Kroxylicious internal code implementing Proxying functionality using Netty.
* Understanding the Kroxylicious Pipeline
* The Kroxylicious pipeline for a client connection is composed of:
*
* - A {@link io.kroxylicious.proxy.internal.KafkaProxyInitializer} that initialises the downstream channel pipeline between client and kroxylicious
* - A {@link io.kroxylicious.proxy.internal.KafkaProxyFrontendHandler} that establishes the upstream channel pipeline to the broker and forwards requests
* from the downstream channel to the upstream channel
* - A {@link io.kroxylicious.proxy.internal.KafkaProxyBackendHandler} that writes responses read from the upstream channel back to the downstream channel
*
* KafkaProxyInitializer
* {@link io.kroxylicious.proxy.internal.KafkaProxyInitializer} is the ChannelInitializer for Kroxylicious. It is responsible for
* installing Handlers into the pipeline to implement behaviours including:
*
* - Decode SNI hostname
* - Resolve VirtualCluster for the channel
* - Decode Kafka Request messages
* - Encode Kafka Response messages
* - {@link io.kroxylicious.proxy.internal.KafkaProxyFrontendHandler} to handle Kroxylicious business logic
*
* Note that for this downstream Channel, the inbound direction carries Requests (we read requests from the channel) and the outbound direction carries Responses from the
* backend server (response are written to the channel). So Handlers are invoked first-to-last for Requests, and last-to-first for Responses.
* KafkaProxyFrontendHandler
* {@link io.kroxylicious.proxy.internal.KafkaProxyFrontendHandler} handles the proxy lifecycle, it:
*
* - Selects a backend server to proxy to using the {@link io.kroxylicious.proxy.filter.NetFilter} API
* - Initiates a Channel connection to the selected backend server
* - Creates a {@link io.kroxylicious.proxy.internal.KafkaProxyBackendHandler}
* - Writes messages read from the downstream channel to the upstream channel
* - Installs handlers into the backend channel pipeline, including the Users configured Custom Protocol Filters as well as Kafka Request Encoding and Response Decoding handlers
* - Configures a predicate for the channel, based on the installed Filters, to determine when to decode Kafka messages
*
* Note that for the upstream Channel, the outbound direction carries Requests (we write requests to the channel) and the inbound direction carries Responses from the
* backend server (we read responses from the channel). So Filters are installed into the pipeline in the reverse order that they are declared in the Kroxylicious configuration
* YAML. Pipeline Handlers are invoked last-to-first for Requests, and first-to-last for Responses.
* KafkaProxyBackendHandler
* {@link io.kroxylicious.proxy.internal.KafkaProxyBackendHandler} signals to the Frontend Handler when the upstream channel is ready to be written to, and it writes
* Responses to the downstream channel after it has read them from the upstream channel.
*/
package io.kroxylicious.proxy.internal;