kitex
kitex copied to clipboard
Feature Proposal: UnknownMethodHandler for KitexThrift/KitexProtobuf requests
A normal Kitex server is based on the IDL generated code, responsible for decoding requests into the go struct for the method handler. If a request with a method name not defined in its IDL is sent to this server, it will simply complain "unknown method" and refuse to process it.
Kitex also provides the "binary generic server" way, which takes in a request payload as a binary slice and sends it to the generic method handler, regardless of the method requested.
The problem is, these two types of server can not both exist within one server.
In this proposal, we sugguest an UnknownMethodHandler
mechanism for a normal Kitex server to deal with requests with unknown methods.
If you are interested in implementing this feature, please reply with your lark id, and kindly prepare for a detailed tech plan.
Note: this might not be easy for a new Kitex contributor.
@Zzhiter Do note that there's no way to force the client to use the same idl as the server. Say the svr has only one method Foo
, you can always create another idl with method Bar
for the client.
“Kitex also provides the "binary generic server" way, which takes in a request payload as a binary slice and sends it to the generic method handler, regardless of the method requested.
The problem is, these two types of server can not both exist within one server.”
Does ‘one server’ refers to a normal server handle normal request and binary generic request at the same time? As mentioned below: https://www.cloudwego.io/zh/docs/kitex/tutorials/advanced-feature/generic-call/basic_usage/#%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%B3%9B%E5%8C%96%E8%B0%83%E7%94%A8-1:~:text=%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%B3%9B%E5%8C%96%E8%B0%83%E7%94%A8%E7%9A%84%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%92%8C%E6%9C%8D%E5%8A%A1%E7%AB%AF%E5%B9%B6%E4%B8%8D%E6%98%AF%E9%85%8D%E5%A5%97%E4%BD%BF%E7%94%A8%E7%9A%84%EF%BC%8C%E5%AE%A2%E6%88%B7%E7%AB%AF%E5%8F%AA%E8%A6%81%E4%BC%A0%E5%85%A5%E6%AD%A3%E7%A1%AE%E7%9A%84%20Thrift%20%E4%BA%8C%E8%BF%9B%E5%88%B6%E7%BC%96%E7%A0%81%E6%A0%BC%E5%BC%8F%E7%9A%84%E5%8F%82%E6%95%B0%EF%BC%8C%E5%8F%AF%E4%BB%A5%E8%AF%B7%E6%B1%82%E6%99%AE%E9%80%9A%20Thrift%20%E6%8E%A5%E5%8F%A3%E6%9C%8D%E5%8A%A1%E3%80%82 I don't understand why binary generic server is mentioned here. Is it to make a normal Kitex server handle unknown methods like a generic server? I'm a little confused.
@Zzhiter With this feature, a normal server shall be able to not only handle requests to its known methods, but also handle requests to unknown methods as the generic server way.