register: add Codec option
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
470263ff5f
commit
277f04ba19
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user