From 277f04ba19c792f562d90617fce3042546e24835 Mon Sep 17 00:00:00 2001 From: Vasiliy Tolstov Date: Fri, 27 Dec 2024 19:33:46 +0300 Subject: [PATCH] register: add Codec option Signed-off-by: Vasiliy Tolstov --- register/options.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/register/options.go b/register/options.go index a0d13f64..d46c4ced 100644 --- a/register/options.go +++ b/register/options.go @@ -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 + } +}