core

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeLocation

type CodeLocation struct {
	File string
	Line int
}

CodeLocation represents a code location for error reporting

func FindUserCodeLocation

func FindUserCodeLocation() CodeLocation

FindUserCodeLocation walks up the call stack to find the first non-framework code location

type DependencyCore

type DependencyCore struct {
	Name               string
	LoadFn             func(ctx context.Context, input interface{}) (interface{}, error)
	TypeFn             func() reflect.Type
	InputFields        reflect.Type
	RequiredMiddleware []MiddlewareFunc
}

DependencyCore contains the core dependency functionality

func NewDependencyCore

func NewDependencyCore(name string, loadFn interface{}) *DependencyCore

NewDependencyCore creates a new dependency with automatic type inference

func (*DependencyCore) Load

func (d *DependencyCore) Load(ctx context.Context, input interface{}) (interface{}, error)

Load executes the dependency's load function

func (*DependencyCore) RequiresMiddleware

func (d *DependencyCore) RequiresMiddleware(middleware ...MiddlewareFunc) *DependencyCore

RequiresMiddleware adds middleware requirements to this dependency

func (*DependencyCore) Type

func (d *DependencyCore) Type() reflect.Type

Type returns the type this dependency provides

func (*DependencyCore) WithInputFields

func (d *DependencyCore) WithInputFields(inputExample interface{}) *DependencyCore

WithInputFields adds input field requirements to a dependency

type DependencyRegistry

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

DependencyRegistry manages dependency mapping and validation

func NewDependencyRegistry

func NewDependencyRegistry() *DependencyRegistry

NewDependencyRegistry creates a new dependency registry

func (*DependencyRegistry) Add

Add adds a dependency to the registry

func (*DependencyRegistry) Get

Get retrieves a dependency by type

func (*DependencyRegistry) GetAll

func (r *DependencyRegistry) GetAll() map[reflect.Type]*DependencyCore

GetAll returns all dependencies

func (*DependencyRegistry) ValidateHandlerDependencies

func (r *DependencyRegistry) ValidateHandlerDependencies(handlerType reflect.Type) (*ValidationResult, error)

ValidateHandlerDependencies validates handler dependencies against registry

type MiddlewareFunc

type MiddlewareFunc interface{}

MiddlewareFunc represents middleware signature

type MiddlewareUtils

type MiddlewareUtils struct{}

MiddlewareUtils provides middleware management utilities

func (MiddlewareUtils) DeduplicateMiddleware

func (m MiddlewareUtils) DeduplicateMiddleware(middlewares []MiddlewareFunc) []MiddlewareFunc

DeduplicateMiddleware removes duplicate middleware while preserving order

func (MiddlewareUtils) GetMiddlewarePointer

func (MiddlewareUtils) GetMiddlewarePointer(middleware MiddlewareFunc) uintptr

GetMiddlewarePointer returns the function pointer value for middleware deduplication

func (MiddlewareUtils) RemoveMiddleware

func (m MiddlewareUtils) RemoveMiddleware(middlewares []MiddlewareFunc, toRemove ...MiddlewareFunc) []MiddlewareFunc

RemoveMiddleware removes specific middleware from a slice

type ValidationResult

type ValidationResult struct {
	MissingTypes []reflect.Type
	UnusedDeps   []*DependencyCore
	DepsByType   map[reflect.Type]*DependencyCore
}

ValidationResult contains dependency validation results

Jump to

Keyboard shortcuts

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