Documentation ¶
Index ¶
- func ContextWithTypeRegistry(ctx context.Context, r *TypeRegistry) context.Context
- func FromContext(ctx context.Context) optional.Option[*TypeRegistry]
- type TypeRegistry
- func (t *TypeRegistry) GetVariantByName(discriminator reflect.Type, name string) optional.Option[reflect.Type]
- func (t *TypeRegistry) GetVariantByType(discriminator reflect.Type, variantType reflect.Type) optional.Option[string]
- func (t *TypeRegistry) IsSumTypeDiscriminator(discriminator reflect.Type) bool
- func (t *TypeRegistry) RegisterSumType(discriminator reflect.Type, variants map[string]reflect.Type)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTypeRegistry ¶
func ContextWithTypeRegistry(ctx context.Context, r *TypeRegistry) context.Context
ContextWithTypeRegistry adds a type registry to the given context.
func FromContext ¶ added in v0.205.0
func FromContext(ctx context.Context) optional.Option[*TypeRegistry]
FromContext retrieves the secrets schema.TypeRegistry previously added to the context with ContextWithTypeRegistry.
Types ¶
type TypeRegistry ¶
type TypeRegistry struct {
// contains filtered or unexported fields
}
TypeRegistry is used for dynamic type resolution at runtime. It stores associations between sum type discriminators and their variants, for use in encoding and decoding.
FTL manages the type registry for you, so you don't need to create one yourself.
func NewTypeRegistry ¶
func NewTypeRegistry() *TypeRegistry
NewTypeRegistry creates a new type registry. The type registry is used to instantiate types by their qualified name at runtime.
func (*TypeRegistry) GetVariantByName ¶ added in v0.205.0
func (*TypeRegistry) GetVariantByType ¶ added in v0.205.0
func (*TypeRegistry) IsSumTypeDiscriminator ¶ added in v0.205.0
func (t *TypeRegistry) IsSumTypeDiscriminator(discriminator reflect.Type) bool
func (*TypeRegistry) RegisterSumType ¶
func (t *TypeRegistry) RegisterSumType(discriminator reflect.Type, variants map[string]reflect.Type)
RegisterSumType registers a Go sum type with the type registry. Sum types are represented as enums in the FTL schema.