mirror of
https://github.com/foomo/gotsrpc.git
synced 2025-10-16 12:35:35 +00:00
fix: fix undefined vars
This commit is contained in:
parent
2c66d6104f
commit
890d293450
@ -16,6 +16,9 @@ export class ServiceClient {
|
||||
async boolSlice(v:Array<boolean>|null):Promise<Array<boolean>|null> {
|
||||
return (await this.transport<{0:Array<boolean>|null}>("BoolSlice", [v]))[0]
|
||||
}
|
||||
async empty():Promise<void> {
|
||||
await this.transport<void>("Empty", [])
|
||||
}
|
||||
async float32(v:number):Promise<number> {
|
||||
return (await this.transport<{0:number}>("Float32", [v]))[0]
|
||||
}
|
||||
|
||||
@ -42,6 +42,11 @@ type (
|
||||
RetBoolSlice_0 []bool
|
||||
}
|
||||
|
||||
ServiceEmptyRequest struct {
|
||||
}
|
||||
ServiceEmptyResponse struct {
|
||||
}
|
||||
|
||||
ServiceFloat32Request struct {
|
||||
V float32
|
||||
}
|
||||
@ -449,6 +454,8 @@ func init() {
|
||||
gob.Register(ServiceBoolPtrResponse{})
|
||||
gob.Register(ServiceBoolSliceRequest{})
|
||||
gob.Register(ServiceBoolSliceResponse{})
|
||||
gob.Register(ServiceEmptyRequest{})
|
||||
gob.Register(ServiceEmptyResponse{})
|
||||
gob.Register(ServiceFloat32Request{})
|
||||
gob.Register(ServiceFloat32Response{})
|
||||
gob.Register(ServiceFloat32MapRequest{})
|
||||
@ -615,6 +622,9 @@ func (p *ServiceGoRPCProxy) handler(clientAddr string, request interface{}) (res
|
||||
req := request.(ServiceBoolSliceRequest)
|
||||
retBoolSlice_0 := p.service.BoolSlice(req.V)
|
||||
response = ServiceBoolSliceResponse{RetBoolSlice_0: retBoolSlice_0}
|
||||
case "ServiceEmptyRequest":
|
||||
p.service.Empty()
|
||||
response = ServiceEmptyResponse{}
|
||||
case "ServiceFloat32Request":
|
||||
req := request.(ServiceFloat32Request)
|
||||
retFloat32_0 := p.service.Float32(req.V)
|
||||
|
||||
@ -63,6 +63,16 @@ func (tsc *ServiceGoRPCClient) BoolSlice(v []bool) (retBoolSlice_0 []bool, clien
|
||||
return response.RetBoolSlice_0, nil
|
||||
}
|
||||
|
||||
func (tsc *ServiceGoRPCClient) Empty() (clientErr error) {
|
||||
req := ServiceEmptyRequest{}
|
||||
_, rpcCallErr := tsc.Client.Call(req)
|
||||
if rpcCallErr != nil {
|
||||
clientErr = rpcCallErr
|
||||
return
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (tsc *ServiceGoRPCClient) Float32(v float32) (retFloat32_0 float32, clientErr error) {
|
||||
req := ServiceFloat32Request{V: v}
|
||||
rpcCallRes, rpcCallErr := tsc.Client.Call(req)
|
||||
|
||||
@ -15,6 +15,7 @@ const (
|
||||
ServiceGoTSRPCProxyBool = "Bool"
|
||||
ServiceGoTSRPCProxyBoolPtr = "BoolPtr"
|
||||
ServiceGoTSRPCProxyBoolSlice = "BoolSlice"
|
||||
ServiceGoTSRPCProxyEmpty = "Empty"
|
||||
ServiceGoTSRPCProxyFloat32 = "Float32"
|
||||
ServiceGoTSRPCProxyFloat32Map = "Float32Map"
|
||||
ServiceGoTSRPCProxyFloat32Slice = "Float32Slice"
|
||||
@ -175,6 +176,21 @@ func (p *ServiceGoTSRPCProxy) ServeHTTP(w http.ResponseWriter, r *http.Request)
|
||||
}
|
||||
gotsrpc.Monitor(w, r, args, rets, callStats)
|
||||
return
|
||||
case ServiceGoTSRPCProxyEmpty:
|
||||
var (
|
||||
args []interface{}
|
||||
rets []interface{}
|
||||
)
|
||||
executionStart := time.Now()
|
||||
p.service.Empty()
|
||||
callStats.Execution = time.Since(executionStart)
|
||||
rets = []interface{}{}
|
||||
if err := gotsrpc.Reply(rets, callStats, r, w); err != nil {
|
||||
gotsrpc.ErrorCouldNotReply(w)
|
||||
return
|
||||
}
|
||||
gotsrpc.Monitor(w, r, args, rets, callStats)
|
||||
return
|
||||
case ServiceGoTSRPCProxyFloat32:
|
||||
var (
|
||||
args []interface{}
|
||||
|
||||
@ -14,6 +14,7 @@ type ServiceGoTSRPCClient interface {
|
||||
Bool(ctx go_context.Context, v bool) (retBool_0 bool, clientErr error)
|
||||
BoolPtr(ctx go_context.Context, v bool) (retBoolPtr_0 *bool, clientErr error)
|
||||
BoolSlice(ctx go_context.Context, v []bool) (retBoolSlice_0 []bool, clientErr error)
|
||||
Empty(ctx go_context.Context) (clientErr error)
|
||||
Float32(ctx go_context.Context, v float32) (retFloat32_0 float32, clientErr error)
|
||||
Float32Map(ctx go_context.Context, v map[float32]interface{}) (retFloat32Map_0 map[float32]interface{}, clientErr error)
|
||||
Float32Slice(ctx go_context.Context, v []float32) (retFloat32Slice_0 []float32, clientErr error)
|
||||
@ -124,6 +125,16 @@ func (tsc *HTTPServiceGoTSRPCClient) BoolSlice(ctx go_context.Context, v []bool)
|
||||
return
|
||||
}
|
||||
|
||||
func (tsc *HTTPServiceGoTSRPCClient) Empty(ctx go_context.Context) (clientErr error) {
|
||||
args := []interface{}{}
|
||||
reply := []interface{}{}
|
||||
clientErr = tsc.Client.Call(ctx, tsc.URL, tsc.EndPoint, "Empty", args, reply)
|
||||
if clientErr != nil {
|
||||
clientErr = pkg_errors.WithMessage(clientErr, "failed to call service.ServiceGoTSRPCProxy Empty")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (tsc *HTTPServiceGoTSRPCClient) Float32(ctx go_context.Context, v float32) (retFloat32_0 float32, clientErr error) {
|
||||
args := []interface{}{v}
|
||||
reply := []interface{}{&retFloat32_0}
|
||||
|
||||
@ -2,6 +2,9 @@ package service
|
||||
|
||||
type Handler struct{}
|
||||
|
||||
func (h *Handler) Empty() {
|
||||
}
|
||||
|
||||
func (h *Handler) Bool(v bool) bool {
|
||||
return v
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package service
|
||||
|
||||
type Service interface {
|
||||
Empty()
|
||||
Bool(v bool) bool
|
||||
BoolPtr(v bool) *bool
|
||||
Int(v int) int
|
||||
|
||||
10
go.go
10
go.go
@ -278,6 +278,12 @@ func renderTSRPCServiceProxies(services ServiceList, fullPackageName string, pac
|
||||
g.ind(1)
|
||||
var callArgs []string
|
||||
isSessionRequest := false
|
||||
g.l("var (")
|
||||
g.ind(1)
|
||||
g.l("args []interface{}")
|
||||
g.l("rets []interface{}")
|
||||
g.ind(-1)
|
||||
g.l(")")
|
||||
if len(method.Args) > 0 {
|
||||
var args []string
|
||||
var argsDecls []string
|
||||
@ -295,10 +301,6 @@ func renderTSRPCServiceProxies(services ServiceList, fullPackageName string, pac
|
||||
callArgs = append(callArgs, argName)
|
||||
skipArgI++
|
||||
}
|
||||
g.l("var (").ind(1)
|
||||
g.l("args []interface{}")
|
||||
g.l("rets []interface{}")
|
||||
g.ind(-1).l(")")
|
||||
if len(args) > 0 {
|
||||
g.l("var (")
|
||||
for _, argDecl := range argsDecls {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user