Add `opts ...grpc.CallOption` in grpc client (#1122)

* Add `opts ...grpc.CallOption` in grpc client

* Update format

* Update format

* Add import package

* Update format
master
chenquan 3 years ago committed by GitHub
parent 022c100dc9
commit d28cfe5f20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ package {{.filePackage}}
import (
"context"
"google.golang.org/grpc"
{{.package}}
"github.com/tal-tech/go-zero/zrpc"
@ -51,13 +51,13 @@ func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
`
callInterfaceFunctionTemplate = `{{if .hasComment}}{{.comment}}
{{end}}{{.method}}(ctx context.Context{{if .hasReq}},in *{{.pbRequest}}{{end}}) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error)`
{{end}}{{.method}}(ctx context.Context{{if .hasReq}}, in *{{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error)`
callFunctionTemplate = `
{{if .hasComment}}{{.comment}}{{end}}
func (m *default{{.serviceName}}) {{.method}}(ctx context.Context{{if .hasReq}},in *{{.pbRequest}}{{end}}) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error) {
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}})
return client.{{.method}}(ctx{{if .hasReq}}, in{{end}}, opts...)
}
`
)

Loading…
Cancel
Save