fixup handlers

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2024-03-12 00:02:48 +03:00
parent 4c3d26c39b
commit 954101f887
3 changed files with 1407 additions and 12 deletions

19
go.mod
View File

@ -6,19 +6,20 @@ require (
go.unistack.org/micro-codec-yaml/v4 v4.0.0 go.unistack.org/micro-codec-yaml/v4 v4.0.0
go.unistack.org/micro-proto/v4 v4.0.1 go.unistack.org/micro-proto/v4 v4.0.1
go.unistack.org/micro/v4 v4.0.17 go.unistack.org/micro/v4 v4.0.17
go.unistack.org/protoc-gen-go-micro/v4 v4.0.7 go.unistack.org/protoc-gen-go-micro/v4 v4.0.13
golang.org/x/net v0.15.0 golang.org/x/net v0.22.0
) )
require ( require (
github.com/fatih/structtag v1.2.0 // indirect github.com/fatih/structtag v1.2.0 // indirect
github.com/golang/protobuf v1.5.3 // indirect github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic v0.6.9 // indirect github.com/google/gnostic v0.7.0 // indirect
golang.org/x/mod v0.12.0 // indirect github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
golang.org/x/sys v0.12.0 // indirect golang.org/x/mod v0.16.0 // indirect
golang.org/x/tools v0.11.0 // indirect golang.org/x/sys v0.18.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect golang.org/x/tools v0.19.0 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect sigs.k8s.io/yaml v1.4.0 // indirect
) )

1395
go.sum

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,6 @@ import (
"sync" "sync"
codecpb "go.unistack.org/micro-proto/v4/codec" codecpb "go.unistack.org/micro-proto/v4/codec"
"go.unistack.org/micro/v4/errors"
"go.unistack.org/micro/v4/logger" "go.unistack.org/micro/v4/logger"
"go.unistack.org/micro/v4/metadata" "go.unistack.org/micro/v4/metadata"
"go.unistack.org/micro/v4/meter" "go.unistack.org/micro/v4/meter"
@ -82,7 +81,7 @@ func NewHandler(opts ...Option) *Handler {
func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error { func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.Frame) error {
log, ok := logger.FromContext(ctx) log, ok := logger.FromContext(ctx)
if !ok { if !ok {
log = logger.DefaultLogger() log = logger.DefaultLogger
} }
buf := bufPool.Get().(*bytes.Buffer) buf := bufPool.Get().(*bytes.Buffer)
@ -103,7 +102,7 @@ func (h *Handler) Metrics(ctx context.Context, req *codecpb.Frame, rsp *codecpb.
} }
if err := h.opts.Meter.Write(w, h.opts.MeterOptions...); err != nil { if err := h.opts.Meter.Write(w, h.opts.MeterOptions...); err != nil {
log.Error(ctx, errors.InternalServerError(h.opts.Name, "%v", err)) log.Error(ctx, "http/meter: write failed", err)
return nil return nil
} }