codec

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 17

Documentation

Overview

Package codec will hold public codec contracts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column interface {
	ColumnName() string
	ColumnType() reflect.Type
	FieldName() string
}

Column is the reduced public column metadata contract.

type ColumnsSource

type ColumnsSource interface {
	Column(key string) (Column, bool)
	ColumnName(key string) (string, error)
}

ColumnsSource is the reduced public column metadata ask surface.

type Config

type Config struct {
	Body                 string
	SourceType           reflect.Type `json:"-" yaml:"-"`
	DestinationType      reflect.Type `json:"-" yaml:"-"`
	Args                 []string
	OutputTypeExpression string
}

Config describes the exact source and destination contract for a codec.

type Factory

type Factory interface {
	New(codecConfig *Config, options ...Option) (Instance, error)
}

Factory creates codec instances from config plus options during registration.

type Instance

type Instance interface {
	Value(ctx context.Context, raw interface{}, options ...Option) (interface{}, error)
}

Instance is the reduced public codec execution contract. Registered instances may be shared by concurrent invocations: Value must be concurrency-safe and must not retain invocation context, record pointers, or lookup options.

type Option

type Option func(o *Options)

Option mutates codec options.

func WithColumnsSource

func WithColumnsSource(columnSource ColumnsSource) Option

func WithOptions

func WithOptions(options ...interface{}) Option

func WithRecord

func WithRecord(record interface{}) Option

func WithResourceFS added in v1.0.0

func WithResourceFS(resources fs.FS) Option

WithResourceFS supplies package resources to codecs that compile external assets such as StructQL. The original fs.FS, including embed.FS, is retained.

func WithSelector

func WithSelector(selector Selector) Option

func WithTypeLookup

func WithTypeLookup(fn func(name string) (reflect.Type, error)) Option

func WithValueGetter

func WithValueGetter(valueGetter ValueGetter) Option

func WithValueLookup

func WithValueLookup(fn func(ctx context.Context, name string) (interface{}, error)) Option

type Options

type Options struct {
	LookupType  func(name string) (reflect.Type, error)
	Record      interface{}
	LookupValue func(ctx context.Context, name string) (interface{}, error)
	ResourceFS  fs.FS
	ColumnsSource
	Selector
	ValueGetter
	Options []interface{}
}

Options is the reduced public codec option bag.

It exists to support codec construction and execution only. It must not turn into a general-purpose runtime dependency transport for unrelated services.

func NewOptions

func NewOptions(opts []Option) *Options

NewOptions creates a new option bag from option functions.

func (*Options) Apply

func (o *Options) Apply(opts []Option)

Apply applies option functions to the option bag.

type Selector

type Selector interface {
	IgnoreRead()
}

Selector is the reduced public selector ask contract.

type ValueGetter

type ValueGetter interface {
	Value(ctx context.Context, paramName string) (interface{}, error)
}

ValueGetter is the reduced public value lookup contract.

Jump to

Keyboard shortcuts

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