v0.18.0
Custom Error Values
Recall that the final return value of every component method must be an error:
// A calculator component. Note that the final return value of every method is an error.
type Calculator interface {
Add(context.Context, int, int) (int, error)
Subtract(context.Context, int, int) (int, error)
Multiply(context.Context, int, int) (int, error)
}
Before v0.18.0, these error values were encoded and decoded using a custom protocol that did not preserve the type of the error. For example, if you returned a custom error value from a component method (e.g., return &customError{}
), the caller of the method would not receive an error of the same type.
In v0.18.0, any errors that embed weaver.AutoMarshal
will be properly encoded and decoded. Here's a simple example:
type customError struct {
weaver.AutoMarshal
msg string
}
Errors that don't embed weaver.AutoMarshal
will continue to use our custom protocol.
See #456, #458, and #457 for details.
Tracing
weaver.InstrumentHandler
now automatically implements time-based trace sampling for you. We also optimized how we store and query traces on disk, and we now garbage collect old traces. We also improved the tracing UI in weaver single dashboard
and weaver multi dashboard
. See #450, #459, #460, #464, #465, #472, and #478 for details
weaver.Instance
Removed
The weaver.Instance
interface was removed (#455). It was not being used and was obsoleted by weaver.InstanceOf[T]
.
Bug Fixes
- Previously, the logs produced by
weaver multi logs --format=json
did not include log entry attributes. This was fixed in #470.
Internals
Most of the core weaver implementation has moved to the private internal/weaver
package. This has no effect on the users of Service Weaver, but does enable some internal cleanups. For example, we split the weavelet implementation into two separate and much simpler weavelets, one for go run
and one for all other deployers. For those interested in learning more about the internals of Service Weaver, this change should make it much easier to understand what's going on under the hood. See #461 and #466 for details.
Full Changelog: v0.17.0...v0.18.0