anz-bank / sysl-go

Communication library used by SYSL-generated code written in Go.
Apache License 2.0
10 stars 14 forks source link

grpc_handler generation is incorrect #204

Closed joshcarp closed 4 years ago

joshcarp commented 4 years ago

There are a number of incorrect lines in grpc hanling:

grpc_handler.go

// Code generated by sysl DO NOT EDIT.
package plzserver

import (
    "context"

    "github.com/anz-bank/sysl-go/core"
    pb "github.com/joshcarp/plz-stop-the-sysl/gen/pkg/servers/myserver/github.com/joshcarp/plz-stop-the-sysl/api/plzserver"

+        "github.com/joshcarp/plz-stop-the-sysl/gen/pkg/servers/myserver/depserver"

    "google.golang.org/grpc"
    "google.golang.org/grpc/codes"
    "google.golang.org/grpc/status"
)

// GrpcServiceHandler for myserver API
type GrpcServiceHandler struct {
    pb.UnimplementedMyserverServer
    genCallback               core.GrpcGenCallback
    serviceInterface          *GrpcServiceInterface
-   depserverDepserverService depserver.myserverdepClient
+        depserverDepserverService depserver.Client
}

// NewGrpcServiceHandler for myserver
func NewGrpcServiceHandler(
    genCallback core.GrpcGenCallback,
    serviceInterface *GrpcServiceInterface,
-   depserverDepserverService depserver.myserverdepClient,
+       depserverDepserverService depserver.Client,
) *GrpcServiceHandler {
    return &GrpcServiceHandler{
        genCallback:               genCallback,
        serviceInterface:          serviceInterface,
        depserverDepserverService: depserverDepserverService,
    }
}

// RegisterServer registers the myserver gRPC service
func (s *GrpcServiceHandler) RegisterServer(ctx context.Context, server *grpc.Server) {
    pb.RegisterMyserverServer(server, s)
}

// Hello ...
func (s *GrpcServiceHandler) Hello(ctx context.Context, req *pb.HelloRequest) (*pb.HelloResponse, error) {
    if s.serviceInterface.Hello == nil {
        return nil, status.Errorf(codes.Unimplemented, "method Hello not implemented")
    }

    ctx, cancel := s.genCallback.DownstreamTimeoutContext(ctx)
    defer cancel()
    client := HelloClient{
        DepserverHello: s.depserverDepserverService.Hello,
    }

    return s.serviceInterface.Hello(ctx, req, client)
}

grpc_handler.go

// Code generated by sysl DO NOT EDIT.
package plzserver

import (
    "context"
    "time"

    "github.com/anz-bank/sysl-go/config"
    "github.com/joshcarp/plz-stop-the-sysl/gen/pkg/servers/myserver/depserver"
+      pb "github.com/joshcarp/plz-stop-the-sysl/api/plzserver"
-   pb "github.com/joshcarp/plz-stop-the-sysl/gen/pkg/servers/myserver/github.com/joshcarp/plz-stop-the-sysl/api/plzserver"

    "google.golang.org/grpc"
)

// Hello Client
type HelloClient struct {
-   DepserverHello func(ctx context.Context, req *depserver.HelloRequest, opts ...grpc.CallOption) (*depserver.DepserverHelloResponse, error)
+     DepserverHello func(ctx context.Context, req *pb.HelloRequest, opts ...grpc.CallOption) (*pb.HelloRequest, error)
}

// GrpcServiceInterface for myserver
type GrpcServiceInterface struct {
    Hello func(ctx context.Context, req *pb.HelloRequest, client HelloClient) (*pb.HelloResponse, error)
}

// DownstreamConfig for myserver
type DownstreamConfig struct {
    ContextTimeout time.Duration                   `yaml:"contextTimeout"`
    Depserver      config.CommonGRPCDownstreamData `yaml:"depserver"`
}
nydrani commented 4 years ago

Fixed with: https://github.com/anz-bank/sysl-go/commit/7b3ce5ee7e8e5fb584fc8952fb2a21b1b92765fc