locator

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 7 Imported by: 5 modules, 20 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	PriorityDefault   = 0
	PrioritySource    = 0
	PriorityTransform = 10
	PriorityDependent = 20
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthoritativeLocator added in v0.2.0

type AuthoritativeLocator interface{ Owns(string) bool }

AuthoritativeLocator distinguishes an owned absence from provider fallback.

type BodyNullPolicyLocator added in v0.4.0

type BodyNullPolicyLocator interface {
	ValueWithBodyNullPolicy(context.Context, reflect.Type, string, string) (any, bool, error)
}

BodyNullPolicyLocator recognizes body null in its native source decoder. The policy is invocation-local: implementations must never mutate a provider or treat an arbitrary provider's nil value as evidence of JSON literal null.

type CachePolicy added in v0.2.0

type CachePolicy interface{ DefaultCacheable() bool }

type Locator

type Locator interface {
	Value(ctx context.Context, targetType reflect.Type, name string) (interface{}, bool, error)
	Kind() string
}

type MetadataScope added in v0.2.0

type MetadataScope interface{ MetadataRequested() bool }

MetadataScope is an optional capability; existing Scope implementations need not implement it. Providers may avoid producing metadata unless requested.

type Provider

type Provider interface {
	Locate(state *structology.State) Locator
	Kind() string
	Priority() int
}

func ComposeProviders added in v0.2.0

func ComposeProviders(kind string, layers ...ProviderLayer) (Provider, error)

type ProviderLayer added in v0.2.0

type ProviderLayer struct {
	Name     string
	Provider Provider
}

type Registry

type Registry struct {
	internal.Map[string, Provider]
	// contains filtered or unexported fields
}

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Child added in v0.3.0

func (r *Registry) Child() *Registry

Child creates an empty provider layer that falls back to this registry.

func (*Registry) Keys added in v0.3.0

func (r *Registry) Keys() []string

Keys returns the distinct provider kinds visible in this registry. Local providers shadow parent providers with the same kind.

func (*Registry) Lookup

func (r *Registry) Lookup(kind string) (Provider, bool)

Lookup returns a provider for a given kind

func (*Registry) Register

func (r *Registry) Register(provider Provider) error

Register registers a provider for a given kind

func (*Registry) Unregister

func (r *Registry) Unregister(kind string)

Unregister unregisters a provider for a given kind

type Resolver

type Resolver interface {
	Value(ctx context.Context, location *state.Location) (interface{}, bool, error)
}

type Scope added in v0.2.0

type Scope interface {
	Resolver
	Bind(context.Context, any) error
	BindTarget(context.Context, any) error
}

type ScopedLocator added in v0.2.0

type ScopedLocator interface {
	Locator
	ValueInScope(context.Context, Scope, reflect.Type, string) (any, bool, error)
}

type SourceCapturer added in v0.2.0

type SourceCapturer interface {
	CaptureSource(context.Context, reflect.Type, string) (any, bool, error)
}

SourceCapturer lets a source preserve its raw representation before target decoding (for example JSON body omission/number precision). JSON source bytes use json.RawMessage; other values retain normal declared source conversion. Implementations must not bind targets or evaluate downstream dependencies.

type ValueWithMetadata added in v0.2.0

type ValueWithMetadata struct {
	Value    any
	Metadata any
}

ValueWithMetadata is a reserved provider result envelope. Bindly exposes Value through its ordinary APIs and transports Metadata only to an opt-in observer. Metadata is opaque, invocation-scoped, and must be immutable or otherwise safe for all consumers of a cached resolution. It is never serialized by Bindly.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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