![]() |
|
[C] GRPC Overview - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] GRPC Overview (/showthread.php?tid=6153189) |
GRPC Overview - Sigma - May 10, 2021 Package https://github.com/lixiangyun/grpc-c.git Description Given a protobuf definition (proto 3) provides routines to
Limitations
Build-time requirements (libgrpc-c)
See grpc-c/third-party and grpc/third-party For MacOS:
Generated code runtime library dependencies
Protobuf compilation Code protoc -I/usr/local/include \Patch to grpc-c to enable compilation against newer grpc library libgrpc-c was developed for a much older version of libgrpc ie 1.17. To compile against 1.35 (latest), using the following patch will suffice: Code diff --git a/lib/include/grpc-c/grpc-c.h b/lib/include/grpc-c/grpc-c.hDocker image (alpine) with grpc-c compiler available Image has been pushed to aaronk-docker-registry.eng.sig:5000 (repository: alpine-grpc-c-compiler) Deploy container (specifying bash), su - dev. The source code that was used to build the compiler etc is found in this directory, for reference. All required build/runtime support binaries/libraries are pre-installed (/usr/local/lib or standard location). Creating a C client API for a new service When writing a new service it is necessary to:
Required components We want to create a dependency chain that matches the following. client-app → libplm-XXXclient → libgrpc-c → libgrpc awarrenhttp (client-app) GRPC client application sends requests and receives responses. In this case, all operations are read-only and constitute the web policy. Client applications need only worry about populating the protobuf request structures and reading the responses. No encoding/packing/unpacking required. libplm-webclient Client API (C library) to the web config service as defined by the service protobuf definition + boilerplate code to perform initialization/destruction of the libgrpc-c context. As of this writing, the bulk of the code in this package is generated in a container (alpine-grpc-c-compiler) and the resultant files are manually copied into this package when needed the compiler will be integrated into the OMC build process. Technically this library isn't required but this approach ensures the code is reusable and simplifies the build process for the client application. libgrpc-c Wrapper library provides access to libgrpc's I/O routines (asynchronous + synchronous) interfaces to send/receive GRPC messages using the protobuf format. Creates threads to handle I/O (async only?) via libgrpc. Library also supports server-side but that is not currently required. libgrpc Core library provides I/O routines (ie using TLS) and performs (de)serialization of protobuf messages. |