add client request timeout option support
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
7b349ba1ca
commit
254448bf74
11
util.go
11
util.go
@ -32,9 +32,9 @@ func unexport(s string) string {
|
|||||||
|
|
||||||
func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) {
|
func generateServiceClient(gfile *protogen.GeneratedFile, service *protogen.Service) {
|
||||||
serviceName := service.GoName
|
serviceName := service.GoName
|
||||||
if rule, ok := getMicroApiService(service); ok {
|
//if rule, ok := getMicroApiService(service); ok {
|
||||||
gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", "))
|
// gfile.P("// client wrappers ", strings.Join(rule.ClientWrappers, ", "))
|
||||||
}
|
// }
|
||||||
gfile.P("type ", unexport(serviceName), "Client struct {")
|
gfile.P("type ", unexport(serviceName), "Client struct {")
|
||||||
gfile.P("c ", microClientPackage.Ident("Client"))
|
gfile.P("c ", microClientPackage.Ident("Client"))
|
||||||
gfile.P("name string")
|
gfile.P("name string")
|
||||||
@ -83,6 +83,11 @@ func generateServiceClientMethods(gfile *protogen.GeneratedFile, service *protog
|
|||||||
gfile.P(")")
|
gfile.P(")")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if rule, ok := getMicroApiMethod(method); ok {
|
||||||
|
if rule.Timeout > 0 {
|
||||||
|
gfile.P("opts = append(opts, ", microClientPackage.Ident("WithRequestTimeout"), "(time.Second*", rule.Timeout, "))")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
|
if !method.Desc.IsStreamingServer() && !method.Desc.IsStreamingClient() {
|
||||||
gfile.P("rsp := &", gfile.QualifiedGoIdent(method.Output.GoIdent), "{}")
|
gfile.P("rsp := &", gfile.QualifiedGoIdent(method.Output.GoIdent), "{}")
|
||||||
|
Loading…
Reference in New Issue
Block a user