Skip to content

v0.4.0

Choose a tag to compare

@maguro maguro released this 18 Sep 18:26
· 18 commits to master since this release

An alpha release. The API can still change before v1.0.

Breaking

  • yama.Option is now a function type. It was an interface with one method. Code that builds options with WithInterceptors, WithBeginComponents, and WithEndComponents needs no change. Code that named the Apply method does.

New

  • The closer directive. A //yama:closer comment in the doc comment of a provider's declaration closes the component in the teardown pass. Yama wraps the component in a Stopper that calls Close. The call runs under the pass context and through the Stop interceptors. This is for a type from a package you do not own, such as *sql.DB.

    // NewDB provides the database handle.
    //
    //yama:closer
    func NewDB(cfg Config) (*sql.DB, error) {
    	return sql.Open(cfg.Driver, cfg.DSN)
    }

    A wire.Struct entry has no declaration, so its directive goes on the entry in the wire.NewSet call.

  • A warning for a closer that nothing closes. A run prints one line on standard error for a component that implements io.Closer and has no directive, no cleanup, and no Stop. The warning does not stop generation.

  • The noclose directive. A //yama:noclose comment states that the lifecycle does not close the component, and it stops the warning.

See the guide and ADR-016.

Changed

  • A run names its backup files with a .bak suffix, not a leading dot. A directory listing now shows what an interrupted run left behind.
  • Regenerate after you upgrade. Generated code calls rt.AsStopper for a closer component, so the yama tool and the l7e.io/yama module must be the same version.

Full changes: v0.3.0...v0.4.0