-
Notifications
You must be signed in to change notification settings - Fork 821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(codec): Unknown Service Handler (#1321) #1498
Conversation
pkg/remote/option.go
Outdated
@@ -21,6 +21,8 @@ import ( | |||
"net" | |||
"time" | |||
|
|||
"github.com/cloudwego/kitex/pkg/unknownservice/service" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove useless empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
ServiceName string | ||
} | ||
|
||
type UnknownServiceHandler interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The definition can put in unknowservice package directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import cycle not allowed
@@ -0,0 +1,85 @@ | |||
/* | |||
* Copyright 2021 CloudWeGo Authors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
pkg/unknownservice/unknown.go
Outdated
|
||
"github.com/cloudwego/kitex/pkg/protocol/bthrift" | ||
thrift "github.com/cloudwego/kitex/pkg/protocol/bthrift/apache" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pay attention to the import grouping
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
pkg/unknownservice/unknown.go
Outdated
*/ | ||
|
||
package unknownservice | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename to unknownservice_codec.go
server/server.go
Outdated
@@ -27,6 +27,7 @@ import ( | |||
"sync" | |||
"time" | |||
|
|||
unknownservice "github.com/cloudwego/kitex/pkg/unknownservice/service" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
format import
pkg/unknownservice/unknown.go
Outdated
) | ||
|
||
// UnknownCodec implements PayloadCodec | ||
type unknownCodec struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unknownServiceCodec
UnknownServiceHandler(ctx context.Context, serviceName, method string, request []byte) ([]byte, error) | ||
} | ||
|
||
// NewServiceInfo create serviceInfo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"NewServiceInfo create serviceInfo" ?
pkg/unknownservice/unknown.go
Outdated
"errors" | ||
"fmt" | ||
|
||
"github.com/cloudwego/kitex/pkg/protocol/bthrift" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bthrift is Deprecated
This feature involves a lot of details, and the PR does not meet expectations very well, so it is closed. However, thank you very much for your contribution! |
What type of PR is this?
feat: Unknown Service Handle new feature
Check the PR title.
we UnknownServiceHandler mechanism for a normal Kitex server to deal with requests with unknown service.
(Optional) Translate the PR title into Chinese.
我们为普通的Kitex服务器提供了UnknownServiceHandler机制来处理带有未知服务和方法的请求。
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
zh(optional):
unknown Service方案
1. 注入Handler
2. 处理请求
string, request []byte 信息,返回一个 Result []byte
3. 处理响应
4. 如何使用
type UnknownServiceImpl struct{}
(Optional) Which issue(s) this PR fixes:
Fixes #1321
(optional) The PR that updates user documentation: