0Pricing
gRPC & High Performance APIs · Lesson

Oneof, Maps & Well-Known Types

Model flexible and evolving data with protobuf oneof fields, maps, and the standard well-known types like Timestamp, Duration, and Any.

Beyond Plain Scalar Fields

Real schemas need more than strings and ints: mutually exclusive choices, key/value collections, and standard date/time types. Protobuf provides oneof, maps, and well-known types.

The oneof Construct

A oneof groups fields where at most one can be set at a time. Setting one clears the others, and only the active field is sent on the wire.

message Contact {
  oneof method {
    string email = 1;
    string phone = 2;
  }
}

All lessons in this course

  1. Protobuf Best Practices
  2. Schema Evolution Strategies
  3. Custom Protobuf Options
  4. Oneof, Maps & Well-Known Types
← Back to gRPC & High Performance APIs