typeregistry

package
v0.213.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

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 (t *TypeRegistry) GetVariantByName(discriminator reflect.Type, name string) optional.Option[reflect.Type]

func (*TypeRegistry) GetVariantByType added in v0.205.0

func (t *TypeRegistry) GetVariantByType(discriminator reflect.Type, variantType reflect.Type) optional.Option[string]

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.

Jump to

Keyboard shortcuts

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