v0.16.0
New weaver.Run
API
In v0.15.0, the main component had a Main
method that was automatically invoked by weaver.Run
. For v0.16.0, we removed this Main
method. weaver.Run
now receives a lambda argument with a pointer to the main component implementation as an argument (#409). Here's an example.
type app struct {
weaver.Implements[weaver.Main]
}
func main() {
err := weaver.Run(context.Background(), func (_ context.Context, app *app) error {
app.Logger().Info("Hello, World!")
return nil
})
if err != nil {
log.Fatal(err)
}
}
New weavertest
API
Recall that the Test
and Benchmark
methods of a weavertest.Runner
receive a lambda with component interface arguments (#406):
// Test the Foo and Bar components.
runner.Test(t, func(t *testing.T, foo Foo, bar Bar) {...})
In v0.16.0, these lambdas can also receive pointers to component implementations:
// Test the foo and bar component implementations.
runner.Test(t, func(t *testing.T, foo *foo, bar *bar) {...})
The Test
and Benchmark
methods no longer automatically run the Main
method, which is obvious considering we also removed the Main
method (#405)! This makes the new weavertest API essential for testing the HTTP server exported by a main component. See examples/chat/server_test.go
for an example.
Listener Config
Listener names are now case sensitive (#404).
Bug Fixes
v0.16.0 also fixes bugs in the onlineboutique
app (#393) and in the output of weaver version
(#399).
Full Changelog: v0.15.0...v0.16.0