Skip to content

Commit

Permalink
fix: streaming support including dot-separated thrift file (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
felix021 committed Jan 18, 2024
1 parent 9649481 commit 54ad8e6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/push-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ jobs:
go mod init codegen-test
go mod edit -replace=github.com/apache/thrift=github.com/apache/[email protected]
go mod edit -replace github.com/cloudwego/thriftgo=${LOCAL_REPO}
go mod edit -replace github.com/cloudwego/kitex=github.com/cloudwego/kitex@develop
go mod tidy
bash -version
bash ./codegen_install_check.sh
Expand Down
7 changes: 3 additions & 4 deletions generator/golang/templates/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,18 +119,17 @@ func (p *{{$ClientName}}) {{- template "FunctionSignature" . -}} {
}
{{- if or .Streaming.ClientStreaming .Streaming.ServerStreaming}}
{{- $arg := index .Arguments 0}}
{{- $ResponseType := .FunctionType.Name}}
type {{.Service.GoName}}_{{.Name}}Server interface {
{{- UseStdLibrary "streaming" -}}
streaming.Stream
{{if .Streaming.ClientStreaming }}
Recv() (*{{$arg.Type.Name}}, error)
Recv() ({{$arg.GoTypeName}}, error)
{{end}}
{{if .Streaming.ServerStreaming}}
Send(*{{$ResponseType}}) error
Send({{.ResponseGoTypeName}}) error
{{end}}
{{if and .Streaming.ClientStreaming (not .Streaming.ServerStreaming) }}
SendAndClose(*{{$ResponseType}}) error
SendAndClose({{.ResponseGoTypeName}}) error
{{end}}
}
{{- end}}{{/* Streaming */}}
Expand Down
2 changes: 1 addition & 1 deletion generator/golang/templates/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var FunctionSignature = `
{{- $arg := index .Arguments 0}}
{{- .GoName}}(
{{- if and .Streaming.ServerStreaming (not .Streaming.ClientStreaming) -}}
req *{{$arg.Type}},
req {{$arg.GoTypeName}},
{{- end -}}
stream {{.Service.GoName}}_{{.Name}}Server) (err error)
{{- else -}}
Expand Down
7 changes: 3 additions & 4 deletions generator/golang/templates/slim/slim.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,17 @@ func (p *{{$TypeName}}) Error() string {
{{- range .Functions}}
{{- if or .Streaming.ClientStreaming .Streaming.ServerStreaming}}
{{- $arg := index .Arguments 0}}
{{- $ResponseType := .FunctionType.Name}}
type {{.Service.GoName}}_{{.Name}}Server interface {
{{- UseStdLibrary "streaming" -}}
streaming.Stream
{{if .Streaming.ClientStreaming }}
Recv() (*{{$arg.Type.Name}}, error)
Recv() ({{$arg.GoTypeName}}, error)
{{end}}
{{if .Streaming.ServerStreaming}}
Send(*{{$ResponseType}}) error
Send({{.ResponseGoTypeName}}) error
{{end}}
{{if and .Streaming.ClientStreaming (not .Streaming.ServerStreaming) }}
SendAndClose(*{{$ResponseType}}) error
SendAndClose({{.ResponseGoTypeName}}) error
{{end}}
}
{{- end}}{{/* Streaming */}}
Expand Down
2 changes: 1 addition & 1 deletion version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@

package version

const ThriftgoVersion = "0.3.5"
const ThriftgoVersion = "0.3.6"

0 comments on commit 54ad8e6

Please sign in to comment.