Skip to content
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

remove xcpu #338

Merged
merged 2 commits into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions client/egrpc/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ import (

// Config ...
type Config struct {
Addr string // 连接地址,直连为127.0.0.1:9001,服务发现为etcd:///appname
BalancerName string // 负载均衡方式,默认round robin
OnFail string // 失败后的处理方式,panic | error
DialTimeout time.Duration // 连接超时,默认3s
ReadTimeout time.Duration // 读超时,默认1s
SlowLogThreshold time.Duration // 慢日志记录的阈值,默认600ms
EnableBlock bool // 是否开启阻塞,默认开启
EnableOfficialGrpcLog bool // 是否开启官方grpc日志,默认关闭
EnableWithInsecure bool // 是否开启非安全传输,默认开启
EnableMetricInterceptor bool // 是否开启监控,默认开启
EnableTraceInterceptor bool // 是否开启链路追踪,默认开启
EnableAppNameInterceptor bool // 是否开启传递应用名,默认开启
EnableTimeoutInterceptor bool // 是否开启超时传递,默认开启
EnableAccessInterceptor bool // 是否开启记录请求数据,默认不开启
EnableAccessInterceptorReq bool // 是否开启记录请求参数,默认不开启
EnableAccessInterceptorRes bool // 是否开启记录响应参数,默认不开启
EnableCPUUsage bool // 是否开启CPU利用率,默认开启
EnableServiceConfig bool // 是否开启服务配置,默认开启
Addr string // 连接地址,直连为127.0.0.1:9001,服务发现为etcd:///appname
BalancerName string // 负载均衡方式,默认round robin
OnFail string // 失败后的处理方式,panic | error
DialTimeout time.Duration // 连接超时,默认3s
ReadTimeout time.Duration // 读超时,默认1s
SlowLogThreshold time.Duration // 慢日志记录的阈值,默认600ms
EnableBlock bool // 是否开启阻塞,默认开启
EnableOfficialGrpcLog bool // 是否开启官方grpc日志,默认关闭
EnableWithInsecure bool // 是否开启非安全传输,默认开启
EnableMetricInterceptor bool // 是否开启监控,默认开启
EnableTraceInterceptor bool // 是否开启链路追踪,默认开启
EnableAppNameInterceptor bool // 是否开启传递应用名,默认开启
EnableTimeoutInterceptor bool // 是否开启超时传递,默认开启
EnableAccessInterceptor bool // 是否开启记录请求数据,默认不开启
EnableAccessInterceptorReq bool // 是否开启记录请求参数,默认不开启
EnableAccessInterceptorRes bool // 是否开启记录响应参数,默认不开启
//EnableCPUUsage bool // 是否开启CPU利用率,默认开启
EnableServiceConfig bool // 是否开启服务配置,默认开启
EnableFailOnNonTempDialError bool

keepAlive *keepalive.ClientParameters
Expand All @@ -56,6 +56,6 @@ func DefaultConfig() *Config {
EnableAccessInterceptorReq: false,
EnableAccessInterceptorRes: false,
EnableServiceConfig: true,
EnableCPUUsage: true,
//EnableCPUUsage: true,
}
}
1 change: 0 additions & 1 deletion client/egrpc/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func TestDefaultConfig(t *testing.T) {
EnableAccessInterceptor: false,
EnableAccessInterceptorReq: false,
EnableAccessInterceptorRes: false,
EnableCPUUsage: true,
EnableFailOnNonTempDialError: true,
EnableServiceConfig: true,
keepAlive: nil,
Expand Down
12 changes: 6 additions & 6 deletions client/egrpc/interceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ func (c *Container) defaultUnaryClientInterceptor() grpc.UnaryClientInterceptor
return func(ctx context.Context, method string, req, reply interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error {
// https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md
ctx = metadata.AppendToOutgoingContext(ctx, "app", eapp.Name())
if c.config.EnableCPUUsage {
ctx = metadata.AppendToOutgoingContext(ctx, "enable-cpu-usage", "true")
}
//if c.config.EnableCPUUsage {
// ctx = metadata.AppendToOutgoingContext(ctx, "enable-cpu-usage", "true")
//}
return invoker(ctx, method, req, reply, cc, opts...)
}
}
Expand Down Expand Up @@ -287,9 +287,9 @@ func (c *Container) defaultStreamClientInterceptor() grpc.StreamClientIntercepto
return func(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, streamer grpc.Streamer, opts ...grpc.CallOption) (grpc.ClientStream, error) {
// https://github.com/grpc/grpc-go/blob/master/Documentation/grpc-metadata.md
ctx = metadata.AppendToOutgoingContext(ctx, "app", eapp.Name())
if c.config.EnableCPUUsage {
ctx = metadata.AppendToOutgoingContext(ctx, "enable-cpu-usage", "true")
}
//if c.config.EnableCPUUsage {
// ctx = metadata.AppendToOutgoingContext(ctx, "enable-cpu-usage", "true")
//}
return streamer(ctx, desc, cc, method, opts...)
}
}
Expand Down
4 changes: 2 additions & 2 deletions client/egrpc/interceptor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ type GreeterHeader struct {
// SayHello ...
func (g GreeterHeader) SayHello(context context.Context, request *helloworld.HelloRequest) (*helloworld.HelloResponse, error) {
appName := tools.GrpcHeaderValue(context, "app")
cpu := tools.GrpcHeaderValue(context, "enable-cpu-usage")
assert.Equal(g.t, "true", cpu)
//cpu := tools.GrpcHeaderValue(context, "enable-cpu-usage")
//assert.Equal(g.t, "true", cpu)
assert.Equal(g.t, "egrpc.test", appName)

return &helloworld.HelloResponse{
Expand Down
123 changes: 0 additions & 123 deletions internal/xcpu/cgroup.go

This file was deleted.

Loading