Skip to content

Instantly share code, notes, and snippets.

@lusis
Created February 13, 2020 02:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lusis/09570bdecdc3bc6dfe892e5e661722ca to your computer and use it in GitHub Desktop.
Save lusis/09570bdecdc3bc6dfe892e5e661722ca to your computer and use it in GitHub Desktop.
example.proto
syntax = "proto3"
package = "com.myorg.ptypes";
message User {
int64 id = 1;
UserStatus status = 2;
}
message Group {
int64 id = 1;
GroupStatus = 2;
}
// this is where the pain is
// because of same package scoping rules I have to duplicate the enum name or something in FRONT of the enum values
// there may be some overlap in the concepts but a groupstatus is inherently different than a user status
// having a common "status" enum that includes all possible status for either groups or users is untenable
// and harder to reason about
enum UserStatus {
USER_STATUS_UNKNOWN = 1;
USER_STATUS_ACTIVE = 2;
USER_STATUS_DISABLED = 3;
}
enum GroupStatus {
GROUP_STATUS_UNKNOWN = 1;
GROUP_STATUS_ACTIVE = 2;
GROUP_STATUS_DISABLED = 3;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment