mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-02-03 00:38:40 +08:00
Add opts ...grpc.CallOption
in grpc client (#1122)
* Add `opts ...grpc.CallOption` in grpc client * Update format * Update format * Add import package * Update format
This commit is contained in:
parent
022c100dc9
commit
d28cfe5f20
@ -23,7 +23,7 @@ package {{.filePackage}}
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"google.golang.org/grpc"
|
||||||
{{.package}}
|
{{.package}}
|
||||||
|
|
||||||
"github.com/tal-tech/go-zero/zrpc"
|
"github.com/tal-tech/go-zero/zrpc"
|
||||||
@ -51,13 +51,13 @@ func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} {
|
|||||||
`
|
`
|
||||||
|
|
||||||
callInterfaceFunctionTemplate = `{{if .hasComment}}{{.comment}}
|
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 = `
|
callFunctionTemplate = `
|
||||||
{{if .hasComment}}{{.comment}}{{end}}
|
{{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())
|
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…
Reference in New Issue
Block a user