Skip to content

v0.10.0

Choose a tag to compare

@floatdrop floatdrop released this 06 Sep 08:21
· 15 commits to main since this release
e4999c2

A service can be wrapped without being replaced (#1), which was the last
open issue and the gap most often felt next to uber/fx. go doc -all
against 0.9.1 adds Scope.Wrap and changes no signature; an upgrade cannot
break a caller, since every new rejection involves a wrapper.

Added

  • Scope.Wrap[T](fn) composes over whatever serves T when it is called,
    the latest registration in this scope or the one an ancestor provides
    (#1). fn takes the wrapped value first and its other dependencies after
    it, read with reflection as Wire reads a constructor, and returns T or
    (T, error). What is wrapped keeps its registration, hooks and lifetime, is
    built first and stopped after the wrapper; wrappers chain in registration
    order; a wrapper takes the wrapped lifetime, and Scoped() on it makes one
    per resolving scope over a shared inner. A wrapper in a child scope applies
    to that scope and its descendants only, which is what uber/fx calls
    Decorate. Nothing to wrap, a group, and the Group() or Override()
    markers on a wrapper are rejected. A registration some wrapper composes
    over can no longer be overridden, in its scope or a descendant's, until an
    Override() replaces the wrapper itself. Explain names a wrapper and
    draws what it wraps beneath it; Validate walks the chain.