fixup deps
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
9a95fda93f
commit
2504345815
@ -8,7 +8,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/imdario/mergo"
|
"dario.cat/mergo"
|
||||||
"go.unistack.org/micro/v4/options"
|
"go.unistack.org/micro/v4/options"
|
||||||
mid "go.unistack.org/micro/v4/util/id"
|
mid "go.unistack.org/micro/v4/util/id"
|
||||||
rutil "go.unistack.org/micro/v4/util/reflect"
|
rutil "go.unistack.org/micro/v4/util/reflect"
|
||||||
|
2
go.mod
2
go.mod
@ -3,9 +3,9 @@ module go.unistack.org/micro/v4
|
|||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
dario.cat/mergo v1.0.0
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.0
|
github.com/DATA-DOG/go-sqlmock v1.5.0
|
||||||
github.com/google/uuid v1.3.0
|
github.com/google/uuid v1.3.0
|
||||||
github.com/imdario/mergo v0.3.15
|
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||||
github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5
|
github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5
|
||||||
golang.org/x/sync v0.3.0
|
golang.org/x/sync v0.3.0
|
||||||
|
4
go.sum
4
go.sum
@ -1,3 +1,5 @@
|
|||||||
|
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
|
||||||
|
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
github.com/DATA-DOG/go-sqlmock v1.5.0 h1:Shsta01QNfFxHCfpW6YH2STWB0MudeXXEWMr20OEh60=
|
||||||
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
github.com/DATA-DOG/go-sqlmock v1.5.0/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
|
||||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
@ -7,8 +9,6 @@ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
github.com/imdario/mergo v0.3.15 h1:M8XP7IuFNsqUx6VPK2P9OSmsYsI/YFaGil0uD21V3dM=
|
|
||||||
github.com/imdario/mergo v0.3.15/go.mod h1:WBLT9ZmE3lPoWsEzCh9LPo3TiwVN+ZKEjmz+hD27ysY=
|
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||||
github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5 h1:G/FZtUu7a6NTWl3KUHMV9jkLAh/Rvtf03NWMHaEDl+E=
|
github.com/silas/dag v0.0.0-20220518035006-a7e85ada93c5 h1:G/FZtUu7a6NTWl3KUHMV9jkLAh/Rvtf03NWMHaEDl+E=
|
||||||
|
@ -7,12 +7,13 @@ import (
|
|||||||
|
|
||||||
"go.unistack.org/micro/v4/client"
|
"go.unistack.org/micro/v4/client"
|
||||||
"go.unistack.org/micro/v4/logger"
|
"go.unistack.org/micro/v4/logger"
|
||||||
|
"go.unistack.org/micro/v4/options"
|
||||||
"go.unistack.org/micro/v4/server"
|
"go.unistack.org/micro/v4/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// DefaultClientCallObserver called by wrapper in client Call
|
// DefaultClientCallObserver called by wrapper in client Call
|
||||||
DefaultClientCallObserver = func(ctx context.Context, req client.Request, rsp interface{}, opts []client.CallOption, err error) []string {
|
DefaultClientCallObserver = func(ctx context.Context, req client.Request, rsp interface{}, opts []options.Option, err error) []string {
|
||||||
labels := []string{"service", req.Service(), "endpoint", req.Endpoint()}
|
labels := []string{"service", req.Service(), "endpoint", req.Endpoint()}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
labels = append(labels, "error", err.Error())
|
labels = append(labels, "error", err.Error())
|
||||||
@ -21,7 +22,7 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DefaultClientStreamObserver called by wrapper in client Stream
|
// DefaultClientStreamObserver called by wrapper in client Stream
|
||||||
DefaultClientStreamObserver = func(ctx context.Context, req client.Request, opts []client.CallOption, stream client.Stream, err error) []string {
|
DefaultClientStreamObserver = func(ctx context.Context, req client.Request, opts []options.Option, stream client.Stream, err error) []string {
|
||||||
labels := []string{"service", req.Service(), "endpoint", req.Endpoint()}
|
labels := []string{"service", req.Service(), "endpoint", req.Endpoint()}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
labels = append(labels, "error", err.Error())
|
labels = append(labels, "error", err.Error())
|
||||||
@ -60,9 +61,9 @@ type lWrapper struct {
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
// ClientCallObserver func signature
|
// ClientCallObserver func signature
|
||||||
ClientCallObserver func(context.Context, client.Request, interface{}, []client.CallOption, error) []string
|
ClientCallObserver func(context.Context, client.Request, interface{}, []options.Option, error) []string
|
||||||
// ClientStreamObserver func signature
|
// ClientStreamObserver func signature
|
||||||
ClientStreamObserver func(context.Context, client.Request, []client.CallOption, client.Stream, error) []string
|
ClientStreamObserver func(context.Context, client.Request, []options.Option, client.Stream, error) []string
|
||||||
// ClientCallFuncObserver func signature
|
// ClientCallFuncObserver func signature
|
||||||
ClientCallFuncObserver func(context.Context, string, client.Request, interface{}, client.CallOptions, error) []string
|
ClientCallFuncObserver func(context.Context, string, client.Request, interface{}, client.CallOptions, error) []string
|
||||||
// ServerHandlerObserver func signature
|
// ServerHandlerObserver func signature
|
||||||
@ -167,7 +168,7 @@ func SkipEndpoints(eps ...string) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *lWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
|
func (l *lWrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...options.Option) error {
|
||||||
err := l.Client.Call(ctx, req, rsp, opts...)
|
err := l.Client.Call(ctx, req, rsp, opts...)
|
||||||
|
|
||||||
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
||||||
@ -190,7 +191,7 @@ func (l *lWrapper) Call(ctx context.Context, req client.Request, rsp interface{}
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *lWrapper) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
|
func (l *lWrapper) Stream(ctx context.Context, req client.Request, opts ...options.Option) (client.Stream, error) {
|
||||||
stream, err := l.Client.Stream(ctx, req, opts...)
|
stream, err := l.Client.Stream(ctx, req, opts...)
|
||||||
|
|
||||||
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package wrapper // import "go.unistack.org/micro/v4/meter/wrapper"
|
package wrapper
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
@ -7,6 +7,7 @@ import (
|
|||||||
|
|
||||||
"go.unistack.org/micro/v4/client"
|
"go.unistack.org/micro/v4/client"
|
||||||
"go.unistack.org/micro/v4/meter"
|
"go.unistack.org/micro/v4/meter"
|
||||||
|
"go.unistack.org/micro/v4/options"
|
||||||
"go.unistack.org/micro/v4/semconv"
|
"go.unistack.org/micro/v4/semconv"
|
||||||
"go.unistack.org/micro/v4/server"
|
"go.unistack.org/micro/v4/server"
|
||||||
)
|
)
|
||||||
@ -24,7 +25,7 @@ var (
|
|||||||
// Options struct
|
// Options struct
|
||||||
type Options struct {
|
type Options struct {
|
||||||
Meter meter.Meter
|
Meter meter.Meter
|
||||||
lopts []meter.Option
|
lopts []options.Option
|
||||||
SkipEndpoints []string
|
SkipEndpoints []string
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +36,7 @@ type Option func(*Options)
|
|||||||
func NewOptions(opts ...Option) Options {
|
func NewOptions(opts ...Option) Options {
|
||||||
options := Options{
|
options := Options{
|
||||||
Meter: meter.DefaultMeter,
|
Meter: meter.DefaultMeter,
|
||||||
lopts: make([]meter.Option, 0, 5),
|
lopts: make([]options.Option, 0, 5),
|
||||||
SkipEndpoints: DefaultSkipEndpoints,
|
SkipEndpoints: DefaultSkipEndpoints,
|
||||||
}
|
}
|
||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
@ -137,7 +138,7 @@ func (w *wrapper) CallFunc(ctx context.Context, addr string, req client.Request,
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...client.CallOption) error {
|
func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{}, opts ...options.Option) error {
|
||||||
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
||||||
for _, ep := range w.opts.SkipEndpoints {
|
for _, ep := range w.opts.SkipEndpoints {
|
||||||
if ep == endpoint {
|
if ep == endpoint {
|
||||||
@ -167,7 +168,7 @@ func (w *wrapper) Call(ctx context.Context, req client.Request, rsp interface{},
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...client.CallOption) (client.Stream, error) {
|
func (w *wrapper) Stream(ctx context.Context, req client.Request, opts ...options.Option) (client.Stream, error) {
|
||||||
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
endpoint := fmt.Sprintf("%s.%s", req.Service(), req.Endpoint())
|
||||||
for _, ep := range w.opts.SkipEndpoints {
|
for _, ep := range w.opts.SkipEndpoints {
|
||||||
if ep == endpoint {
|
if ep == endpoint {
|
||||||
|
@ -5,12 +5,13 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"go.unistack.org/micro/v4/options"
|
||||||
"go.unistack.org/micro/v4/store"
|
"go.unistack.org/micro/v4/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestMemoryReInit(t *testing.T) {
|
func TestMemoryReInit(t *testing.T) {
|
||||||
s := store.NewStore(store.Namespace("aaa"))
|
s := store.NewStore(options.Namespace("aaa"))
|
||||||
if err := s.Init(store.Namespace("")); err != nil {
|
if err := s.Init(options.Namespace("")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if len(s.Options().Namespace) > 0 {
|
if len(s.Options().Namespace) > 0 {
|
||||||
@ -28,7 +29,7 @@ func TestMemoryBasic(t *testing.T) {
|
|||||||
|
|
||||||
func TestMemoryPrefix(t *testing.T) {
|
func TestMemoryPrefix(t *testing.T) {
|
||||||
s := store.NewStore()
|
s := store.NewStore()
|
||||||
if err := s.Init(store.Namespace("some-prefix")); err != nil {
|
if err := s.Init(options.Namespace("some-prefix")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
basictest(s, t)
|
basictest(s, t)
|
||||||
@ -36,7 +37,7 @@ func TestMemoryPrefix(t *testing.T) {
|
|||||||
|
|
||||||
func TestMemoryNamespace(t *testing.T) {
|
func TestMemoryNamespace(t *testing.T) {
|
||||||
s := store.NewStore()
|
s := store.NewStore()
|
||||||
if err := s.Init(store.Namespace("some-namespace")); err != nil {
|
if err := s.Init(options.Namespace("some-namespace")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
basictest(s, t)
|
basictest(s, t)
|
||||||
@ -44,7 +45,7 @@ func TestMemoryNamespace(t *testing.T) {
|
|||||||
|
|
||||||
func TestMemoryNamespacePrefix(t *testing.T) {
|
func TestMemoryNamespacePrefix(t *testing.T) {
|
||||||
s := store.NewStore()
|
s := store.NewStore()
|
||||||
if err := s.Init(store.Namespace("some-namespace")); err != nil {
|
if err := s.Init(options.Namespace("some-namespace")); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
basictest(s, t)
|
basictest(s, t)
|
||||||
|
@ -177,7 +177,7 @@ func (ot *tWrapper) Call(ctx context.Context, req client.Request, rsp interface{
|
|||||||
|
|
||||||
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
||||||
tracer.WithSpanKind(tracer.SpanKindClient),
|
tracer.WithSpanKind(tracer.SpanKindClient),
|
||||||
tracer.WithSpanLabels(
|
options.Labels(
|
||||||
"rpc.service", req.Service(),
|
"rpc.service", req.Service(),
|
||||||
"rpc.method", req.Method(),
|
"rpc.method", req.Method(),
|
||||||
"rpc.flavor", "rpc",
|
"rpc.flavor", "rpc",
|
||||||
@ -206,7 +206,7 @@ func (ot *tWrapper) Stream(ctx context.Context, req client.Request, opts ...opti
|
|||||||
|
|
||||||
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
||||||
tracer.WithSpanKind(tracer.SpanKindClient),
|
tracer.WithSpanKind(tracer.SpanKindClient),
|
||||||
tracer.WithSpanLabels(
|
options.Labels(
|
||||||
"rpc.service", req.Service(),
|
"rpc.service", req.Service(),
|
||||||
"rpc.method", req.Method(),
|
"rpc.method", req.Method(),
|
||||||
"rpc.flavor", "rpc",
|
"rpc.flavor", "rpc",
|
||||||
@ -240,7 +240,7 @@ func (ot *tWrapper) ServerHandler(ctx context.Context, req server.Request, rsp i
|
|||||||
|
|
||||||
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-server", req.Service(), req.Method()),
|
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-server", req.Service(), req.Method()),
|
||||||
tracer.WithSpanKind(tracer.SpanKindServer),
|
tracer.WithSpanKind(tracer.SpanKindServer),
|
||||||
tracer.WithSpanLabels(
|
options.Labels(
|
||||||
"rpc.service", req.Service(),
|
"rpc.service", req.Service(),
|
||||||
"rpc.method", req.Method(),
|
"rpc.method", req.Method(),
|
||||||
"rpc.flavor", "rpc",
|
"rpc.flavor", "rpc",
|
||||||
@ -293,7 +293,7 @@ func (ot *tWrapper) ClientCallFunc(ctx context.Context, addr string, req client.
|
|||||||
|
|
||||||
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
nctx, sp := ot.opts.Tracer.Start(ctx, fmt.Sprintf("%s.%s rpc-client", req.Service(), req.Method()),
|
||||||
tracer.WithSpanKind(tracer.SpanKindClient),
|
tracer.WithSpanKind(tracer.SpanKindClient),
|
||||||
tracer.WithSpanLabels(
|
options.Labels(
|
||||||
"rpc.service", req.Service(),
|
"rpc.service", req.Service(),
|
||||||
"rpc.method", req.Method(),
|
"rpc.method", req.Method(),
|
||||||
"rpc.flavor", "rpc",
|
"rpc.flavor", "rpc",
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"go.unistack.org/micro/v4/codec"
|
"go.unistack.org/micro/v4/codec"
|
||||||
"go.unistack.org/micro/v4/errors"
|
"go.unistack.org/micro/v4/errors"
|
||||||
"go.unistack.org/micro/v4/metadata"
|
"go.unistack.org/micro/v4/metadata"
|
||||||
|
"go.unistack.org/micro/v4/options"
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -226,7 +227,7 @@ func NewRequestFromFile(c client.Client, reqfile string) (client.Request, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
req := c.NewRequest("test", endpoint, &codec.Frame{Data: reqbuf}, client.RequestContentType(ct))
|
req := c.NewRequest("test", endpoint, &codec.Frame{Data: reqbuf}, options.ContentType(ct))
|
||||||
|
|
||||||
return req, nil
|
return req, nil
|
||||||
}
|
}
|
||||||
@ -373,7 +374,7 @@ func Run(ctx context.Context, c client.Client, m sqlmock.Sqlmock, dir string, ex
|
|||||||
data := &codec.Frame{}
|
data := &codec.Frame{}
|
||||||
md := metadata.New(1)
|
md := metadata.New(1)
|
||||||
md.Set("X-Request-Id", xrid)
|
md.Set("X-Request-Id", xrid)
|
||||||
cerr := c.Call(metadata.NewOutgoingContext(gctx, md), treq, data, client.WithContentType(treq.ContentType()))
|
cerr := c.Call(metadata.NewOutgoingContext(gctx, md), treq, data, options.ContentType(treq.ContentType()))
|
||||||
|
|
||||||
var rspfile string
|
var rspfile string
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user