-
Notifications
You must be signed in to change notification settings - Fork 575
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(grpc): initialize default metadata #4169
base: main
Are you sure you want to change the base?
Conversation
bfea8ad
to
b5fe944
Compare
b5fe944
to
437e92d
Compare
9f5dc07
to
403ca31
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #4169 +/- ##
==========================================
+ Coverage 84.55% 85.20% +0.65%
==========================================
Files 491 519 +28
Lines 46778 50128 +3350
Branches 5601 5233 -368
==========================================
+ Hits 39551 42713 +3162
- Misses 7191 7389 +198
+ Partials 36 26 -10 ☔ View full report in Codecov by Sentry. |
8412bae
to
b7ca3d3
Compare
奇怪,啥参数没改,单测就报 |
288b3dd
to
0662d18
Compare
终于过了…… |
let genericFunctionName; | ||
switch (genericFunctionSelector) { | ||
case 0: | ||
options.metadata.set('rpc.method.type', 'unary'); |
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.
这里的 metadata,不能是写死的,要么做到外部可覆盖,要么就搞一个私有的 key 好了,比如叫 midway.rpc.method.type啥的
@@ -1,6 +1,7 @@ | |||
import { join } from 'path'; | |||
|
|||
export const grpcServer = { | |||
url: 'localhost:6568', |
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.
最好还是新开一个,确保老的不受影响。
da0032d
to
4354f91
Compare
一折腾又炸了~ |
18399b7
to
b35590d
Compare
win 下面 jest 调试真麻烦…… |
可以搞个gitpod |
} else { | ||
clientOptions.metadata = new Metadata(); | ||
} | ||
clientOptions.metadata.set('rpc.definition', definition); |
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.
这里有问题吧,如果 clientOptions.metadata 有值,就被覆盖了吧。
这里是不是这样就行了
const meta = new Metadata();
meta.set('xx', xx);
clientOptions.metadata = clientOptions.metadata ? meta.merge(clientOptions.metadata) : meta;
caadbcf
to
75e17e6
Compare
@@ -71,6 +71,17 @@ export class GRPCClients extends Map { | |||
connectionService[methodName] = ( | |||
clientOptions: IClientOptions = {} | |||
) => { | |||
const meta = new Metadata(); | |||
meta.set('rpc.definition', definition); |
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.
话说传递这些有啥用?客户端自己应该都知道吧,不然没法解析出来找到服务了。另外可能也会有性能和安全性问题 🤔
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.
来都来了~
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.
还是得严谨点。。
75e17e6
to
5922751
Compare
5922751
to
9c770a2
Compare
9c770a2
to
63e7dc1
Compare
key: rpc.method.type value: unary|server|client
63e7dc1
to
57fa626
Compare
请求中添加 Meta 信息: