Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Alibaba MNN FlatBuffers gRPC Gen Go

From Leeroopedia


Knowledge Sources
Domains Serialization, RPC
Last Updated 2026-02-10 12:00 GMT

Overview

Go gRPC stub generator that emits client and server service interfaces using FlatBuffers as the wire format.

Description

go_generator.cc implements the Go gRPC stub generation logic. It generates Go source files containing service interfaces, client structs, and server handler registrations that use FlatBuffers for message serialization instead of Protocol Buffers. The generated code integrates with the standard google.golang.org/grpc package and uses the FlatBuffers Go runtime for marshaling and unmarshaling.

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/grpc/src/compiler/go_generator.cc
  • Lines: 1-446

Signature

namespace grpc_go_generator {
  grpc::string GetServices(const grpc_generator::File *file);
  grpc::string GetHeader(const grpc_generator::File *file,
                          const Parameters &params);
}

Import

#include "src/compiler/go_generator.h"

I/O Contract

Input Output
grpc_generator::File with service and method descriptors Go source file with gRPC service stubs and client interfaces

Usage Examples

// Generated Go service usage (shown as Go code):
// type MonsterStorageServer interface {
//     Store(context.Context, *flatbuffers.Builder) (*flatbuffers.Builder, error)
// }
//
// func RegisterMonsterStorageServer(s *grpc.Server, srv MonsterStorageServer) {
//     s.RegisterService(&_MonsterStorage_serviceDesc, srv)
// }

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment