"Fossies" - the Fresh Open Source Software Archive

Member "flatbuffers-23.1.21/grpc/examples/README.md" (21 Jan 2023, 1020 Bytes) of package /linux/misc/flatbuffers-23.1.21.tar.gz:

As a special service "Fossies" has tried to format the requested source page into HTML format (assuming markdown format). Alternatively you can here view or download the uninterpreted source code file. A member file download can also be achieved by clicking within a package contents listing on the according byte size field.

Languages known issues


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)


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