generated from cloudwego/.github
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathdefault_tpl.yaml
54 lines (54 loc) · 2.45 KB
/
default_tpl.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
path: /rpc/{{ ReplaceString (ReplaceString .RealServiceName "." "_" -1) "/" "_" -1 }}/{{ ReplaceString (ReplaceString .RealServiceName "." "_" -1) "/" "_" -1 }}_default.go
update_behavior:
type: cover
body: |-
package {{ ReplaceString (ReplaceString .RealServiceName "." "_" -1) "/" "_" -1 }}
import (
{{- range $path, $aliases := .Imports}}
{{- if not $aliases }}
"{{$path}}"
{{- else if or (eq $path "github.com/cloudwego/kitex/client") (eq $path "github.com/cloudwego/kitex/pkg/serviceinfo")}}
{{- else}}
{{- range $alias, $is := $aliases}}
{{$alias}} "{{$path}}"
{{- end}}
{{- end}}
{{- end}}
{{- if .HasStreaming }}
"{{.ImportPath}}/{{ToLower .ServiceName}}"
{{end}}
"github.com/cloudwego/kitex/client/callopt"
"github.com/cloudwego/kitex/pkg/klog"
)
{{range .AllMethods}}
{{- if or .ClientStreaming .ServerStreaming}}
func {{.Name}} (ctx context.Context {{if not .ClientStreaming}}{{range .Args}}, {{.RawName}} {{.Type}}{{end}}{{end}}, callOptions ...callopt.Option) (stream {{ToLower .ServiceName}}.{{.ServiceName}}_{{.RawName}}Client, err error){
stream, err = defaultClient.{{.Name}}(ctx {{if not .ClientStreaming}}{{range .Args}}, {{.RawName}} {{end}}{{end}}, callOptions...)
if err != nil {
klog.CtxErrorf(ctx, "{{.Name}} call failed,err =%+v", err)
return nil, err
}
return stream, nil
}
{{ else }}
{{- if .Oneway}}
func {{.Name}}(ctx context.Context, {{- range .Args}} {{LowerFirst .Name}} {{.Type}}, {{end}} callOptions ...callopt.Option) (err error){
err = defaultClient.{{.Name}}(ctx, {{- range .Args}} {{LowerFirst .Name}}, {{end}} callOptions...)
if err != nil {
klog.CtxErrorf(ctx, "{{.Name}} call failed,err =%+v", err)
return err
}
return nil
}
{{else -}}
func {{.Name}}(ctx context.Context, {{range .Args}} {{LowerFirst .Name}} {{.Type}} ,{{end}} callOptions ...callopt.Option) (resp {{.Resp.Type}}, err error){
resp, err = defaultClient.{{.Name}}(ctx, {{- range .Args}} {{LowerFirst .Name}}, {{end}} callOptions...)
if err != nil {
klog.CtxErrorf(ctx, "{{.Name}} call failed,err =%+v", err)
return nil,err
}
return resp, nil
}
{{end}}
{{end}}
{{end}}