flatbuffers/grpc/examples
2023-05-09 09:33:30 -07:00
..
go Support file_identifier in Go (#7904) 2023-04-26 05:15:09 +00:00
python/greeter Optionally generate Python type annotations (#7858) 2023-04-28 09:38:29 -07:00
swift/Greeter FlatBuffers Version 23.5.9 (#7945) 2023-05-09 09:33:30 -07:00
ts/greeter [TS/JS] Entry point per namespace and reworked 1.x compatible single file build (#7510) 2023-01-21 12:22:22 -08:00
greeter.fbs
README.md Working on a python example plus fixing python grpc code (#6456) 2021-02-25 14:38:12 -08:00

Languages known issues

Python

  • Assert the type required in your server/client since python is able to receive Bytes array or utf8 strings.
def SayHello(self, request, context):
    # request might be a byte array or a utf8 string

    r = HelloRequest.HelloRequest().GetRootAs(request, 0)
    reply = "Unknown"
    if r.Name():
        reply = r.Name()
    # Issues might happen if type checking isnt present.
    # thus encoding it as a `reply.decode('UTF-8')`
    return build_reply("welcome " + reply.decode('UTF-8'))

This can be prevented by making sure all the requests coming to/from python are Bytes array

def say_hello(stub, builder):
    hello_request = bytes(builder.Output())
    reply = stub.SayHello(hello_request)
    r = HelloReply.HelloReply.GetRootAs(reply)
    print(r.Message())

Go

  • Always requires the content-type of the payload to be set to application/grpc+flatbuffers

example: .SayHello(ctx, b, grpc.CallContentSubtype("flatbuffers"))