juzhiyuan commented on code in PR #6956: URL: https://github.com/apache/apisix/pull/6956#discussion_r860771100
########## docs/en/latest/xrpc.md: ########## @@ -0,0 +1,145 @@ +--- +title: xRPC +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## What is xRPC + +APISIX supports proxy TCP protocols, but there are times when a pure TCP protocol proxy is not enough. What you need is an application-specific proxy, such as Redis Proxy, Kafka Proxy, etc. Because some features must be coded and decoded for that protocol before they can be implemented. Review Comment: ```suggestion APISIX supports proxy TCP protocols, but there are times when a pure TCP protocol proxy is not enough. It would help if you had an application-specific proxy, such as Redis Proxy, Kafka Proxy, etc. In addition, some features must be coded and decoded for that protocol before they can be implemented. ``` ########## docs/en/latest/xrpc.md: ########## @@ -0,0 +1,145 @@ +--- +title: xRPC +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## What is xRPC + +APISIX supports proxy TCP protocols, but there are times when a pure TCP protocol proxy is not enough. What you need is an application-specific proxy, such as Redis Proxy, Kafka Proxy, etc. Because some features must be coded and decoded for that protocol before they can be implemented. + +Therefore, Apache APISIX implements an L4 protocol extension framework called xRPC that allows developers to customize application-specific protocols on top. Based on xRPC, developers can codec requests and responses through Lua code, and then implement fault injection, log reporting, dynamic routing, and other functions based on the understanding of the protocol content. Review Comment: ```suggestion Therefore, Apache APISIX implements an L4 protocol extension framework called xRPC that allows developers to customize application-specific protocols. Based on xRPC, developers can codec requests and responses through Lua code and then implement fault injection, log reporting, dynamic routing, and other functions based on understanding the protocol content. ``` ########## docs/en/latest/xrpc.md: ########## @@ -0,0 +1,145 @@ +--- +title: xRPC +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## What is xRPC + +APISIX supports proxy TCP protocols, but there are times when a pure TCP protocol proxy is not enough. What you need is an application-specific proxy, such as Redis Proxy, Kafka Proxy, etc. Because some features must be coded and decoded for that protocol before they can be implemented. + +Therefore, Apache APISIX implements an L4 protocol extension framework called xRPC that allows developers to customize application-specific protocols on top. Based on xRPC, developers can codec requests and responses through Lua code, and then implement fault injection, log reporting, dynamic routing, and other functions based on the understanding of the protocol content. + +Based on the xRPC framework, APISIX can provide a proxy implementation of several major application protocols. Users can also support their own private TCP-based application protocols based on this framework, giving them the precise granularity and higher-level 7-layer control similar to HTTP protocol proxies. Review Comment: ```suggestion Based on the xRPC framework, APISIX can provide a proxy implementation of several major application protocols. In addition, users can also support their own private TCP-based application protocols based on this framework, giving them precise granularity and higher-level 7-layer control similar to HTTP protocol proxies. ``` ########## docs/en/latest/xrpc.md: ########## @@ -0,0 +1,145 @@ +--- +title: xRPC +--- + +<!-- +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--> + +## What is xRPC + +APISIX supports proxy TCP protocols, but there are times when a pure TCP protocol proxy is not enough. What you need is an application-specific proxy, such as Redis Proxy, Kafka Proxy, etc. Because some features must be coded and decoded for that protocol before they can be implemented. + +Therefore, Apache APISIX implements an L4 protocol extension framework called xRPC that allows developers to customize application-specific protocols on top. Based on xRPC, developers can codec requests and responses through Lua code, and then implement fault injection, log reporting, dynamic routing, and other functions based on the understanding of the protocol content. + +Based on the xRPC framework, APISIX can provide a proxy implementation of several major application protocols. Users can also support their own private TCP-based application protocols based on this framework, giving them the precise granularity and higher-level 7-layer control similar to HTTP protocol proxies. + +## How to use + +Currently, the steps for users to use xRPC are relatively simple and can be handled quickly in just two steps. + +1. First enable the corresponding protocol in `conf/config.yaml`. + +```yaml +xrpc: + protocols: + - name: redis +``` + +2. Then specify the protocol in the relevant `stream_routes`. + +```json +{ + ... + "protocol": { + "name": "redis", + "conf": { + "faults": [ + { "delay": 5, "key": "bogus_key", "commands":["GET", "MGET"]} + ] + } + } +} +``` + +The TCP connection that hits that `stream_route` is then handled according to that protocol. + +## Configuration + +| Name | Type | Required | Default | Description | +|-------------|--------|----------|---------|-------------------------------------------------| +| name | string | True | | the protocol name | +| conf | | False | | the application-specific protocol configuration | +| superior_id | ID | False | | the ID of the superior stream route | + +## Scenarios + +### Fault injection + +Taking Redis protocol as an example, after decoding the RESP protocol of Redis, we can know the command and parameters of the current request, and then get the corresponding content according to the configuration, encode it using RESP protocol, and return it to the client. Review Comment: ```suggestion Taking Redis protocol as an example, after decoding the RESP protocol of Redis, we can know the command and parameters of the current request and then get the corresponding content according to the configuration, encode it using RESP protocol, and return it to the client. ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
