Documentation
¶
Overview ¶
Package objectidproto builds a trogonobjectid.Definition from the trogon.object_id.v1alpha1.enum_value annotation on a protobuf enum value:
enum ObjectType {
OBJECT_TYPE_UNSPECIFIED = 0;
OBJECT_TYPE_TICKET = 1 [(trogon.object_id.v1alpha1.enum_value).object_type = "tkt"];
}
The object type and separator then live in one place for every language that uses the proto, and the other fields come from a base Definition:
var ticketDefinition = objectidproto.MustDefinition(acmev1.ObjectType_OBJECT_TYPE_TICKET, trogonobjectid.Definition{
StorageFormat: trogonobjectid.FormatDropPrefix,
Validate: trogonobjectid.ValidateUUID,
})
type ticketType struct{}
func (ticketType) Definition() trogonobjectid.Definition { return ticketDefinition }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Definition ¶
func Definition(value protoreflect.Enum, base trogonobjectid.Definition) (trogonobjectid.Definition, error)
Definition returns a Definition with ObjectType and Separator read from the enum value's annotation, over base. An absent separator gives trogonobjectid.DefaultSeparator. base carries the fields the annotation does not, so a new Definition field needs no change here.
func MustDefinition ¶
func MustDefinition(value protoreflect.Enum, base trogonobjectid.Definition) trogonobjectid.Definition
MustDefinition is like Definition but panics on error. Use it in package-level variables.
Types ¶
This section is empty.