Skip to content

Commit

Permalink
optimize: add a new option to not generate processor and thrift client (
Browse files Browse the repository at this point in the history
  • Loading branch information
HeyJavaBean authored Apr 12, 2024
1 parent 11c5538 commit f227ad9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions generator/golang/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ type Features struct {
EnableRefInterface bool `enable_ref_interface:"Generate Interface field without pointer type when 'thrift.is_interface=\"true\"' annotation is set to types in referred thrift."`
UseOption bool `use_option:"Parse specific Thrift annotations into struct-style option fields. If key not match, thriftgo will just ignore it."`
// ForceUseOption bool `use_option:"Forcefully parse all Thrift annotations into struct-style option fields. If parsing is not possible, an error will be thrown."`
NoFmt bool `no_fmt:"To achieve faster generation speed, skipping the formatting of Golang code can improve performance by approximately 50%."`
SkipEmpty bool `skip_empty:"If there's not content in file, just skip it. Later this feature will be a default feature."`
NoFmt bool `no_fmt:"To achieve faster generation speed, skipping the formatting of Golang code can improve performance by approximately 50%."`
SkipEmpty bool `skip_empty:"If there's not content in file, just skip it. Later this feature will be a default feature."`
NoProcessor bool `no_processor:" Do not generate default thrift processor and client. Later this feature will be a default feature."`
}

var defaultFeatures = Features{
Expand Down
2 changes: 2 additions & 0 deletions generator/golang/templates/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package templates
// Client .
var Client = `
{{define "ThriftClient"}}
{{- if not Features.NoProcessor}}
{{- UseStdLibrary "thrift"}}
{{- $BasePrefix := ServicePrefix .Base}}
{{- $BaseService := ServiceName .Base}}
Expand Down Expand Up @@ -134,5 +135,6 @@ type {{.Service.GoName}}_{{.Name}}Server interface {
}
{{- end}}{{/* Streaming */}}
{{- end}}{{/* range .Functions */}}
{{- end}}{{/* if not Features.NoProcessor */}}
{{- end}}{{/* define "ThriftClient" */}}
`
2 changes: 2 additions & 0 deletions generator/golang/templates/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package templates
// Processor .
var Processor = `
{{define "ThriftProcessor"}}
{{- if not Features.NoProcessor}}
{{- UseStdLibrary "thrift"}}
{{- $BasePrefix := ServicePrefix .Base}}
{{- $BaseService := ServiceName .Base}}
Expand Down Expand Up @@ -171,6 +172,7 @@ func (p *{{$ProcessName}}) Process(ctx context.Context, seqId int32, iprot, opro
{{- end -}}{{- /* end if not Has Streaming */ -}}
}
{{- end}}{{/* range .Functions */}}
{{- end}}{{/* if not Features.NoProcessor */}}
{{- range .Functions}}
{{$ArgsType := .ArgType}}
Expand Down

0 comments on commit f227ad9

Please sign in to comment.