Documentation
¶
Overview ¶
Package storagegen holds engine-neutral helpers shared by the storage code generators (protoc-gen-ent and, per F027, protoc-gen-storage). Its job is to make the "can this resource field be deterministically wired into a persistence.Repository adapter?" decision IDENTICALLY across backends — so a resource behaves the same on ent and GORM, and a field the generator cannot map fails generation on both rather than being silently dropped (F027 G-002 fail-closed, G-005 cross-backend parity).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Mappable ¶
Mappable reports whether a field can be deterministically wired into a repository adapter (its setter, projection, and — where relevant — filter column). A field that is not Mappable has no automatic representation and must be surfaced to the developer, not dropped.
The order matters: a relationship is mappable even though it is a message or repeated field (it becomes an edge/association); only NON-relationship messages, repeated fields, and enums are unmappable.
Types ¶
type Field ¶
type Field struct {
Name string // proto field name (e.g. "fleet_id")
IsID bool // the resource primary key
IsTenant bool // account_id (supplied by the tenant mixin)
IsSecret bool // secret field (stored hash+cipher)
IsCredential bool // verify-only credential field (stored public_id + salted hash)
IsTags bool // map<string,string> (stored as a JSON column)
OutputOnly bool // AIP-203 OUTPUT_ONLY (surfaced on read, never written)
IsRepeated bool // a repeated (list) field
IsMessage bool // a nested message field (NOT a string map)
IsEnum bool // an enum field
IsRelationship bool // carries a has_one/has_many/belongs_to/many_to_many annotation
IsScalarFK bool // a scalar that is some relationship's foreign_key
HasColumnType bool // maps to a recognized scalar column type (string/int/bool/bytes/…)
}
Field is the engine-neutral view of a proto resource field that the storage generators classify. Both plugins populate it from the same proto annotations (field.v1 options + field_behavior + descriptor kind), so classification does not depend on any ent- or GORM-specific type.