bindutil

package
v2.33.7 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package bindutil holds the mechanics every typed resource binder (db.Bind, cache.Bind, mail.Bind, storage.Bind) shares: discovering the embedded manager field on the marker type, constructing the holder, and the dashboard-registration option set. Each binder keeps only what genuinely differs — how its manager is built and how its resource registers.

Before this package the four binders carried verbatim copies, and they had already diverged: db evaluated its options lazily (so BindFromConfig works under nexus.Boot, which parses nexus.toml after option construction) while the other three applied them eagerly. Sharing the plumbing makes the lazy semantics uniform by construction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmbeddedField

func EmbeddedField[T any](pkg string, want reflect.Type, example string) int

EmbeddedField returns the index of T's embedded field of exact type want (a *Manager pointer type). A T that doesn't match panics here, at wiring time, with pkg-qualified guidance — never at request time.

func ManagerOf

func ManagerOf[M any](h any, fieldIdx int) M

ManagerOf reads the embedded manager back out of a holder.

func NewHolder

func NewHolder[T any](fieldIdx int, manager any) *T

NewHolder allocates a *T and stores manager into its embedded field.

Types

type Option

type Option func(*Options)

Option mutates an Options. The binder packages alias their public BindOption to this type, so options remain interchangeable with the pre-consolidation API (the config struct was unexported everywhere, so no caller could have depended on its shape).

type Options

type Options struct {
	Description string
	Details     map[string]any
	AsDefault   bool
}

Options is the shared dashboard-registration knob set. Each binder package re-exports the With* constructors it supports so godoc and call sites stay package-local (cache.WithDefault, db.WithDetails, …).

func Apply

func Apply(opts []Option) Options

Apply folds opts into a value. Call it inside the register invoke — never at option-construction time — so options derived from config parsed at boot (BindFromConfig under nexus.Boot) resolve lazily.

Jump to

Keyboard shortcuts

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