objectidproto

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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. Keep the result in a package-level variable, because Definition methods run on every call:

var ticketDefinition = func() trogonobjectid.Definition {
	def := objectidproto.MustDefinition(acmev1.ObjectType_OBJECT_TYPE_TICKET)
	def.StorageFormat = trogonobjectid.FormatDropPrefix
	def.Validate = trogonobjectid.ValidateUUID
	return def
}()

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) (trogonobjectid.Definition, error)

Definition returns a Definition with ObjectType and Separator read from the enum value's annotation. An absent separator gives trogonobjectid.DefaultSeparator. Set the other fields on the result.

func MustDefinition

func MustDefinition(value protoreflect.Enum) trogonobjectid.Definition

MustDefinition is like Definition but panics on error. Use it in package-level variables.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL