Implementation:Alibaba MNN FlatBuffers IDL Gen gRPC
Appearance
| Knowledge Sources | |
|---|---|
| Domains | Serialization, Code_Generation |
| Last Updated | 2026-02-10 12:00 GMT |
Overview
gRPC service stub code generator that produces client and server stubs using FlatBuffers as the message format.
Description
idl_gen_grpc.cpp implements the gRPC code generation backend for flatc. When a .fbs schema contains rpc_service declarations, this generator produces gRPC service stubs for the target language (C++, Go, or Java). It delegates the actual language-specific stub emission to the corresponding gRPC generator modules in the grpc/src/compiler/ directory.
Usage
Vendored dependency used internally by MNN for model serialization. Not directly imported by end users.
Code Reference
Source Location
- Repository: Alibaba_MNN
- File:
3rd_party/flatbuffers/src/idl_gen_grpc.cpp - Lines: 1-371
Signature
namespace flatbuffers {
bool GenerateGRPC(const Parser &parser,
const std::string &path,
const std::string &file_name);
}
Import
#include "flatbuffers/idl.h"
// Generator invoked internally by flatc
I/O Contract
| Input | Output |
|---|---|
Parsed Parser object with rpc_service definitions |
gRPC service stub source files in the target language |
Usage Examples
// Invoked by flatc:
// flatc --grpc --cpp schema.fbs
// Internally:
flatbuffers::Parser parser;
parser.Parse(schema_with_services);
flatbuffers::GenerateGRPC(parser, output_path, file_name);
Related Pages
Page Connections
Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment