Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/explanation/protobuf-extension-naming.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ Claim your extension numbers here to prevent conflicts:
| 870001 | trogon.uuid.v1 | google.protobuf.EnumOptions |
| 870002 | trogon.uuid.v1 | google.protobuf.EnumValueOptions |
| 870010 | trogon.object_id.v1alpha1 | google.protobuf.EnumValueOptions |
| 870011–870999 | *Available* | — |
| 870011 | trogon.stream.v1alpha1 | google.protobuf.EnumValueOptions |
| 870012–870999 | *Available* | — |

## Examples in This Repo

Expand All @@ -99,6 +100,9 @@ trogon/uuid/v1/options.proto

trogon/object_id/v1alpha1/options.proto
└─ EnumValueOptions { object_type, separator } → enum_value (870010)

trogon/stream/v1alpha1/options.proto
└─ EnumValueOptions { prefix, separator } → enum_value (870011)
```

## Field Number Ranges
Expand Down
39 changes: 39 additions & 0 deletions proto/trogon/stream/v1alpha1/options.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
syntax = "proto3";
package trogon.stream.v1alpha1;

import "elixirpb.proto";
import "google/protobuf/descriptor.proto";

option (elixirpb.file).module_prefix = "TrogonProto.Stream.V1Alpha1";

// EnumValueOptions defines enum-value-level options for stream identity prefixes.
message EnumValueOptions {
// The stream prefix for this aggregate (e.g., "order", "account", "fanid").
string prefix = 1;

// Separator between prefix and identity value. Defaults to ":" if not set.
optional string separator = 2;
}

extend google.protobuf.EnumValueOptions {
// enum_value specifies the stream identity prefix for an enum value.
//
// Example usage:
//
// // acme/type/v1/stream_prefix.proto
// syntax = "proto3";
// package acme.type.v1;
//
// import "trogon/stream/v1alpha1/options.proto";
//
// enum StreamPrefix {
// STREAM_PREFIX_UNSPECIFIED = 0;
// STREAM_PREFIX_ORDER = 1 [(trogon.stream.v1alpha1.enum_value).prefix = "order"];
// STREAM_PREFIX_ACCOUNT = 2 [(trogon.stream.v1alpha1.enum_value) = {
// prefix: "account",
// separator: "-"
// }];
// }
//
optional EnumValueOptions enum_value = 870011;
}