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-client return parameter bug #214

Closed nydrani closed 3 years ago

nydrani commented 4 years ago

https://github.com/anz-bank/sysl-go/blob/master/codegen/arrai/grpc.arrai#L8

This arrai transform reads a jsonified sysl file, specifically this kind of structure:

"stmt": [
  {
    "ret": {
      "payload": "ok \u003c: depserver.HelloResponse"
    }
  }
],

This works for a sysl file where the data types are located separately from the endpoints. Kind of like:

depserver:
    !type HelloRequest:
        Content <: string:
    !type HelloResponse:
        Content <: string:

myserverdep[~gRPC
    Hello(input <: depserver.HelloRequest)[~gRPC]:
        return ok <: depserver.HelloResponse

In the situation where they are located together, e.g:

myserverdep[~gRPC
    Hello(input <: HelloRequest)[~gRPC]:
        return ok <: HelloResponse

    !type HelloRequest:
        Content <: string:
    !type HelloResponse:
        Content <: string:

the arrai transform is incorrect due to the linked line (line 8).

The solution is to make the transform read the last word past the final dot (final '.') and use that in the string templating/transform.

anzdaddy commented 4 years ago

~The output JSON is working as intended. See https://github.com/anz-bank/sysl/issues/1040#issuecomment-684417202 for details.~

~The arr.ai transform will have to accommodate it by inferring appname from its containing app.~

anzdaddy commented 3 years ago

This is related to https://github.com/anz-bank/sysl-go/issues/215 and https://github.com/anz-bank/sysl/issues/1040, but slightly different since the interpretation of return bodies is up the code generator.