miruken

package module
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: MIT Imports: 13 Imported by: 13

README

Miruken

Core Miruken

Documentation

Index

Constants

View Source
const (
	FilterStage              = 0
	FilterStageLogging       = 10
	FilterStateAuthorization = 30
	FilterStageValidation    = 50
)

Filter stage priorities.

Variables

View Source
var (
	Handled           = HandleResult{true, false, nil}
	HandledAndStop    = HandleResult{true, true, nil}
	NotHandled        = HandleResult{false, false, nil}
	NotHandledAndStop = HandleResult{false, true, nil}
)
View Source
var WithAncestor = WithAxis(TraverseAncestor)
View Source
var WithDescendant = WithAxis(TraverseDescendant)
View Source
var WithDescendantReverse = WithAxis(TraverseDescendantReverse)
View Source
var WithSelfOrAncestor = WithAxis(TraverseSelfOrAncestor)
View Source
var WithSelfOrChild = WithAxis(TraverseSelfOrChild)
View Source
var WithSelfOrDescendant = WithAxis(TraverseSelfOrDescendant)
View Source
var WithSelfOrDescendantReverse = WithAxis(TraverseSelfOrDescendant)
View Source
var WithSelfOrSibling = WithAxis(TraverseSelfOrSibling)
View Source
var WithSelfSiblingOrAncestor = WithAxis(TraverseSelfSiblingOrAncestor)
View Source
var WithSibling = WithAxis(TraverseSibling)
View Source
var WithoutInference = FeatureFunc(func(setup *SetupBuilder) {
	setup.DisableInference()
})

Functions

func CopyIndirect

func CopyIndirect(src any, target any)

CopyIndirect copies the contents of src into the source pointer or reflect.Value.

func CopySliceIndirect

func CopySliceIndirect(src []any, target any)

CopySliceIndirect copies the contents of src slice into the source pointer or reflect.Value.

func Create

func Create(handler Handler, target any) error

func CreateAll

func CreateAll(handler Handler, target any) error

func DynNext

func DynNext(
	filter Filter,
	next Next,
	context HandleContext,
	provider FilterProvider,
) (results []any, invalid error)

func GetOptions

func GetOptions(handler Handler, target any) bool

func Invoke

func Invoke[T any](handler Handler, callback any) (T, error)

func InvokeAll

func InvokeAll[T any](handler Handler, callback any) ([]T, error)

func IsNil

func IsNil(val any) bool

IsNil determine if the val is typed or untyped nil.

func IsStruct

func IsStruct(val any) bool

func MakeCaller added in v0.3.0

func MakeCaller(fun any) (func(Handler) []reflect.Value, error)

func Map

func Map[T any](
	handler Handler,
	source any,
	format ...any,
) (T, error)

func MapAll

func MapAll[T any](
	handler Handler,
	source any,
	format ...any,
) ([]T, error)

func MapInto added in v0.5.0

func MapInto[T any](
	handler Handler,
	source any,
	target *T,
	format ...any,
) error

func MergeOptions

func MergeOptions(from, into any) bool

func Resolve

func Resolve[T any](
	handler Handler,
	constraints ...func(*ConstraintBuilder),
) (T, error)

func ResolveAll

func ResolveAll[T any](
	handler Handler,
	constraints ...func(*ConstraintBuilder),
) ([]T, error)

func TargetSliceValue

func TargetSliceValue(target any) reflect.Value

TargetSliceValue validates the interface contains a non-nil typed slice pointer and return reflect.Value.

func TargetValue

func TargetValue(target any) reflect.Value

TargetValue validates the interface contains a non-nil typed pointer and return reflect.Value.

func TraverseAxis

func TraverseAxis(
	node Traversing,
	axis TraversingAxis,
	visitor TraversalVisitor,
) error

TraverseAxis traverses a node over an axis.

func TraverseLevelOrder

func TraverseLevelOrder(
	node Traversing,
	visitor TraversalVisitor,
) error

TraverseLevelOrder traverse the node using level-order algorithm.

func TraversePostOrder

func TraversePostOrder(
	node Traversing,
	visitor TraversalVisitor,
) error

TraversePostOrder traverse the node using post-order algorithm.

func TraversePreOrder

func TraversePreOrder(
	node Traversing,
	visitor TraversalVisitor,
) error

TraversePreOrder traverse the node using pre-order algorithm.

func TraverseReverseLevelOrder

func TraverseReverseLevelOrder(
	node Traversing,
	visitor TraversalVisitor,
) error

TraverseReverseLevelOrder traverse the node using reverse level-order algorithm.

func TypeOf

func TypeOf[T any]() reflect.Type

TypeOf returns reflect.Type of generic argument.

func ValidateResults

func ValidateResults(installer *ValidationInstaller)

func ValueAs

func ValueAs[T any](v reflect.Value) (r T)

ValueAs returns the value of v as the type T. It panics if the value isn't assignable to T.

func WithConstraint added in v0.5.0

func WithConstraint(constraint BindingConstraint) func(*ConstraintBuilder)

func WithConstraintProvider added in v0.5.0

func WithConstraintProvider[T ConstraintInitialize](provider T) func(*ConstraintBuilder)

func WithMetadata added in v0.5.0

func WithMetadata(metadata BindingMetadata) func(*ConstraintBuilder)

func WithName added in v0.5.0

func WithName(name string) func(*ConstraintBuilder)

func WithQualifier added in v0.5.0

func WithQualifier[T any]() func(*ConstraintBuilder)

Types

type AcceptResultFunc

type AcceptResultFunc func(
	result any,
	composer Handler,
) HandleResult

AcceptResultFunc accepts or rejects callback results.

type Binding

type Binding interface {
	Filtered
	Key() any
	Strict() bool
	SkipFilters() bool
	Invoke(
		ctx HandleContext,
		explicitArgs ...any,
	) (results []any, err error)
}

Binding abstracts a Callback method.

type BindingConstraint

type BindingConstraint interface {
	Require(metadata *BindingMetadata)
	Matches(metadata *BindingMetadata) bool
}

BindingConstraint manages BindingMetadata assertions.

type BindingMetadata

type BindingMetadata struct {
	// contains filtered or unexported fields
}

BindingMetadata is a key/value container.

func ApplyConstraints

func ApplyConstraints(
	scope BindingScope,
	constraints ...func(*ConstraintBuilder),
) *BindingMetadata

func (*BindingMetadata) Get

func (b *BindingMetadata) Get(key any) (any, bool)

func (*BindingMetadata) Has

func (b *BindingMetadata) Has(key any) bool

func (*BindingMetadata) IsEmpty

func (b *BindingMetadata) IsEmpty() bool

func (*BindingMetadata) MergeInto

func (b *BindingMetadata) MergeInto(other *BindingMetadata)

func (*BindingMetadata) Name

func (b *BindingMetadata) Name() string

func (*BindingMetadata) Set

func (b *BindingMetadata) Set(key any, val any)

func (*BindingMetadata) SetName

func (b *BindingMetadata) SetName(name string)

type BindingReducer

type BindingReducer func(
	binding Binding,
	result HandleResult,
) (HandleResult, bool)

BindingReducer aggregates Binding results.

type BindingScope

type BindingScope interface {
	Metadata() *BindingMetadata
}

BindingScope is a BindingMetadata container.

type BivariantPolicy

type BivariantPolicy struct {
	FilteredScope
	// contains filtered or unexported fields
}

BivariantPolicy defines related input and output values.

func (*BivariantPolicy) AcceptResults

func (p *BivariantPolicy) AcceptResults(
	results []any,
) (any, HandleResult)

func (*BivariantPolicy) IsVariantKey

func (p *BivariantPolicy) IsVariantKey(
	key any,
) (variant bool, unknown bool)

func (*BivariantPolicy) Less

func (p *BivariantPolicy) Less(
	binding, otherBinding Binding,
) bool

func (*BivariantPolicy) MatchesKey

func (p *BivariantPolicy) MatchesKey(
	key, otherKey any,
	strict bool,
) (matches bool, exact bool)

func (*BivariantPolicy) NewFuncBinding added in v0.3.0

func (p *BivariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *policySpec,
) (Binding, error)

func (*BivariantPolicy) NewMethodBinding

func (p *BivariantPolicy) NewMethodBinding(
	method reflect.Method,
	spec *policySpec,
) (Binding, error)

type Builder

type Builder interface {
	Build(Handler) Handler
}

Builder augments a Handler.

func ComposeBuilders

func ComposeBuilders(builder Builder, builders ...Builder) Builder

func PipeBuilders

func PipeBuilders(builder Builder, builders ...Builder) Builder

func With

func With(values ...any) Builder

func WithAxis

func WithAxis(axis TraversingAxis) Builder

func WithCallSemantics

func WithCallSemantics(semantics SemanticFlags) Builder

func WithFilter

func WithFilter(filter FilterFunc, reentrant bool) Builder

func WithFilterProviders

func WithFilterProviders(providers ...FilterProvider) Builder

func WithFilters

func WithFilters(filters ...Filter) Builder

func WithOptions

func WithOptions(options any) Builder

func WithRequiredFilters

func WithRequiredFilters(filters ...Filter) Builder

type BuilderFunc

type BuilderFunc func(Handler) Handler
var DisableFilters BuilderFunc = func(handler Handler) Handler {
	return Build(handler, disableFilters)
}
var EnableFilters BuilderFunc = func(handler Handler) Handler {
	return Build(handler, enableFilters)
}
var WithPublishFromRoot BuilderFunc = func(handler Handler) Handler {
	if context, err := Resolve[*Context](handler); err != nil {
		panic("the root context could not be found")
	} else {
		return WithPublish.Build(context.Root())
	}
}

func (BuilderFunc) Build

func (f BuilderFunc) Build(
	handler Handler,
) Handler

type Callback

type Callback interface {
	Key() any
	Source() any
	Policy() Policy
	ResultType() reflect.Type
	Result(many bool) any
	SetResult(result any)
	ReceiveResult(
		result any,
		strict bool,
		composer Handler,
	) HandleResult
}

Callback represents any action.

type CallbackArg added in v0.4.0

type CallbackArg struct{}

CallbackArg returns the raw callback.

type CallbackBase

type CallbackBase struct {
	// contains filtered or unexported fields
}

CallbackBase is abstract Callback implementation.

func (*CallbackBase) AddResult

func (c *CallbackBase) AddResult(
	result any,
	composer Handler,
) HandleResult

func (*CallbackBase) CopyResult

func (c *CallbackBase) CopyResult(target any, many bool)

func (*CallbackBase) ReceiveResult

func (c *CallbackBase) ReceiveResult(
	result any,
	strict bool,
	composer Handler,
) HandleResult

func (*CallbackBase) Result

func (c *CallbackBase) Result(many bool) any

func (*CallbackBase) ResultType

func (c *CallbackBase) ResultType() reflect.Type

func (*CallbackBase) SetResult

func (c *CallbackBase) SetResult(result any)

func (*CallbackBase) Source added in v0.4.0

func (c *CallbackBase) Source() any

type CallbackBuilder

type CallbackBuilder struct {
	// contains filtered or unexported fields
}

func (*CallbackBuilder) CallbackBase

func (b *CallbackBuilder) CallbackBase() CallbackBase

func (*CallbackBuilder) WithAcceptResult

func (b *CallbackBuilder) WithAcceptResult(
	accept AcceptResultFunc,
) *CallbackBuilder

type CallbackGuard

type CallbackGuard interface {
	CanDispatch(
		handler any,
		binding Binding,
	) (reset func(), approved bool)
}

CallbackGuard detects and prevents circular Callback dispatch.

type CallbackSemantics

type CallbackSemantics struct {
	Composition
	// contains filtered or unexported fields
}

CallbackSemantics captures semantic options

func GetSemantics

func GetSemantics(handler Handler) *CallbackSemantics

func (*CallbackSemantics) CanFilter

func (c *CallbackSemantics) CanFilter() bool

func (*CallbackSemantics) CanInfer

func (c *CallbackSemantics) CanInfer() bool

func (*CallbackSemantics) HasOption

func (c *CallbackSemantics) HasOption(options SemanticFlags) bool

func (*CallbackSemantics) IsSpecified

func (c *CallbackSemantics) IsSpecified(options SemanticFlags) bool

func (*CallbackSemantics) MergeInto

func (c *CallbackSemantics) MergeInto(semantics *CallbackSemantics)

func (*CallbackSemantics) SetOption

func (c *CallbackSemantics) SetOption(options SemanticFlags, enabled bool)

type ChildContextEndedObserver

type ChildContextEndedObserver interface {
	ChildContextEnded(childCtx *Context, reason any)
}

ChildContextEndedObserver reports child Context ended.

type ChildContextEndedObserverFunc

type ChildContextEndedObserverFunc func(ctx *Context, reason any)

func (ChildContextEndedObserverFunc) ChildContextEnded

func (f ChildContextEndedObserverFunc) ChildContextEnded(
	ctx *Context,
	reason any,
)

type ChildContextEndingObserver

type ChildContextEndingObserver interface {
	ChildContextEnding(childCtx *Context, reason any)
}

ChildContextEndingObserver reports child Context is ending.

type ChildContextEndingObserverFunc

type ChildContextEndingObserverFunc func(ctx *Context, reason any)

func (ChildContextEndingObserverFunc) ChildContextEnding

func (f ChildContextEndingObserverFunc) ChildContextEnding(
	ctx *Context,
	reason any,
)

type CompletePipelineFunc

type CompletePipelineFunc func(HandleContext) ([]any, error)

type Composition

type Composition struct {
	Trampoline
}

func (*Composition) Dispatch

func (c *Composition) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

type ConstraintBuilder

type ConstraintBuilder struct {
	// contains filtered or unexported fields
}

ConstraintBuilder is a fluent builder for BindingMetadata.

func (*ConstraintBuilder) Metadata

func (b *ConstraintBuilder) Metadata() (metadata *BindingMetadata)

func (*ConstraintBuilder) Named

func (b *ConstraintBuilder) Named(
	name string,
) *ConstraintBuilder

func (*ConstraintBuilder) WithConstraint

func (b *ConstraintBuilder) WithConstraint(
	constraint BindingConstraint,
) *ConstraintBuilder

func (*ConstraintBuilder) WithMetadata

func (b *ConstraintBuilder) WithMetadata(
	metadata BindingMetadata,
) *ConstraintBuilder

type ConstraintInitialize added in v0.5.0

type ConstraintInitialize interface {
	BindingConstraint
	Init() error
}

ConstraintInitialize defines generic contract for providers.

type ConstraintProvider

type ConstraintProvider struct {
	// contains filtered or unexported fields
}

ConstraintProvider is a FilterProvider for constraints.

func (*ConstraintProvider) AppliesTo

func (c *ConstraintProvider) AppliesTo(
	callback Callback,
) bool

func (*ConstraintProvider) Constraints

func (c *ConstraintProvider) Constraints() []BindingConstraint

func (*ConstraintProvider) Filters

func (c *ConstraintProvider) Filters(
	binding Binding,
	callback any,
	composer Handler,
) ([]Filter, error)

func (*ConstraintProvider) Required

func (c *ConstraintProvider) Required() bool

type ConstructorBinder

type ConstructorBinder interface {
	NewConstructorBinding(
		handlerType reflect.Type,
		constructor *reflect.Method,
		spec *policySpec,
	) (Binding, error)
}

ConstructorBinder creates a constructor binding to `handlerType`.

type Context

type Context struct {
	// contains filtered or unexported fields
}

A Context represents the scope at a give point in time. It has a beginning and an end and can handle callbacks as well as notify observers of lifecycle changes. In addition, it maintains parent-child relationships and thus can form a graph.

func NewContext

func NewContext(handlers ...any) *Context

func (*Context) AddHandlers

func (m *Context) AddHandlers(
	handlers ...any,
) *mutableHandlers

func (*Context) Children

func (c *Context) Children() []Traversing

func (*Context) Dispose

func (c *Context) Dispose()

func (*Context) End

func (c *Context) End(reason any)

func (*Context) Handle

func (c *Context) Handle(
	callback any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Context) HandleAxis

func (c *Context) HandleAxis(
	axis TraversingAxis,
	callback any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Context) HasChildren

func (c *Context) HasChildren() bool

func (*Context) InsertHandlers

func (m *Context) InsertHandlers(
	index int,
	handlers ...any,
) *mutableHandlers

func (*Context) NewChild

func (c *Context) NewChild() *Context

func (*Context) Observe

func (c *Context) Observe(observer ContextObserver) Disposable

func (*Context) Parent

func (c *Context) Parent() Traversing

func (*Context) RemoveHandlers

func (m *Context) RemoveHandlers(
	handlers ...any,
) *mutableHandlers

func (*Context) Root

func (c *Context) Root() *Context

func (*Context) State

func (c *Context) State() ContextState

func (*Context) Store

func (c *Context) Store(values ...any) *Context

func (*Context) SuppressDispatch added in v0.3.0

func (m *Context) SuppressDispatch()

func (*Context) Traverse

func (c *Context) Traverse(
	axis TraversingAxis,
	visitor TraversalVisitor,
) error

func (*Context) Unwind

func (c *Context) Unwind(reason any) *Context

func (*Context) UnwindToRoot

func (c *Context) UnwindToRoot(reason any) *Context

type ContextChangedObserver

type ContextChangedObserver interface {
	ContextChanged(
		contextual Contextual,
		oldCtx *Context,
		newCtx *Context)
}

ContextChangedObserver reports a Context changed.

type ContextChangedObserverFunc

type ContextChangedObserverFunc func(
	contextual Contextual,
	oldCtx *Context,
	newCtx *Context)

func (ContextChangedObserverFunc) ContextChanged

func (f ContextChangedObserverFunc) ContextChanged(
	contextual Contextual,
	oldCtx *Context,
	newCtx *Context,
)

type ContextChangingObserver

type ContextChangingObserver interface {
	ContextChanging(
		contextual Contextual,
		oldCtx *Context,
		newCtx **Context)
}

ContextChangingObserver reports a Context is changing.

type ContextChangingObserverFunc

type ContextChangingObserverFunc func(
	contextual Contextual,
	oldCtx *Context,
	newCtx **Context)

func (ContextChangingObserverFunc) ContextChanging

func (f ContextChangingObserverFunc) ContextChanging(
	contextual Contextual,
	oldCtx *Context,
	newCtx **Context,
)

type ContextEndedObserver

type ContextEndedObserver interface {
	ContextEnded(ctx *Context, reason any)
}

ContextEndedObserver reports Context ended.

type ContextEndedObserverFunc

type ContextEndedObserverFunc func(ctx *Context, reason any)

func (ContextEndedObserverFunc) ContextEnded

func (f ContextEndedObserverFunc) ContextEnded(
	ctx *Context,
	reason any,
)

type ContextEndingObserver

type ContextEndingObserver interface {
	ContextEnding(ctx *Context, reason any)
}

ContextEndingObserver reports Context is ending.

type ContextEndingObserverFunc

type ContextEndingObserverFunc func(ctx *Context, reason any)

func (ContextEndingObserverFunc) ContextEnding

func (f ContextEndingObserverFunc) ContextEnding(
	ctx *Context,
	reason any,
)

type ContextObserver

type ContextObserver = interface{}

ContextObserver is a generic Context observer.

type ContextReason

type ContextReason uint

ContextReason identifies the cause for the notification.

const (
	ContextAlreadyEnded ContextReason = iota
	ContextUnwinded
	ContextDisposed
)

type ContextState

type ContextState uint

ContextState represents the state of a Context.

const (
	ContextActive ContextState = iota
	ContextEnding
	ContextEnded
)

type Contextual

type Contextual interface {
	Context() *Context
	SetContext(ctx *Context)
	Observe(observer ContextObserver) Disposable
}

Contextual represents anything with a Context.

type ContextualBase

type ContextualBase struct {
	// contains filtered or unexported fields
}

func (*ContextualBase) ChangeContext

func (c *ContextualBase) ChangeContext(
	contextual Contextual,
	ctx *Context,
)

func (*ContextualBase) Context

func (c *ContextualBase) Context() *Context

func (*ContextualBase) EndContext

func (c *ContextualBase) EndContext()

func (*ContextualBase) Observe

func (c *ContextualBase) Observe(
	observer ContextObserver,
) Disposable

type ContravariantPolicy

type ContravariantPolicy struct {
	FilteredScope
}

ContravariantPolicy defines related input values.

func (*ContravariantPolicy) AcceptResults

func (p *ContravariantPolicy) AcceptResults(
	results []any,
) (result any, accepted HandleResult)

func (*ContravariantPolicy) IsVariantKey

func (p *ContravariantPolicy) IsVariantKey(
	key any,
) (variant bool, unknown bool)

func (*ContravariantPolicy) Less

func (p *ContravariantPolicy) Less(
	binding, otherBinding Binding,
) bool

func (*ContravariantPolicy) MatchesKey

func (p *ContravariantPolicy) MatchesKey(
	key, otherKey any,
	strict bool,
) (matches bool, exact bool)

func (*ContravariantPolicy) NewFuncBinding added in v0.3.0

func (p *ContravariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *policySpec,
) (Binding, error)

func (*ContravariantPolicy) NewMethodBinding

func (p *ContravariantPolicy) NewMethodBinding(
	method reflect.Method,
	spec *policySpec,
) (Binding, error)

type CovariantPolicy

type CovariantPolicy struct {
	FilteredScope
}

CovariantPolicy defines related output values.

func (*CovariantPolicy) AcceptResults

func (p *CovariantPolicy) AcceptResults(
	results []any,
) (result any, accepted HandleResult)

func (*CovariantPolicy) IsVariantKey

func (p *CovariantPolicy) IsVariantKey(
	key any,
) (variant bool, unknown bool)

func (*CovariantPolicy) Less

func (p *CovariantPolicy) Less(
	binding, otherBinding Binding,
) bool

func (*CovariantPolicy) MatchesKey

func (p *CovariantPolicy) MatchesKey(
	key, otherKey any,
	strict bool,
) (matches bool, exact bool)

func (*CovariantPolicy) NewFuncBinding added in v0.3.0

func (p *CovariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *policySpec,
) (Binding, error)

func (*CovariantPolicy) NewMethodBinding

func (p *CovariantPolicy) NewMethodBinding(
	method reflect.Method,
	spec *policySpec,
) (Binding, error)

type Creates

type Creates struct {
	CallbackBase
	// contains filtered or unexported fields
}

Creates instances covariantly.

func (*Creates) Dispatch

func (c *Creates) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Creates) Key

func (c *Creates) Key() any

func (*Creates) Policy

func (c *Creates) Policy() Policy

type CreatesBuilder

type CreatesBuilder struct {
	CallbackBuilder
	// contains filtered or unexported fields
}

CreatesBuilder builds Creates callbacks.

func (*CreatesBuilder) NewCreation

func (b *CreatesBuilder) NewCreation() *Creates

func (*CreatesBuilder) WithType

func (b *CreatesBuilder) WithType(
	typ reflect.Type,
) *CreatesBuilder

type DependencyArg

type DependencyArg struct {
	// contains filtered or unexported fields
}

DependencyArg is a parameter resolved at runtime.

func (DependencyArg) Optional

func (d DependencyArg) Optional() bool

func (DependencyArg) Strict

func (d DependencyArg) Strict() bool

type DependencyResolver

type DependencyResolver interface {
	Resolve(
		typ reflect.Type,
		callback Callback,
		dep DependencyArg,
		handler Handler,
	) (reflect.Value, error)
}

DependencyResolver defines how an argument value is retrieved.

type DiKey

type DiKey struct {
	In  any
	Out any
}

DiKey represents a key with input and output parts.

type Disposable

type Disposable interface {
	Dispose()
}

type DisposableFunc

type DisposableFunc func()

func (DisposableFunc) Dispose

func (f DisposableFunc) Dispose()

type Feature added in v0.3.0

type Feature interface {
	Install(setup *SetupBuilder)
}

Feature encapsulates custom setup.

func ExcludeHandlerSpecs added in v0.3.0

func ExcludeHandlerSpecs(rules ...Predicate[HandlerSpec]) Feature

func WithHandlerDescriptorFactory

func WithHandlerDescriptorFactory(factory HandlerDescriptorFactory) Feature

func WithHandlerSpecs added in v0.3.0

func WithHandlerSpecs(specs ...any) Feature

func WithHandlers

func WithHandlers(handlers ...any) Feature

func WithValidation

func WithValidation(
	config ...func(installer *ValidationInstaller),
) Feature

type FeatureFunc added in v0.3.0

type FeatureFunc func(setup *SetupBuilder)

func (FeatureFunc) Install added in v0.3.0

func (f FeatureFunc) Install(setup *SetupBuilder)

type Filter

type Filter interface {
	Order() int
	Next(
		next Next,
		context HandleContext,
		provider FilterProvider,
	) ([]any, error)
}

Filter defines a Middleware step in a pipeline.

type FilterFunc

type FilterFunc = func(
	callback any,
	composer Handler,
	proceed func() HandleResult,
) HandleResult

type FilterInstanceProvider

type FilterInstanceProvider struct {
	// contains filtered or unexported fields
}

FilterInstanceProvider manages existing Filters.

func NewFilterInstanceProvider

func NewFilterInstanceProvider(
	required bool,
	filters ...Filter,
) *FilterInstanceProvider

func (*FilterInstanceProvider) Filters

func (f *FilterInstanceProvider) Filters(
	binding Binding,
	callback any,
	composer Handler,
) ([]Filter, error)

func (*FilterInstanceProvider) Required

func (f *FilterInstanceProvider) Required() bool

type FilterOptions

type FilterOptions struct {
	Providers   []FilterProvider
	SkipFilters OptionBool
}

FilterOptions are used to control Filter processing.

type FilterProvider

type FilterProvider interface {
	Required() bool
	Filters(
		binding Binding,
		callback any,
		composer Handler,
	) ([]Filter, error)
}

FilterProvider provides one or more Filter's.

type FilterSpecProvider

type FilterSpecProvider struct {
	// contains filtered or unexported fields
}

FilterSpecProvider resolves a Filter specification.

func (*FilterSpecProvider) Filters

func (f *FilterSpecProvider) Filters(
	binding Binding,
	callback any,
	composer Handler,
) ([]Filter, error)

func (*FilterSpecProvider) Required

func (f *FilterSpecProvider) Required() bool

type Filtered

type Filtered interface {
	Filters() []FilterProvider
	AddFilters(providers ...FilterProvider)
	RemoveFilters(providers ...FilterProvider)
	RemoveAllFilters()
}

Filtered models a container of Filters.

type FilteredScope

type FilteredScope struct {
	// contains filtered or unexported fields
}

FilteredScope is a container of Filters.

func (*FilteredScope) AddFilters

func (f *FilteredScope) AddFilters(providers ...FilterProvider)

func (*FilteredScope) Filters

func (f *FilteredScope) Filters() []FilterProvider

func (*FilteredScope) RemoveAllFilters

func (f *FilteredScope) RemoveAllFilters()

func (*FilteredScope) RemoveFilters

func (f *FilteredScope) RemoveFilters(providers ...FilterProvider)

type Format

type Format struct {
	// contains filtered or unexported fields
}

func (*Format) InitWithTag

func (f *Format) InitWithTag(tag reflect.StructTag) error

func (*Format) Matches

func (f *Format) Matches(metadata *BindingMetadata) bool

func (*Format) Merge

func (f *Format) Merge(constraint BindingConstraint) bool

func (*Format) Require

func (f *Format) Require(metadata *BindingMetadata)

type FromOptions

type FromOptions struct{}

FromOptions is a DependencyResolver that binds options to an argument.

func (FromOptions) Resolve

func (o FromOptions) Resolve(
	typ reflect.Type,
	callback Callback,
	dep DependencyArg,
	handler Handler,
) (options reflect.Value, err error)

func (FromOptions) Validate

func (o FromOptions) Validate(
	typ reflect.Type,
	dep DependencyArg,
) error

type FuncBinder added in v0.3.0

type FuncBinder interface {
	NewFuncBinding(
		fun reflect.Value,
		spec *policySpec,
	) (Binding, error)
}

FuncBinder creates a binding to a function.

type FuncBindingError added in v0.3.0

type FuncBindingError struct {
	// contains filtered or unexported fields
}

FuncBindingError reports a failed function binding.

func (FuncBindingError) Error added in v0.3.0

func (e FuncBindingError) Error() string

func (FuncBindingError) Func added in v0.3.0

func (e FuncBindingError) Func() reflect.Value

func (FuncBindingError) Unwrap added in v0.3.0

func (e FuncBindingError) Unwrap() error

type Group

type Group struct {
	// contains filtered or unexported fields
}

func (*Group) InitWithTag

func (g *Group) InitWithTag(tag reflect.StructTag) error

func (*Group) Matches

func (g *Group) Matches(metadata *BindingMetadata) bool

func (*Group) Merge

func (g *Group) Merge(constraint BindingConstraint) bool

func (*Group) Require

func (g *Group) Require(metadata *BindingMetadata)

type HandleContext

type HandleContext struct {
	// contains filtered or unexported fields
}

HandleContext contain all the information about handling a Callback.

func (HandleContext) Binding

func (h HandleContext) Binding() Binding

func (HandleContext) Callback

func (h HandleContext) Callback() Callback

func (HandleContext) Composer

func (h HandleContext) Composer() Handler

func (HandleContext) Greedy added in v0.4.0

func (h HandleContext) Greedy() bool

func (HandleContext) Handler added in v0.5.0

func (h HandleContext) Handler() any

type HandleResult

type HandleResult struct {
	// contains filtered or unexported fields
}

HandleResult describes the result of an operation.

func DispatchCallback

func DispatchCallback(
	handler any,
	callback any,
	greedy bool,
	composer Handler,
) HandleResult

func DispatchPolicy

func DispatchPolicy(
	handler any,
	callback Callback,
	greedy bool,
	composer Handler,
) HandleResult

func (HandleResult) And

func (r HandleResult) And(other HandleResult) HandleResult

func (HandleResult) Error

func (r HandleResult) Error() error

func (HandleResult) IsError

func (r HandleResult) IsError() bool

func (HandleResult) IsHandled

func (r HandleResult) IsHandled() bool

func (HandleResult) Or

func (HandleResult) Otherwise

func (r HandleResult) Otherwise(
	block HandleResultBlock,
) HandleResult

func (HandleResult) OtherwiseHandledIf

func (r HandleResult) OtherwiseHandledIf(
	handled bool,
) HandleResult

func (HandleResult) OtherwiseIf

func (r HandleResult) OtherwiseIf(
	condition bool,
	block HandleResultBlock,
) HandleResult

func (HandleResult) ShouldStop

func (r HandleResult) ShouldStop() bool

func (HandleResult) Then

func (r HandleResult) Then(
	block HandleResultBlock,
) HandleResult

func (HandleResult) ThenIf

func (r HandleResult) ThenIf(
	condition bool,
	block HandleResultBlock,
) HandleResult

func (HandleResult) WithError

func (r HandleResult) WithError(err error) HandleResult

func (HandleResult) WithoutError

func (r HandleResult) WithoutError() HandleResult

type HandleResultBlock

type HandleResultBlock func(HandleResult) HandleResult

HandleResultBlock combines a HandleResult with an action.

type Handler

type Handler interface {
	Handle(
		callback any,
		greedy bool,
		composer Handler,
	) HandleResult
}

Handler is the uniform metaphor for processing.

func AddHandlers

func AddHandlers(
	parent Handler,
	handlers ...any,
) Handler

func Build

func Build(handler Handler, builders ...Builder) Handler

func NewProvider

func NewProvider(value any) Handler

func Setup added in v0.3.0

func Setup(features ...Feature) Handler

func ToHandler

func ToHandler(handler any) Handler

type HandlerAxis

type HandlerAxis interface {
	Handler
	HandleAxis(
		axis TraversingAxis,
		callback any,
		greedy bool,
		composer Handler,
	) HandleResult
}

HandlerAxis extends Handler with traversal.

type HandlerDescriptor

type HandlerDescriptor struct {
	FilteredScope
	// contains filtered or unexported fields
}

HandlerDescriptor describes the Binding's of a Handler.

func (*HandlerDescriptor) Dispatch

func (d *HandlerDescriptor) Dispatch(
	policy Policy,
	handler any,
	callback Callback,
	greedy bool,
	composer Handler,
	guard CallbackGuard,
) (result HandleResult)

type HandlerDescriptorError

type HandlerDescriptorError struct {
	Reason error
	// contains filtered or unexported fields
}

HandlerDescriptorError reports a failed HandlerDescriptor.

func (*HandlerDescriptorError) Error

func (e *HandlerDescriptorError) Error() string

func (*HandlerDescriptorError) HandlerSpec added in v0.3.0

func (e *HandlerDescriptorError) HandlerSpec() HandlerSpec

func (*HandlerDescriptorError) Unwrap

func (e *HandlerDescriptorError) Unwrap() error

type HandlerDescriptorFactory

type HandlerDescriptorFactory interface {
	HandlerDescriptorProvider
	MakeHandlerSpec(spec any) HandlerSpec
	RegisterHandler(spec any) (*HandlerDescriptor, bool, error)
}

HandlerDescriptorFactory registers HandlerDescriptor's.

func GetHandlerDescriptorFactory

func GetHandlerDescriptorFactory(
	handler Handler,
) HandlerDescriptorFactory

type HandlerDescriptorProvider

type HandlerDescriptorProvider interface {
	DescriptorOf(spec any) *HandlerDescriptor
}

HandlerDescriptorProvider returns Handler descriptors.

type HandlerDescriptorVisitor

type HandlerDescriptorVisitor interface {
	VisitHandlerBinding(
		descriptor *HandlerDescriptor,
		binding Binding,
	)
}

HandlerDescriptorVisitor observes HandlerDescriptor Binding's.

type HandlerDescriptorVisitorFunc

type HandlerDescriptorVisitorFunc func(*HandlerDescriptor, Binding)

func (HandlerDescriptorVisitorFunc) VisitHandlerBinding

func (f HandlerDescriptorVisitorFunc) VisitHandlerBinding(
	descriptor *HandlerDescriptor,
	binding Binding,
)

type HandlerFuncSpec added in v0.4.0

type HandlerFuncSpec struct {
	// contains filtered or unexported fields
}

HandlerFuncSpec represents Handler function specifications.

func (HandlerFuncSpec) Func added in v0.4.0

func (s HandlerFuncSpec) Func() reflect.Value

func (HandlerFuncSpec) String added in v0.4.0

func (s HandlerFuncSpec) String() string

type HandlerSpec added in v0.3.0

type HandlerSpec interface {
	// contains filtered or unexported methods
}

HandlerSpec manages a category of HandlerDescriptor's.

type HandlerTypeSpec added in v0.3.0

type HandlerTypeSpec struct {
	// contains filtered or unexported fields
}

HandlerTypeSpec represents Handler type specifications.

func (HandlerTypeSpec) Name added in v0.3.0

func (s HandlerTypeSpec) Name() string

func (HandlerTypeSpec) String added in v0.3.0

func (s HandlerTypeSpec) String() string

func (HandlerTypeSpec) Type added in v0.3.0

func (s HandlerTypeSpec) Type() reflect.Type

type Handles

type Handles struct {
	CallbackBase
	// contains filtered or unexported fields
}

Handles callbacks contravariantly.

func (*Handles) CanDispatch

func (h *Handles) CanDispatch(
	handler any,
	binding Binding,
) (reset func(), approved bool)

func (*Handles) CanFilter

func (h *Handles) CanFilter() bool

func (*Handles) CanInfer

func (h *Handles) CanInfer() bool

func (*Handles) Dispatch

func (h *Handles) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Handles) Key

func (h *Handles) Key() any

func (*Handles) Policy

func (h *Handles) Policy() Policy

func (*Handles) Source added in v0.4.0

func (h *Handles) Source() any

type HandlesBuilder

type HandlesBuilder struct {
	CallbackBuilder
	// contains filtered or unexported fields
}

HandlesBuilder builds Handles callbacks.

func (*HandlesBuilder) NewHandles

func (b *HandlesBuilder) NewHandles() *Handles

func (*HandlesBuilder) WithCallback

func (b *HandlesBuilder) WithCallback(
	callback any,
) *HandlesBuilder

type JsonMapper

type JsonMapper struct{}

JsonMapper formats to and from json.

func (*JsonMapper) FromJson

func (m *JsonMapper) FromJson(
	_ *struct {
		Maps
		Format `as:"application/json"`
	}, jsonString string,
	maps *Maps,
) (any, error)

func (*JsonMapper) FromJsonStream

func (m *JsonMapper) FromJsonStream(
	_ *struct {
		Maps
		Format `as:"application/json"`
	}, stream io.Reader,
	maps *Maps,
) (any, error)

func (*JsonMapper) ToJson

func (m *JsonMapper) ToJson(
	_ *struct {
		Maps
		Format `as:"application/json"`
	}, maps *Maps,
	_ *struct {
		Optional
		FromOptions
	}, options JsonOptions,
) (js string, err error)

func (*JsonMapper) ToJsonStream

func (m *JsonMapper) ToJsonStream(
	_ *struct {
		Maps
		Format `as:"application/json"`
	}, maps *Maps,
	_ *struct {
		Optional
		FromOptions
	}, options JsonOptions,
) (stream io.Writer, err error)

type JsonOptions

type JsonOptions struct {
	Prefix string
	Indent string
}

JsonOptions customizes json formatting.

type KeyValues

type KeyValues map[any]any

KeyValues is an alias for key/value map.

type Lifestyle

type Lifestyle struct{}

Lifestyle provides common lifestyle functionality.

func (*Lifestyle) Order

func (l *Lifestyle) Order() int

type LifestyleProvider

type LifestyleProvider struct {
	// contains filtered or unexported fields
}

LifestyleProvider is a FilterProvider of lifestyles.

func (*LifestyleProvider) AppliesTo

func (l *LifestyleProvider) AppliesTo(
	callback Callback,
) bool

func (*LifestyleProvider) Filters

func (l *LifestyleProvider) Filters(
	binding Binding,
	callback any,
	composer Handler,
) ([]Filter, error)

func (*LifestyleProvider) Required

func (l *LifestyleProvider) Required() bool

func (*LifestyleProvider) SetFilters

func (l *LifestyleProvider) SetFilters(filters ...Filter)

type Maps

type Maps struct {
	CallbackBase
	// contains filtered or unexported fields
}

Maps callbacks bivariantly.

func (*Maps) Dispatch

func (m *Maps) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Maps) Format

func (m *Maps) Format() any

func (*Maps) Key

func (m *Maps) Key() any

func (*Maps) Metadata

func (m *Maps) Metadata() *BindingMetadata

func (*Maps) Policy

func (m *Maps) Policy() Policy

func (*Maps) Source

func (m *Maps) Source() any

func (*Maps) Target

func (m *Maps) Target() any

type MapsBuilder

type MapsBuilder struct {
	CallbackBuilder
	// contains filtered or unexported fields
}

MapsBuilder builds Maps callbacks.

func (*MapsBuilder) FromSource

func (b *MapsBuilder) FromSource(
	source any,
) *MapsBuilder

func (*MapsBuilder) NewMaps

func (b *MapsBuilder) NewMaps() *Maps

func (*MapsBuilder) ToTarget

func (b *MapsBuilder) ToTarget(
	target any,
) *MapsBuilder

func (*MapsBuilder) WithFormat

func (b *MapsBuilder) WithFormat(
	format any,
) *MapsBuilder

type Metadata

type Metadata struct {
	// contains filtered or unexported fields
}

Metadata matches against kev/value pairs.

func (*Metadata) InitWithMetadata

func (m *Metadata) InitWithMetadata(
	metadata KeyValues,
) error

func (*Metadata) InitWithTag

func (m *Metadata) InitWithTag(
	tag reflect.StructTag,
) (err error)

func (*Metadata) Matches

func (m *Metadata) Matches(metadata *BindingMetadata) bool

func (*Metadata) Require

func (m *Metadata) Require(metadata *BindingMetadata)

type MethodBinder

type MethodBinder interface {
	NewMethodBinding(
		method reflect.Method,
		spec *policySpec,
	) (Binding, error)
}

MethodBinder creates a binding a method.

type MethodBindingError

type MethodBindingError struct {
	// contains filtered or unexported fields
}

MethodBindingError reports a failed method binding.

func (MethodBindingError) Error

func (e MethodBindingError) Error() string

func (MethodBindingError) Method

func (e MethodBindingError) Method() reflect.Method

func (MethodBindingError) Unwrap

func (e MethodBindingError) Unwrap() error

type MutableHandlerDescriptorFactoryOption

type MutableHandlerDescriptorFactoryOption interface {
	// contains filtered or unexported methods
}

type Named

type Named struct {
	// contains filtered or unexported fields
}

Named matches against a name.

func (*Named) InitWithTag

func (n *Named) InitWithTag(tag reflect.StructTag) error

func (*Named) Matches

func (n *Named) Matches(metadata *BindingMetadata) bool

func (*Named) Name

func (n *Named) Name() string

func (*Named) Require

func (n *Named) Require(metadata *BindingMetadata)

type Next

type Next func(
	composer Handler,
	proceed bool,
) ([]any, error)

Next advances to the next step in a pipeline.

func (Next) Abort

func (n Next) Abort() ([]any, error)

func (Next) Filter

func (n Next) Filter() ([]any, error)

func (Next) WithComposer

func (n Next) WithComposer(composer Handler) ([]any, error)

type NotHandledError

type NotHandledError struct {
	// contains filtered or unexported fields
}

NotHandledError reports a failed callback.

func (NotHandledError) Callback

func (e NotHandledError) Callback() any

func (NotHandledError) Error

func (e NotHandledError) Error() string

type OptionBool

type OptionBool byte

OptionBool should be used in option structs instead of bool to be able to represent a bool not set. Otherwise, the Zero value for of a bool cannot be distinguished from false.

const (
	OptionNone OptionBool = iota
	OptionFalse
	OptionTrue
)

func (OptionBool) Bool

func (b OptionBool) Bool() bool

type Optional

type Optional struct{}

type Policy

type Policy interface {
	Filtered
	Less(binding, otherBinding Binding) bool
	IsVariantKey(key any) (bool, bool)
	MatchesKey(key, otherKey any, strict bool) (bool, bool)
	AcceptResults(results []any) (any, HandleResult)
}

Policy manages behaviors and callback Binding's.

type PolicyDispatch

type PolicyDispatch interface {
	DispatchPolicy(
		policy Policy,
		callback Callback,
		greedy bool,
		composer Handler,
	) HandleResult
}

PolicyDispatch customizes Callback Policy dispatch.

type Predicate

type Predicate[T any] func(T) bool

Predicate represents a generic selector.

func CombinePredicates

func CombinePredicates[T any](
	predicate Predicate[T],
	predicates ...Predicate[T],
) Predicate[T]

type Provides

type Provides struct {
	CallbackBase
	// contains filtered or unexported fields
}

Provides results covariantly.

func (*Provides) Binding

func (p *Provides) Binding() Binding

func (*Provides) CanDispatch

func (p *Provides) CanDispatch(
	handler any,
	binding Binding,
) (reset func(), approved bool)

func (*Provides) Dispatch

func (p *Provides) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) (result HandleResult)

func (*Provides) Key

func (p *Provides) Key() any

func (*Provides) Metadata

func (p *Provides) Metadata() *BindingMetadata

func (*Provides) Parent

func (p *Provides) Parent() *Provides

func (*Provides) Policy

func (p *Provides) Policy() Policy

func (*Provides) ReceiveResult

func (p *Provides) ReceiveResult(
	result any,
	strict bool,
	composer Handler,
) HandleResult

func (*Provides) Resolve

func (p *Provides) Resolve(
	handler Handler,
	many bool,
) (any, error)

type ProvidesBuilder

type ProvidesBuilder struct {
	CallbackBuilder
	// contains filtered or unexported fields
}

ProvidesBuilder builds Provides callbacks.

func (*ProvidesBuilder) NewProvides

func (b *ProvidesBuilder) NewProvides() *Provides

func (*ProvidesBuilder) Provides

func (b *ProvidesBuilder) Provides() Provides

func (*ProvidesBuilder) WithConstraints

func (b *ProvidesBuilder) WithConstraints(
	constraints ...func(*ConstraintBuilder),
) *ProvidesBuilder

func (*ProvidesBuilder) WithKey

func (b *ProvidesBuilder) WithKey(
	key any,
) *ProvidesBuilder

func (*ProvidesBuilder) WithParent

func (b *ProvidesBuilder) WithParent(
	parent *Provides,
) *ProvidesBuilder

type Qualifier

type Qualifier[T any] struct{}

Qualifier matches against a type.

func (Qualifier[T]) Matches added in v0.5.0

func (q Qualifier[T]) Matches(metadata *BindingMetadata) bool

func (Qualifier[T]) Require added in v0.5.0

func (q Qualifier[T]) Require(metadata *BindingMetadata)

type RejectedError

type RejectedError struct {
	// contains filtered or unexported fields
}

RejectedError reports a rejected callback.

func (RejectedError) Callback

func (e RejectedError) Callback() any

func (RejectedError) Error

func (e RejectedError) Error() string

type Resolving

type Resolving struct {
	Provides
	// contains filtered or unexported fields
}

func (*Resolving) CanDispatch

func (r *Resolving) CanDispatch(
	handler any,
	binding Binding,
) (reset func(), approved bool)

func (*Resolving) Succeeded

func (r *Resolving) Succeeded() bool

type ResolvingBuilder

type ResolvingBuilder struct {
	ProvidesBuilder
	// contains filtered or unexported fields
}

func (*ResolvingBuilder) NewResolving

func (b *ResolvingBuilder) NewResolving() *Resolving

func (*ResolvingBuilder) WithCallback

func (b *ResolvingBuilder) WithCallback(
	callback Callback,
) *ResolvingBuilder

func (*ResolvingBuilder) WithGreedy added in v0.3.0

func (b *ResolvingBuilder) WithGreedy(
	greedy bool,
) *ResolvingBuilder

type Scoped

type Scoped struct {
	LifestyleProvider
	// contains filtered or unexported fields
}

Scoped LifestyleProvider provides instances per Context.

func (*Scoped) Constraint

func (s *Scoped) Constraint() BindingConstraint

func (*Scoped) Init

func (s *Scoped) Init() error

func (*Scoped) InitWithTag

func (s *Scoped) InitWithTag(tag reflect.StructTag) error

type SemanticFlags

type SemanticFlags uint8
const (
	SemanticNone   SemanticFlags = 0
	SemanticStrict SemanticFlags = 1 << iota
	SemanticBroadcast
	SemanticBestEffort
	SemanticNotify = SemanticBroadcast | SemanticBestEffort
)

type SetupBuilder added in v0.3.0

type SetupBuilder struct {
	// contains filtered or unexported fields
}

SetupBuilder configures a setup.

func (*SetupBuilder) AddFilters added in v0.3.0

func (s *SetupBuilder) AddFilters(
	providers ...FilterProvider,
) *SetupBuilder

func (*SetupBuilder) AddHandlers added in v0.3.0

func (s *SetupBuilder) AddHandlers(
	handlers ...any,
) *SetupBuilder

func (*SetupBuilder) Build added in v0.3.0

func (s *SetupBuilder) Build() Handler

func (*SetupBuilder) CanInstall added in v0.3.0

func (s *SetupBuilder) CanInstall(tag any) bool

func (*SetupBuilder) DisableInference added in v0.3.0

func (s *SetupBuilder) DisableInference()

func (*SetupBuilder) Exclude added in v0.3.0

func (s *SetupBuilder) Exclude(
	excludes ...Predicate[HandlerSpec],
) *SetupBuilder

func (*SetupBuilder) Install added in v0.3.0

func (s *SetupBuilder) Install(feature Feature) *SetupBuilder

func (*SetupBuilder) RegisterHandlers added in v0.3.0

func (s *SetupBuilder) RegisterHandlers(
	specs ...any,
) *SetupBuilder

func (*SetupBuilder) SetHandlerDescriptorFactory added in v0.3.0

func (s *SetupBuilder) SetHandlerDescriptorFactory(
	factory HandlerDescriptorFactory,
) *SetupBuilder

type Singleton

type Singleton struct {
	LifestyleProvider
}

Singleton LifestyleProvider providing same instance.

func (*Singleton) Init

func (s *Singleton) Init() error

type SkipFilters

type SkipFilters struct{}

type Strict

type Strict struct{}

type Trampoline

type Trampoline struct {
	// contains filtered or unexported fields
}

func (*Trampoline) Callback

func (t *Trampoline) Callback() any

func (*Trampoline) CanDispatch

func (t *Trampoline) CanDispatch(
	handler any,
	binding Binding,
) (reset func(), approved bool)

func (*Trampoline) CanFilter

func (t *Trampoline) CanFilter() bool

func (*Trampoline) CanInfer

func (t *Trampoline) CanInfer() bool

func (*Trampoline) Dispatch

func (t *Trampoline) Dispatch(
	callback any,
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Trampoline) Policy

func (t *Trampoline) Policy() Policy

func (*Trampoline) Result

func (t *Trampoline) Result(many bool) any

func (*Trampoline) ResultType

func (t *Trampoline) ResultType() reflect.Type

func (*Trampoline) SetResult

func (t *Trampoline) SetResult(result any)

func (*Trampoline) Source added in v0.4.0

func (t *Trampoline) Source() any

type TraversalCircularityError

type TraversalCircularityError struct {
	// contains filtered or unexported fields
}

TraversalCircularityError reports a traversal circularity.

func (TraversalCircularityError) Culprit

func (TraversalCircularityError) Error

type TraversalVisitor

type TraversalVisitor interface {
	VisitTraversal(node Traversing) (stop bool, err error)
}

TraversalVisitor is called during traversal.

type TraversalVisitorFunc

type TraversalVisitorFunc func(node Traversing) (stop bool, err error)

func (TraversalVisitorFunc) VisitTraversal

func (f TraversalVisitorFunc) VisitTraversal(node Traversing) (bool, error)

type Traversing

type Traversing interface {
	Parent() Traversing
	Children() []Traversing
	Traverse(axis TraversingAxis, visitor TraversalVisitor) error
}

Traversing represents a node in a graph.

type TraversingAxis

type TraversingAxis uint

TraversingAxis defines a path of traversal.

const (
	TraverseSelf TraversingAxis = iota
	TraverseRoot
	TraverseChild
	TraverseSibling
	TraverseAncestor
	TraverseDescendant
	TraverseDescendantReverse
	TraverseSelfOrChild
	TraverseSelfOrSibling
	TraverseSelfOrAncestor
	TraverseSelfOrDescendant
	TraverseSelfOrDescendantReverse
	TraverseSelfSiblingOrAncestor
)

type UnresolvedArgError added in v0.3.0

type UnresolvedArgError struct {
	Reason error
	// contains filtered or unexported fields
}

UnresolvedArgError reports a failed resolve an arg.

func (UnresolvedArgError) Error added in v0.3.0

func (e UnresolvedArgError) Error() string

func (UnresolvedArgError) Unwrap added in v0.3.0

func (e UnresolvedArgError) Unwrap() error

type ValidateProvider

type ValidateProvider struct {
	// contains filtered or unexported fields
}

ValidateProvider is a FilterProvider for validation.

func NewValidateProvider

func NewValidateProvider(withResult bool) *ValidateProvider

func (*ValidateProvider) Filters

func (v *ValidateProvider) Filters(
	binding Binding,
	callback any,
	composer Handler,
) ([]Filter, error)

func (*ValidateProvider) InitWithTag

func (v *ValidateProvider) InitWithTag(tag reflect.StructTag) error

func (*ValidateProvider) Required

func (v *ValidateProvider) Required() bool

type Validates

type Validates struct {
	CallbackBase
	// contains filtered or unexported fields
}

Validates callbacks contravariantly.

func (*Validates) Dispatch

func (v *Validates) Dispatch(
	handler any,
	greedy bool,
	composer Handler,
) HandleResult

func (*Validates) Groups

func (v *Validates) Groups() []any

func (*Validates) InGroup

func (v *Validates) InGroup(group any) bool

func (*Validates) Key

func (v *Validates) Key() any

func (*Validates) Metadata

func (v *Validates) Metadata() *BindingMetadata

func (*Validates) Outcome

func (v *Validates) Outcome() *ValidationOutcome

func (*Validates) Policy

func (v *Validates) Policy() Policy

func (*Validates) Source added in v0.4.0

func (v *Validates) Source() any

type ValidatesBuilder

type ValidatesBuilder struct {
	CallbackBuilder
	// contains filtered or unexported fields
}

ValidatesBuilder builds Validates callbacks.

func (*ValidatesBuilder) NewValidates

func (b *ValidatesBuilder) NewValidates() *Validates

func (*ValidatesBuilder) Target

func (b *ValidatesBuilder) Target(
	target any,
) *ValidatesBuilder

func (*ValidatesBuilder) WithGroups

func (b *ValidatesBuilder) WithGroups(
	groups ...any,
) *ValidatesBuilder

type ValidationInstaller

type ValidationInstaller struct {
	// contains filtered or unexported fields
}

ValidationInstaller enables validation support.

func (*ValidationInstaller) Install

func (v *ValidationInstaller) Install(setup *SetupBuilder)

func (*ValidationInstaller) ValidateResults

func (v *ValidationInstaller) ValidateResults()

type ValidationOutcome

type ValidationOutcome struct {
	// contains filtered or unexported fields
}

ValidationOutcome captures structured validation errors.

func Validate

func Validate(
	handler Handler,
	target any,
	groups ...any,
) (*ValidationOutcome, error)

Validate initiates validation of the source.

func (*ValidationOutcome) AddError

func (v *ValidationOutcome) AddError(
	path string,
	err error,
)

func (*ValidationOutcome) Error

func (v *ValidationOutcome) Error() string

func (*ValidationOutcome) FieldErrors

func (v *ValidationOutcome) FieldErrors(
	path string,
) []error

func (*ValidationOutcome) Fields

func (v *ValidationOutcome) Fields() []string

func (*ValidationOutcome) Path

func (v *ValidationOutcome) Path(
	path string,
) *ValidationOutcome

func (*ValidationOutcome) RequirePath

func (v *ValidationOutcome) RequirePath(
	path string,
) *ValidationOutcome

func (*ValidationOutcome) Valid

func (v *ValidationOutcome) Valid() bool

Directories

Path Synopsis
tools

Jump to

Keyboard shortcuts

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