add context Must methods
All checks were successful
lint / lint (pull_request) Successful in 1m39s
test / test (pull_request) Successful in 4m12s

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2024-12-18 01:31:21 +03:00
parent 19b04fe070
commit 330d8b149a
16 changed files with 162 additions and 45 deletions

View File

@@ -15,6 +15,15 @@ func FromContext(ctx context.Context) (Meter, bool) {
return c, ok
}
// MustContext get meter from context
func MustContext(ctx context.Context) Meter {
m, ok := FromContext(ctx)
if !ok {
panic("missing meter")
}
return m
}
// NewContext put meter in context
func NewContext(ctx context.Context, c Meter) context.Context {
if ctx == nil {