You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Expected behavior**
A clear and concise description of what you expected to happen.
、、、
type defaultManager struct {
cli zrpc.Client
client ManagerClient // 复用 gRPC 客户端
}
func NewManager(cli zrpc.Client) Manager {
return &defaultManager{
cli: cli,
client: NewManagerClient(cli.Conn()), // 初始化时创建客户端
}
}
func (m *defaultManager) SetBaseHostResource(ctx context.Context, in *SetBaseHostResourceRequest, opts ...grpc.CallOption) (*SetBaseHostResourceResponse, error) {
return m.client.SetBaseHostResource(ctx, in, opts...) // 直接使用复用的客户端
}
、、、
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environments (please complete the following information):**
- OS: [e.g. Linux]
- go-zero version [v1.3.2]
- goctl version [goctl version 1.3.2 darwin/amd64]
**More description**
Add any other context about the problem here.
![Image](https://github.com/user-attachments/assets/c35d39b1-0359-4f5e-9962-872bb1321e65)
The text was updated successfully, but these errors were encountered:
zou-xinhua
changed the title
goctl rpc client go file not reuse connection lead to goroutine leak
goctl rpc client generate go file not reuse connection lead to goroutine leak
Feb 11, 2025
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior, if applicable:
The code is
{{.head}}
package {{.filePackage}}
import (
"context"
)
type (
{{.alias}}
)
func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
return &default{{.serviceName}}{
cli: cli,
}
}
{{if .hasComment}}{{.comment}}{{end}}
func (m *default{{.serviceName}}) {{.method}}(ctx context.Context{{if .hasReq}}, in {{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error) {
client := {{.package}}.New{{.rpcServiceName}}Client(m.cli.Conn())
return client.{{.method}}(ctx{{if .hasReq}}, in{{end}}, opts...)
}
The text was updated successfully, but these errors were encountered: