🔌 gRPC
Beginner
What is a `.proto` file?
Answer
A .proto file is the Interface Definition Language (IDL) source file for Protocol Buffers and gRPC. It defines: (1) Messages — data structures with typed fields, e.g., message User { int32 id = 1; string name = 2; }; (2) Services — collections of RPC methods, e.g., service UserService { rpc GetUser(GetUserRequest) returns (User); }; (3) Enums, oneof fields, map types, nested messages. The protoc compiler reads .proto files and generates language-specific code (stubs, message classes). The syntax = "proto3"; declaration at the top specifies the Protobuf version. Field numbers (e.g., = 1) identify fields in the binary encoding — they must never change once used in production, as they're part of the wire format.