Skip to content

Commit

Permalink
Proto generation
Browse files Browse the repository at this point in the history
  • Loading branch information
jackkleeman committed Aug 21, 2024
1 parent 7ed640f commit 704a1e0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions protoc-gen-go-restate/restate.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func genService(gen *protogen.Plugin, g *protogen.GeneratedFile, service *protog
func clientSignature(g *protogen.GeneratedFile, method *protogen.Method) string {
s := method.GoName + "("
s += "opts ..." + g.QualifiedGoIdent(sdkPackage.Ident("ClientOption")) + ") ("
s += g.QualifiedGoIdent(sdkPackage.Ident("TypedCallClient")) + "[" + "*" + g.QualifiedGoIdent(method.Input.GoIdent) + ", *" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
s += g.QualifiedGoIdent(sdkPackage.Ident("Client")) + "[" + "*" + g.QualifiedGoIdent(method.Input.GoIdent) + ", *" + g.QualifiedGoIdent(method.Output.GoIdent) + "]"
s += ")"
return s
}
Expand All @@ -280,18 +280,18 @@ func genClientMethod(gen *protogen.Plugin, g *protogen.GeneratedFile, method *pr
g.P("if len(opts) > 0 {")
g.P("cOpts = append(append([]sdk_go.ClientOption{}, cOpts...), opts...)")
g.P("}")
getClient := `c.ctx.`
var getClient string
switch serviceType {
case sdk.ServiceType_SERVICE:
getClient += `Service` + `("` + service.GoName + `",`
getClient = g.QualifiedGoIdent(sdkPackage.Ident("Service")) + `[*` + g.QualifiedGoIdent(method.Output.GoIdent) + `]` + `(c.ctx, "` + service.GoName + `",`
case sdk.ServiceType_VIRTUAL_OBJECT:
getClient += `Object` + `("` + service.GoName + `", c.key,`
getClient = g.QualifiedGoIdent(sdkPackage.Ident("Object")) + `[*` + g.QualifiedGoIdent(method.Output.GoIdent) + `]` + `(c.ctx, "` + service.GoName + `", c.key,`
default:
gen.Error(fmt.Errorf("Unexpected service type: %s", serviceType.String()))
return
}
getClient += `"` + method.GoName + `", cOpts...)`
g.P("return ", sdkPackage.Ident("NewTypedCallClient"), "[*", method.Input.GoIdent, ", *", method.Output.GoIdent, "]", `(`, getClient, `)`)
g.P("return ", sdkPackage.Ident("WithRequestType"), "[*", method.Input.GoIdent, "]", `(`, getClient, `)`)
g.P("}")
g.P()
return
Expand Down

0 comments on commit 704a1e0

Please sign in to comment.