miruken

package module
v0.30.113 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 15 Imported by: 13

README

Miruken

Core Miruken

Docker

Manual
docker pull golang:1.22
docker run -it -v $(pwd):/go/src --workdir=/go/src golang:1.22
CGO_ENABLED=0 go build
go test ./... -count=1
Automated
docker run -v $(pwd):/go/src --workdir=/go/src golang:1.22 go test ./...

Documentation

Index

Constants

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

Filter stage priorities.

Variables

View Source
var (
	ErrBivMissingCallback = errors.New("bivariant: missing callback argument")
	ErrBivMissingReturn   = errors.New("bivariant: must have a return value")
)
View Source
var (
	ErrCovResultsExceeded = errors.New("covariant: cannot accept more than 2 results")
	ErrCovMissingReturn   = errors.New("covariant: must have a return value")
)
View Source
var (
	DisableFilters = Options(FilterOptions{SkipFilters: Set(true)})
	EnableFilters  = Options(FilterOptions{SkipFilters: Set(false)})
)
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 AncestorAxis = Axis(TraverseAncestor)
View Source
var ChildAxis = Axis(TraverseChild)
View Source
var DescendantAxis = Axis(TraverseDescendant)
View Source
var DescendantReverseAxis = Axis(TraverseDescendantReverse)
View Source
var ErrConMissingCallback = errors.New("contravariant: missing callback argument")
View Source
var (
	ErrConstraintNameMissing = errors.New("the Named constraint requires a non-empty `name:[name]` tag")
)
View Source
var (

	// Explicit suppresses implied resolution.
	Explicit explicit
)
View Source
var RootAxis = Axis(TraverseRoot)
View Source
var SelfAxis = Axis(TraverseSelf)
View Source
var SelfOrAncestorAxis = Axis(TraverseSelfOrAncestor)
View Source
var SelfOrChildAxis = Axis(TraverseSelfOrChild)
View Source
var SelfOrDescendantAxis = Axis(TraverseSelfOrDescendant)
View Source
var SelfOrDescendantReverseAxis = Axis(TraverseSelfOrDescendant)
View Source
var SelfOrSiblingAxis = Axis(TraverseSelfOrSibling)
View Source
var SelfSiblingOrAncestorAxis = Axis(TraverseSelfSiblingOrAncestor)
View Source
var SiblingAxis = Axis(TraverseSibling)

Functions

func Batch added in v0.10.0

func Batch(
	handler Handler,
	configure func(Handler),
	tags ...any,
) *promise.Promise[[]any]

func BatchAsync added in v0.10.0

func BatchAsync[T any](
	handler Handler,
	configure func(Handler) *promise.Promise[T],
	tags ...any,
) *promise.Promise[[]any]

func BatchTag added in v0.10.0

func BatchTag[T any](
	handler Handler,
	configure func(Handler),
) *promise.Promise[[]any]

func BatchTagAsync added in v0.10.0

func BatchTagAsync[T any, E any](
	handler Handler,
	configure func(Handler) *promise.Promise[T],
) *promise.Promise[[]any]

func Command added in v0.10.0

func Command(
	handler Handler,
	callback any,
	constraints ...any,
) (pv *promise.Promise[any], err error)

Command invokes a callback with no results. returns an empty promise if execution is asynchronous.

func CommandAll added in v0.10.0

func CommandAll(
	handler Handler,
	callback any,
	constraints ...any,
) (p *promise.Promise[any], err error)

CommandAll invokes a callback on all with no results. returns an empty promise if execution is asynchronous.

func Create

func Create[T any](
	handler Handler,
	constraints ...any,
) (T, *promise.Promise[T], error)

Create creates a value of type parameter T.

func CreateAll

func CreateAll[T any](
	handler Handler,
	constraints ...any,
) (t []T, tp *promise.Promise[[]T], err error)

CreateAll creates all values of type parameter T.

func CreateKey added in v0.11.0

func CreateKey[T any](
	handler Handler,
	key any,
	constraints ...any,
) (t T, tp *promise.Promise[T], err error)

CreateKey creates a value of type parameter T with the specified key.

func Execute added in v0.10.0

func Execute[T any](
	handler Handler,
	callback any,
	constraints ...any,
) (t T, tp *promise.Promise[T], err error)

Execute executes a callback with results. returns the results or promise if execution is asynchronous.

func ExecuteAll added in v0.10.0

func ExecuteAll[T any](
	handler Handler,
	callback any,
	constraints ...any,
) (t []T, tp *promise.Promise[[]T], err error)

ExecuteAll executes a callback on all and collects the results. returns the results or promise if execution is asynchronous.

func GetBatch added in v0.10.0

func GetBatch[TB batching](handler Handler, tags ...any) TB

func GetOptions

func GetOptions[T any](handler Handler) (t T, ok bool)

func GetOptionsInto added in v0.30.23

func GetOptionsInto(handler Handler, target any) bool

func MergeOptions

func MergeOptions(from, into any) bool

MergeOptions merges from options into options

func Resolve

func Resolve[T any](
	handler Handler,
	constraints ...any,
) (T, *promise.Promise[T], bool, error)

Resolve retrieves a value of type parameter T. Applies any lifestyle if present.

func ResolveAll

func ResolveAll[T any](
	handler Handler,
	constraints ...any,
) (t []T, tp *promise.Promise[[]T], err error)

ResolveAll retrieves all values of type parameter T. Applies any lifestyle if present.

func ResolveKey added in v0.11.0

func ResolveKey[T any](
	handler Handler,
	key any,
	constraints ...any,
) (t T, tp *promise.Promise[T], ok bool, err error)

ResolveKey retrieves a value of type parameter T with the specified key. Applies any lifestyle if present.

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 ValidEffect added in v0.30.113

func ValidEffect(
	typ reflect.Type,
) (bool, error)

ValidEffect returns true if the argument is an Effect or can be converted to an Effect.

Types

type AcceptPromiseResultFunc added in v0.10.0

type AcceptPromiseResultFunc func(
	pa *promise.Promise[any],
) *promise.Promise[any]

AcceptPromiseResultFunc adjusts promise callback results.

type AcceptResultFunc

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

AcceptResultFunc accepts or rejects callback results.

type Batched added in v0.10.0

type Batched[T any] struct {
	Source   T
	Callback Callback
}

Batched wraps a Callback participating in a batch operation.

type Binding

type Binding interface {
	Filtered
	Key() any
	Strict() bool
	SkipFilters() bool
	Async() bool
	Exported() bool
	Metadata() []any
	LogicalOutputType() reflect.Type
	Invoke(
		ctx HandleContext,
		initArgs ...any,
	) ([]any, *promise.Promise[[]any], error)
}

Binding connects a Callback to a handler.

type BindingBase added in v0.21.0

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

BindingBase implements common binding contract.

func (*BindingBase) Async added in v0.22.0

func (b *BindingBase) Async() bool

func (*BindingBase) Metadata added in v0.21.0

func (b *BindingBase) Metadata() []any

func (*BindingBase) SkipFilters added in v0.21.0

func (b *BindingBase) SkipFilters() bool

func (*BindingBase) Strict added in v0.21.0

func (b *BindingBase) Strict() bool

type BindingGroup added in v0.10.0

type BindingGroup struct{}

BindingGroup marks bindings that aggregate one or more binding metadata.

func (BindingGroup) DefinesBindingGroup added in v0.10.0

func (BindingGroup) DefinesBindingGroup()

type BindingParser added in v0.22.0

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

BindingParser is an extension for binding customizations.

type BindingParserFunc added in v0.22.0

type BindingParserFunc func(
	index int,
	field *reflect.StructField,
	binding any,
) (bound bool, err error)

BindingParserFunc implements a BindingParser using a function.

type BindingReducer

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

BindingReducer aggregates Binding results.

type BivariantPolicy

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

BivariantPolicy matches related input and output values.

func (*BivariantPolicy) AcceptResults

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

func (*BivariantPolicy) Less

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

func (*BivariantPolicy) MatchesKey

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

func (*BivariantPolicy) NewFuncBinding added in v0.3.0

func (p *BivariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*BivariantPolicy) NewMethodBinding

func (p *BivariantPolicy) NewMethodBinding(
	method *reflect.Method,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*BivariantPolicy) Strict added in v0.10.0

func (p *BivariantPolicy) Strict() bool

func (*BivariantPolicy) VariantKey added in v0.23.0

func (p *BivariantPolicy) VariantKey(
	key any,
) (bool, bool)

type Builder

type Builder interface {
	BuildUp(Handler) Handler
}

Builder augments a Handler.

func CallWith added in v0.7.0

func CallWith(semantics SemanticFlags) Builder

func ComposeBuilders

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

func PipeBuilders

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

func ProvideFilters added in v0.7.0

func ProvideFilters(providers ...FilterProvider) Builder

func UseFilters added in v0.7.0

func UseFilters(filters ...Filter) Builder

type BuilderFunc

type BuilderFunc func(Handler) Handler

BuilderFunc promotes a function to Builder.

var NoBatch BuilderFunc = func(handler Handler) Handler {
	if internal.IsNil(handler) {
		panic("handler cannot be nil")
	}
	return &noBatchHandler{handler}
}

func Axis added in v0.7.0

func Axis(axis TraversingAxis) BuilderFunc

func Options added in v0.7.0

func Options(options any) BuilderFunc

Options returns a BuilderFunc that makes the provided options available for merging into matching options.

func Reentrant added in v0.7.0

func Reentrant(filter FilterFunc) BuilderFunc

func With

func With(values ...any) BuilderFunc

func (BuilderFunc) BuildUp added in v0.7.0

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

type Callback

type Callback interface {
	ConstraintSource
	Key() any
	Source() any
	Target() any
	TargetForWrite() any
	Policy() Policy
	ResultCount() int
	Result(many bool) (any, *promise.Promise[any])
	SetResult(result any)
	ReceiveResult(
		result any,
		strict bool,
		composer Handler,
	) HandleResult
}

Callback represents an intention.

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) Constraints added in v0.21.0

func (c *CallbackBase) Constraints() []Constraint

func (*CallbackBase) ReceiveResult

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

func (*CallbackBase) Result

func (c *CallbackBase) Result(
	many bool,
) (any, *promise.Promise[any])

func (*CallbackBase) ResultCount added in v0.7.0

func (c *CallbackBase) ResultCount() int

func (*CallbackBase) SetAcceptPromiseResult added in v0.10.0

func (c *CallbackBase) SetAcceptPromiseResult(
	accept AcceptPromiseResultFunc,
)

func (*CallbackBase) SetAcceptResult added in v0.7.0

func (c *CallbackBase) SetAcceptResult(
	accept AcceptResultFunc,
)

func (*CallbackBase) SetResult

func (c *CallbackBase) SetResult(result any)

func (*CallbackBase) Source added in v0.4.0

func (c *CallbackBase) Source() any

func (*CallbackBase) Target added in v0.26.0

func (c *CallbackBase) Target() any

func (*CallbackBase) TargetForWrite added in v0.26.0

func (c *CallbackBase) TargetForWrite() any

type CallbackBuilder

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

CallbackBuilder builds common CallbackBase.

func (*CallbackBuilder) CallbackBase

func (b *CallbackBuilder) CallbackBase() CallbackBase

func (*CallbackBuilder) IntoTarget added in v0.26.0

func (b *CallbackBuilder) IntoTarget(
	target any,
) *CallbackBuilder

func (*CallbackBuilder) WithConstraints added in v0.11.0

func (b *CallbackBuilder) WithConstraints(
	constraints ...any,
) *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) CanBatch added in v0.10.0

func (c *CallbackSemantics) CanBatch() bool

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 CallerFunc added in v0.30.11

type CallerFunc func(Handler, ...any) ([]any, *promise.Promise[[]any], error)

CallerFunc is a function that invokes a handler method. The first argument is the handler instance. The remaining arguments become the initial arguments to the handler method. All remaining handler method arguments are resolved from the context.

func MakeCaller added in v0.3.0

func MakeCaller(fun any) (CallerFunc, error)

MakeCaller creates a CallerFunc from a function.

type CanceledError added in v0.26.0

type CanceledError struct {
	Message string
	Cause   error
}

CanceledError reports a canceled operation.

func (*CanceledError) Error added in v0.26.0

func (e *CanceledError) Error() string

func (*CanceledError) Unwrap added in v0.26.0

func (e *CanceledError) Unwrap() error

type Cascade added in v0.30.105

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

Cascade is a standard Effect for cascading callbacks.

func CascadeCallbacks added in v0.30.105

func CascadeCallbacks(callbacks ...any) *Cascade

CascadeCallbacks is a fluent builder to Cascade callbacks.

func (*Cascade) Apply added in v0.30.105

func (c *Cascade) Apply(
	ctx HandleContext,
) (promise.Reflect, error)

func (*Cascade) Greedy added in v0.30.105

func (c *Cascade) Greedy(
	greedy bool,
) *Cascade

func (*Cascade) WithConstraints added in v0.30.105

func (c *Cascade) WithConstraints(
	constraints ...any,
) *Cascade

func (*Cascade) WithHandler added in v0.30.105

func (c *Cascade) WithHandler(
	handler Handler,
) *Cascade

type Composition

type Composition struct {
	Trampoline
}

Composition wraps a callback for composition.

func (*Composition) Dispatch

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

type CompositionScope added in v0.22.0

type CompositionScope struct {
	Handler
}

CompositionScope decorates a Handler for composition.

func (*CompositionScope) Handle added in v0.22.0

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

type Constraint added in v0.25.0

type Constraint interface {
	// Required determines if Constraint must be satisfied.
	// If it is not required, it will accept Callback's without it.
	Required() bool

	// Implied determines if Constraint can be satisfied with just HandleContext.
	Implied() bool

	// Satisfies checks if the required Constraint is satisfied.
	// if implied, nil will be passed for `required` Constraint parameter.
	Satisfies(required Constraint, ctx HandleContext) bool
}

Constraint manages BindingMetadata assertions.

type ConstraintProvider

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

ConstraintProvider is a FilterProvider for constraints.

func (*ConstraintProvider) Constraints

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

func (*ConstraintProvider) Filters

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

func (*ConstraintProvider) Required

func (c *ConstraintProvider) Required() bool

type ConstraintSource added in v0.25.0

type ConstraintSource interface {
	Constraints() []Constraint
}

ConstraintSource returns one or more Constraint.

type ConstructorBinder

type ConstructorBinder interface {
	NewCtorBinding(
		typ reflect.Type,
		ctor *reflect.Method,
		inits []*reflect.Method,
		spec *bindingSpec,
		key any,
	) (Binding, error)
}

ConstructorBinder creates constructor Binding's.

type ContravariantPolicy

type ContravariantPolicy struct {
	FilteredScope
}

ContravariantPolicy matches related input values.

func (*ContravariantPolicy) AcceptResults

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

func (*ContravariantPolicy) Less

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

func (*ContravariantPolicy) MatchesKey

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

func (*ContravariantPolicy) NewFuncBinding added in v0.3.0

func (p *ContravariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*ContravariantPolicy) NewMethodBinding

func (p *ContravariantPolicy) NewMethodBinding(
	method *reflect.Method,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*ContravariantPolicy) Strict added in v0.10.0

func (p *ContravariantPolicy) Strict() bool

func (*ContravariantPolicy) VariantKey added in v0.23.0

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

type CovariantPolicy

type CovariantPolicy struct {
	FilteredScope
}

CovariantPolicy matches related output values.

func (*CovariantPolicy) AcceptResults

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

func (*CovariantPolicy) Less

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

func (*CovariantPolicy) MatchesKey

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

func (*CovariantPolicy) NewCtorBinding added in v0.30.28

func (p *CovariantPolicy) NewCtorBinding(
	typ reflect.Type,
	ctor *reflect.Method,
	inits []*reflect.Method,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*CovariantPolicy) NewFuncBinding added in v0.3.0

func (p *CovariantPolicy) NewFuncBinding(
	fun reflect.Value,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*CovariantPolicy) NewMethodBinding

func (p *CovariantPolicy) NewMethodBinding(
	method *reflect.Method,
	spec *bindingSpec,
	key any,
) (Binding, error)

func (*CovariantPolicy) Strict added in v0.10.0

func (p *CovariantPolicy) Strict() bool

func (*CovariantPolicy) VariantKey added in v0.23.0

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

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

func (*Creates) String added in v0.21.0

func (c *Creates) String() string

type CreatesBuilder

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

CreatesBuilder builds Creates callbacks.

func (*CreatesBuilder) New added in v0.22.0

func (b *CreatesBuilder) New() *Creates

func (*CreatesBuilder) WithKey added in v0.11.0

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

type CurrentHandlerInfoFactoryProvider added in v0.30.79

type CurrentHandlerInfoFactoryProvider struct {
	Factory HandlerInfoFactory
}

CurrentHandlerInfoFactoryProvider Resolves the current HandlerInfoFactory

func (*CurrentHandlerInfoFactoryProvider) CabBatch added in v0.30.79

func (*CurrentHandlerInfoFactoryProvider) Handle added in v0.30.79

func (f *CurrentHandlerInfoFactoryProvider) Handle(
	callback any,
	greedy bool,
	composer Handler,
) HandleResult

func (*CurrentHandlerInfoFactoryProvider) SuppressDispatch added in v0.30.79

func (f *CurrentHandlerInfoFactoryProvider) SuppressDispatch()

type DependencyArg

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

DependencyArg is a parameter resolved at runtime.

func (DependencyArg) Metadata added in v0.9.0

func (d DependencyArg) Metadata() []any

func (DependencyArg) Optional

func (d DependencyArg) Optional() bool

func (DependencyArg) Promise added in v0.10.0

func (d DependencyArg) Promise() bool

func (DependencyArg) Strict

func (d DependencyArg) Strict() bool

type DependencyResolver

type DependencyResolver interface {
	Resolve(
		reflect.Type,
		DependencyArg,
		HandleContext,
	) (reflect.Value, *promise.Promise[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 Effect added in v0.30.113

type Effect interface {
	Apply(HandleContext) (promise.Reflect, error)
}

Effect describes an action to be performed. Effects are additional outputs from a Handler. These actions generally represent interactions with external entities i.e. databases and other IO.

func MakeEffect added in v0.30.113

func MakeEffect(
	effect any,
	require bool,
) (Effect, error)

MakeEffect creates an Effect from anything. If the argument is already an Effect it is returned. If require is true, an error is returned if the argument cannot be coerced into an Effect.

func MakeEffects added in v0.30.113

func MakeEffects(
	require bool,
	effects []any,
) ([]Effect, []any, error)

MakeEffects creates Effect from anything. If an argument is already an Effect it is returned. Unrecognized effects are returned as is. If require is true, an error is returned if any argument cannot be coerced into an Effect.

type Filter

type Filter interface {
	Order() int
	Next(

		self Filter,
		next Next,
		ctx HandleContext,
		provider FilterProvider,
	) ([]any, *promise.Promise[[]any], error)
}

Filter defines a middleware step in a pipeline.

type FilterAdapter added in v0.30.23

type FilterAdapter struct{}

FilterAdapter is an adapter for implementing a Filter using late binding method resolution.

func (FilterAdapter) Next added in v0.30.23

func (l FilterAdapter) Next(
	self Filter,
	next Next,
	ctx HandleContext,
	provider FilterProvider,
) ([]any, *promise.Promise[[]any], error)

type FilterFunc

type FilterFunc func(
	callback any,
	greedy bool,
	composer Handler,
	proceed ProceedFunc,
) HandleResult

FilterFunc defines a function that can intercept a callback.

func (FilterFunc) BuildUp added in v0.7.0

func (f FilterFunc) BuildUp(handler Handler) Handler

type FilterInstanceProvider

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

FilterInstanceProvider provides 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 Option[bool]
}

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 Filtered

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

Filtered is a container of Filters.

type FilteredScope

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

FilteredScope implements 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 FromOptions

type FromOptions struct{}

FromOptions is a DependencyResolver for option arguments.

func (FromOptions) Resolve

func (o FromOptions) Resolve(
	typ reflect.Type,
	dep DependencyArg,
	ctx HandleContext,
) (options reflect.Value, _ *promise.Promise[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 *bindingSpec,
		key any,
	) (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 FuncSpec added in v0.30.25

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

FuncSpec creates a HandlerInfo from a single function.

func (FuncSpec) Func added in v0.30.25

func (s FuncSpec) Func() reflect.Value

func (FuncSpec) PkgPath added in v0.30.25

func (s FuncSpec) PkgPath() string

func (FuncSpec) String added in v0.30.25

func (s FuncSpec) String() string

type HandleContext

type HandleContext struct {
	Handler  any
	Callback Callback
	Binding  Binding
	Composer Handler
	Greedy   bool
}

HandleContext allows inspection of the current Callback.

func (HandleContext) Handle added in v0.30.35

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

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) AndBlock added in v0.7.0

func (r HandleResult) AndBlock(other HandleResult) HandleResult

func (HandleResult) Error

func (r HandleResult) Error() error

func (HandleResult) Handled added in v0.21.0

func (r HandleResult) Handled() bool

func (HandleResult) IsError

func (r HandleResult) IsError() bool

func (HandleResult) Or

func (HandleResult) OrBlock added in v0.7.0

func (r HandleResult) OrBlock(block HandleResultBlock) HandleResult

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) Stop added in v0.22.0

func (r HandleResult) Stop() 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

HandleResultBlock provides another HandleResult.

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 BuildUp added in v0.7.0

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

func NewInferenceHandler added in v0.30.79

func NewInferenceHandler(
	factory HandlerInfoFactory,
	specs []HandlerSpec,
) Handler

func NewProvider

func NewProvider(value any) 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 behavior.

type HandlerInfo added in v0.30.25

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

HandlerInfo describes the structure of a Handler.

func (*HandlerInfo) Dispatch added in v0.30.25

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

func (*HandlerInfo) Spec added in v0.30.25

func (h *HandlerInfo) Spec() HandlerSpec

type HandlerInfoError added in v0.30.25

type HandlerInfoError struct {
	Spec  HandlerSpec
	Cause error
}

HandlerInfoError reports a failed HandlerInfo.

func (*HandlerInfoError) Error added in v0.30.25

func (e *HandlerInfoError) Error() string

func (*HandlerInfoError) Unwrap added in v0.30.25

func (e *HandlerInfoError) Unwrap() error

type HandlerInfoFactory added in v0.30.25

type HandlerInfoFactory interface {
	HandlerInfoProvider
	Spec(src any) HandlerSpec
	Register(src any) (*HandlerInfo, bool, error)
}

HandlerInfoFactory registers HandlerInfo's.

func CurrentHandlerInfoFactory added in v0.30.25

func CurrentHandlerInfoFactory(
	handler Handler,
) HandlerInfoFactory

CurrentHandlerInfoFactory retrieves the current HandlerInfoFactory assigned to the Handler context.

type HandlerInfoFactoryBuilder added in v0.30.25

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

HandlerInfoFactoryBuilder build the HandlerInfoFactory.

func (*HandlerInfoFactoryBuilder) Build added in v0.30.25

func (*HandlerInfoFactoryBuilder) Observers added in v0.30.25

func (*HandlerInfoFactoryBuilder) Parsers added in v0.30.25

type HandlerInfoObserver added in v0.30.25

type HandlerInfoObserver interface {
	BindingCreated(
		policy Policy,
		handlerInfo *HandlerInfo,
		binding Binding,
	)
	HandlerInfoCreated(handlerInfo *HandlerInfo)
}

HandlerInfoObserver observes HandlerInfo creation.

type HandlerInfoObserverFunc added in v0.30.25

type HandlerInfoObserverFunc func(Policy, *HandlerInfo, Binding)

func (HandlerInfoObserverFunc) BindingCreated added in v0.30.25

func (f HandlerInfoObserverFunc) BindingCreated(
	policy Policy,
	handlerInfo *HandlerInfo,
	binding Binding,
)

type HandlerInfoProvider added in v0.30.25

type HandlerInfoProvider interface {
	Get(src any) *HandlerInfo
}

HandlerInfoProvider returns HandlerInfo's.

type HandlerSpec added in v0.3.0

type HandlerSpec interface {
	fmt.Stringer
	PkgPath() string
	// contains filtered or unexported methods
}

HandlerSpec is Factory for HandlerInfo and associated metadata.

type Handles

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

Handles callbacks contravariantly.

func (*Handles) CanBatch added in v0.10.0

func (h *Handles) CanBatch() bool

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

func (*Handles) String added in v0.21.0

func (h *Handles) String() string

type HandlesBuilder

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

HandlesBuilder builds Handles callbacks.

func (*HandlesBuilder) New added in v0.22.0

func (b *HandlesBuilder) New() *Handles

func (*HandlesBuilder) WithCallback

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

type Init added in v0.30.28

type Init struct{}

Init marks a method as an initializer.

type Key added in v0.30.35

type Key string

Key is a miruken.DependencyResolver for resolving values referenced by a string key.

func (*Key) InitWithTag added in v0.30.35

func (k *Key) InitWithTag(tag reflect.StructTag) error

func (Key) Resolve added in v0.30.35

func (k Key) Resolve(
	typ reflect.Type,
	dep DependencyArg,
	ctx HandleContext,
) (v reflect.Value, pv *promise.Promise[reflect.Value], err error)

type Lifestyle

type Lifestyle struct{}

Lifestyle provides common lifestyle functionality.

func (*Lifestyle) Order

func (l *Lifestyle) Order() int

type LifestyleInit added in v0.30.28

type LifestyleInit interface {
	InitLifestyle(Binding) error
}

LifestyleInit initializes a Lifestyle from Binding info.

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) FiltersAssigned added in v0.30.28

func (l *LifestyleProvider) FiltersAssigned() bool

func (*LifestyleProvider) Required

func (l *LifestyleProvider) Required() bool

func (*LifestyleProvider) SetFilters

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

type Metadata

type Metadata map[any]any

Metadata matches against kev/value pairs.

func (*Metadata) Implied added in v0.28.0

func (m *Metadata) Implied() bool

func (*Metadata) InitWithTag

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

func (*Metadata) Required added in v0.21.0

func (m *Metadata) Required() bool

func (*Metadata) Satisfies added in v0.21.0

func (m *Metadata) Satisfies(required Constraint, _ HandleContext) bool

type MethodBinder

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

MethodBinder creates a binding a method.

type MethodBindingError

type MethodBindingError struct {
	Method *reflect.Method
	Cause  error
}

MethodBindingError reports a failed method binding.

func (*MethodBindingError) Error

func (e *MethodBindingError) Error() string

func (*MethodBindingError) Unwrap

func (e *MethodBindingError) Unwrap() error

type MutableHandlers added in v0.22.0

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

MutableHandlers manages a mutable list of Handlers.

func (*MutableHandlers) AppendHandlers added in v0.30.25

func (m *MutableHandlers) AppendHandlers(
	handlers ...any,
) *MutableHandlers

func (*MutableHandlers) Handle added in v0.22.0

func (m *MutableHandlers) Handle(
	callback any,
	greedy bool,
	composer Handler,
) HandleResult

func (*MutableHandlers) Handlers added in v0.22.0

func (m *MutableHandlers) Handlers() []any

func (*MutableHandlers) InsertHandlers added in v0.22.0

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

func (*MutableHandlers) RemoveHandlers added in v0.22.0

func (m *MutableHandlers) RemoveHandlers(
	handlers ...any,
) *MutableHandlers

func (*MutableHandlers) ResetHandlers added in v0.30.25

func (m *MutableHandlers) ResetHandlers(
	handlers ...any,
) *MutableHandlers

func (*MutableHandlers) SuppressDispatch added in v0.22.0

func (m *MutableHandlers) SuppressDispatch()

type Named

type Named string

Named matches against a name.

func (*Named) Implied added in v0.28.0

func (n *Named) Implied() bool

func (*Named) InitWithTag

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

func (*Named) Name

func (n *Named) Name() string

func (*Named) Required added in v0.12.0

func (n *Named) Required() bool

func (*Named) Satisfies added in v0.21.0

func (n *Named) Satisfies(required Constraint, _ HandleContext) bool

type Next

type Next func(
	composer Handler,
	proceed bool,
	values ...any,
) ([]any, *promise.Promise[[]any], error)

Next advances to the next step in a pipeline. The optional composer replaces the Handler in the next step. The optional values provide dependencies to the next step.

func (Next) Abort

func (n Next) Abort() ([]any, *promise.Promise[[]any], error)

func (Next) Fail added in v0.10.0

func (n Next) Fail(err error) ([]any, *promise.Promise[[]any], error)

func (Next) Handle added in v0.10.0

func (n Next) Handle(
	callback any,
	greedy bool,
	composer Handler,
) ([]any, *promise.Promise[[]any], error)

func (Next) Pipe added in v0.10.0

func (n Next) Pipe(values ...any) ([]any, *promise.Promise[[]any], error)

func (Next) PipeAwait added in v0.10.0

func (n Next) PipeAwait(values ...any) []any

func (Next) PipeComposer added in v0.10.0

func (n Next) PipeComposer(
	composer Handler,
	values ...any,
) ([]any, *promise.Promise[[]any], error)

func (Next) PipeComposerAwait added in v0.10.0

func (n Next) PipeComposerAwait(
	composer Handler,
	values ...any,
) []any

type NotHandledError

type NotHandledError struct {
	Callback any
}

NotHandledError reports a failed callback.

func (*NotHandledError) Error

func (e *NotHandledError) Error() string

type Option added in v0.11.0

type Option[T any] struct {
	// contains filtered or unexported fields
}

Option provides an explicit representation of an optional value when the Zero value is not sufficient to distinguish unset values.

func Set added in v0.11.0

func Set[T any](val T) Option[T]

Set creates a new Option set to val.

func (*Option[T]) MergeFrom added in v0.11.0

func (o *Option[T]) MergeFrom(option any) bool

func (*Option[T]) Set added in v0.11.0

func (o *Option[T]) Set() bool

func (*Option[T]) SetValue added in v0.11.0

func (o *Option[T]) SetValue(val T)

func (*Option[T]) Value added in v0.11.0

func (o *Option[T]) Value() T

func (*Option[T]) ValueOrDefault added in v0.11.0

func (o *Option[T]) ValueOrDefault(val T) T

type Optional

type Optional struct{}

Optional marks a dependency not required.

type Policy

type Policy interface {
	Filtered
	Strict() bool
	Less(binding, otherBinding Binding) bool
	VariantKey(key any) (bool, bool)
	MatchesKey(key, otherKey any, invariant bool) (bool, bool)
	AcceptResults(results []any) (any, HandleResult, []Effect, []any)
}

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 ProceedFunc added in v0.7.0

type ProceedFunc func() HandleResult

ProceedFunc calls the next filter in the pipeline.

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) Owner added in v0.11.0

func (p *Provides) Owner() any

func (*Provides) Parent

func (p *Provides) Parent() *Provides

func (*Provides) Policy

func (p *Provides) Policy() Policy

func (*Provides) Resolve

func (p *Provides) Resolve(
	handler Handler,
	many bool,
) (any, *promise.Promise[any], error)

func (*Provides) String added in v0.21.0

func (p *Provides) String() string

type ProvidesBuilder

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

ProvidesBuilder builds Provides callbacks.

func (*ProvidesBuilder) Build added in v0.22.0

func (b *ProvidesBuilder) Build() Provides

func (*ProvidesBuilder) ForOwner added in v0.11.0

func (b *ProvidesBuilder) ForOwner(
	owner any,
) *ProvidesBuilder

func (*ProvidesBuilder) New added in v0.22.0

func (b *ProvidesBuilder) New() *Provides

func (*ProvidesBuilder) WithConstraints

func (b *ProvidesBuilder) WithConstraints(
	constraints ...any,
) *CallbackBuilder

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]) Implied added in v0.28.0

func (q Qualifier[T]) Implied() bool

func (Qualifier[T]) Required added in v0.12.0

func (q Qualifier[T]) Required() bool

func (Qualifier[T]) Satisfies added in v0.21.0

func (q Qualifier[T]) Satisfies(required Constraint, _ HandleContext) bool

type RejectedError

type RejectedError struct {
	Callback any
}

RejectedError reports a rejected callback.

func (*RejectedError) Error

func (e *RejectedError) Error() string

type Resolves added in v0.10.0

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

Resolves extends Provides semantics to dispatch a Callback on the resolved handler.

func (*Resolves) Callback added in v0.10.0

func (r *Resolves) Callback() Callback

func (*Resolves) CanDispatch added in v0.10.0

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

func (*Resolves) Succeeded added in v0.10.0

func (r *Resolves) Succeeded() bool

type ResolvesBuilder added in v0.10.0

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

ResolvesBuilder builds Resolves callbacks.

func (*ResolvesBuilder) New added in v0.30.25

func (b *ResolvesBuilder) New() *Resolves

func (*ResolvesBuilder) WithCallback added in v0.10.0

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

func (*ResolvesBuilder) WithGreedy added in v0.10.0

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

type SemanticFlags

type SemanticFlags uint8

SemanticFlags enumerates semantic options.

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

type Single added in v0.22.0

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

Single LifestyleProvider providing same instance.

func (*Single) InitLifestyle added in v0.30.28

func (s *Single) InitLifestyle(binding Binding) error

func (*Single) InitWithTag added in v0.30.71

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

type SkipFilters

type SkipFilters struct{}

SkipFilters skips all non-required filters.

type Strict

type Strict struct{}

Strict Binding's do not expand results.

type Timespan added in v0.11.0

type Timespan time.Duration

func (Timespan) Format added in v0.11.0

func (t Timespan) Format(format string) string

type Trampoline

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

func (*Trampoline) Callback

func (t *Trampoline) Callback() any

func (*Trampoline) CanBatch added in v0.10.0

func (t *Trampoline) CanBatch() bool

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, *promise.Promise[any])

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 TypeSpec added in v0.30.25

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

TypeSpec creates a HandlerInfo using all the exported methods of reflect.Type instance.

func (TypeSpec) Name added in v0.30.25

func (s TypeSpec) Name() string

func (TypeSpec) PkgPath added in v0.30.25

func (s TypeSpec) PkgPath() string

func (TypeSpec) String added in v0.30.25

func (s TypeSpec) String() string

func (TypeSpec) Type added in v0.30.25

func (s TypeSpec) Type() reflect.Type

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

Jump to

Keyboard shortcuts

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