add copy metadata from grpc-go #386

Merged
vtolstov merged 25 commits from devstigneev/micro:v3 into v4 2025-01-25 15:57:56 +03:00
12 changed files with 318 additions and 172 deletions
Showing only changes of commit a66433af30 - Show all commits

View File

@@ -5,6 +5,7 @@ import (
"crypto/tls"
"time"
"go.unistack.org/micro/v3/codec"
"go.unistack.org/micro/v3/logger"
"go.unistack.org/micro/v3/meter"
"go.unistack.org/micro/v3/tracer"
@@ -26,6 +27,8 @@ type Options struct {
Name string
// Addrs specifies register addrs
Addrs []string
// Codec used to marshal/unmarshal data in register
Codec codec.Codec
// Timeout specifies timeout
Timeout time.Duration
}
@@ -37,6 +40,7 @@ func NewOptions(opts ...Option) Options {
Meter: meter.DefaultMeter,
Tracer: tracer.DefaultTracer,
Context: context.Background(),
Codec: codec.NewCodec(),
}
for _, o := range opts {
o(&options)
@@ -310,3 +314,11 @@ func Name(n string) Option {
o.Name = n
}
}
type codecKey struct{}
func Codec(c codec.Codec) Option {
return func(o *Options) {
o.Codec = c
}
}