Skip to content

Commit b5d57ad

Browse files
wineguoWineChord
wineguo
authored andcommitted
tpl: generate codecc-friendly service code
1 parent 4206802 commit b5d57ad

File tree

2 files changed

+27
-8
lines changed

2 files changed

+27
-8
lines changed

install/flatbuffers/asset_go/service_rpc.go.tpl

+14-4
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ type {{$svrName}}Impl struct {}
7575

7676
{{ with .LeadingComments }}// {{$rpcName}} {{.}}{{ end }}
7777
{{- if and $method.ClientStreaming $method.ServerStreaming }}
78-
func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
78+
func (s *{{$svrName}}Impl) {{$rpcName}}(
79+
stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
80+
) error {
7981
// Bidirectional streaming scenario processing logic (for reference only, please modify as needed).
8082
for {
8183
req, err := stream.Recv()
@@ -103,7 +105,9 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqTyp
103105
}
104106
}
105107
{{- else if $method.ClientStreaming }}
106-
func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
108+
func (s *{{$svrName}}Impl) {{$rpcName}}(
109+
stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
110+
) error {
107111
// Client streaming scenario processing logic (for reference only, please modify as needed).
108112
// all := []string{}
109113
for {
@@ -128,7 +132,10 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqTyp
128132
}
129133
}
130134
{{- else if $method.ServerStreaming }}
131-
func (s *{{$svrName}}Impl) {{$rpcName}}(req *{{$rpcReqType}}, stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
135+
func (s *{{$svrName}}Impl) {{$rpcName}}(
136+
req *{{$rpcReqType}},
137+
stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
138+
) error {
132139
// Server streaming scenario processing logic (for reference only, please modify as needed).
133140
log.Debugf("StreamClient server receive %v", req)
134141
for i := 0; i < 5; i++ {
@@ -147,7 +154,10 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(req *{{$rpcReqType}}, stream {{index (sp
147154
return nil
148155
}
149156
{{- else }}
150-
func (s *{{$svrName}}Impl) {{$rpcName}}(ctx context.Context, req *{{$rpcReqType}}) (*flatbuffers.Builder, error) {
157+
func (s *{{$svrName}}Impl) {{$rpcName}}(
158+
ctx context.Context,
159+
req *{{$rpcReqType}},
160+
) (*flatbuffers.Builder, error) {
151161
// Unary call: flatbuffers processing logic (for reference only, please modify as needed).
152162
log.Debugf("Simple server receive %v", req)
153163
// Replace 'Message' with the field name you want to operate on.

install/protobuf/asset_go/service_rpc.go.tpl

+13-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ type {{$svrName}}Impl struct {
6969

7070
{{ with .LeadingComments }}// {{$rpcName}} {{.}}{{ end }}
7171
{{- if and $method.ClientStreaming $method.ServerStreaming }}
72-
func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
72+
func (s *{{$svrName}}Impl) {{$rpcName}}(
73+
stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
74+
) error {
7375
// Bidirectional streaming scenario processing logic (for reference only, please modify as needed).
7476
for {
7577
_, err := stream.Recv()
@@ -87,7 +89,9 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqTyp
8789
}
8890
{{- else }}
8991
{{- if $method.ClientStreaming }}
90-
func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
92+
func (s *{{$svrName}}Impl) {{$rpcName}}(
93+
stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
94+
) error {
9195
// Client streaming scenario processing logic (for reference only, please modify as needed).
9296
for {
9397
_, err := stream.Recv()
@@ -101,7 +105,9 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(stream {{index (splitList "." $rpcReqTyp
101105
}
102106
{{- else }}
103107
{{- if $method.ServerStreaming }}
104-
func (s *{{$svrName}}Impl) {{$rpcName}}(req *{{$rpcReqType}}, stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server) error {
108+
func (s *{{$svrName}}Impl) {{$rpcName}}(
109+
req *{{$rpcReqType}}, stream {{index (splitList "." $rpcReqType) 0}}.{{$svrNameCamelCase}}_{{$rpcName}}Server,
110+
) error {
105111
// Server streaming scenario processing logic (for reference only, please modify as needed).
106112
for i := 0; i < 5; i++ {
107113
err := stream.Send(&{{$rpcRspType}}{})
@@ -112,7 +118,10 @@ func (s *{{$svrName}}Impl) {{$rpcName}}(req *{{$rpcReqType}}, stream {{index (sp
112118
return nil
113119
}
114120
{{- else }}
115-
func (s *{{$svrName}}Impl) {{$rpcName}}(ctx context.Context, req *{{$rpcReqType}}) (*{{$rpcRspType}}, error) {
121+
func (s *{{$svrName}}Impl) {{$rpcName}}(
122+
ctx context.Context,
123+
req *{{$rpcReqType}},
124+
) (*{{$rpcRspType}}, error) {
116125
rsp := &{{$rpcRspType}}{}
117126
return rsp, nil
118127
}

0 commit comments

Comments
 (0)