|
|
@@ -5,6 +5,7 @@ import (
|
|
|
|
"crypto/tls"
|
|
|
|
"crypto/tls"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"go.unistack.org/micro/v3/codec"
|
|
|
|
"go.unistack.org/micro/v3/logger"
|
|
|
|
"go.unistack.org/micro/v3/logger"
|
|
|
|
"go.unistack.org/micro/v3/meter"
|
|
|
|
"go.unistack.org/micro/v3/meter"
|
|
|
|
"go.unistack.org/micro/v3/tracer"
|
|
|
|
"go.unistack.org/micro/v3/tracer"
|
|
|
@@ -26,6 +27,8 @@ type Options struct {
|
|
|
|
Name string
|
|
|
|
Name string
|
|
|
|
// Addrs specifies register addrs
|
|
|
|
// Addrs specifies register addrs
|
|
|
|
Addrs []string
|
|
|
|
Addrs []string
|
|
|
|
|
|
|
|
// Codec used to marshal/unmarshal data in register
|
|
|
|
|
|
|
|
Codec codec.Codec
|
|
|
|
// Timeout specifies timeout
|
|
|
|
// Timeout specifies timeout
|
|
|
|
Timeout time.Duration
|
|
|
|
Timeout time.Duration
|
|
|
|
}
|
|
|
|
}
|
|
|
@@ -37,6 +40,7 @@ func NewOptions(opts ...Option) Options {
|
|
|
|
Meter: meter.DefaultMeter,
|
|
|
|
Meter: meter.DefaultMeter,
|
|
|
|
Tracer: tracer.DefaultTracer,
|
|
|
|
Tracer: tracer.DefaultTracer,
|
|
|
|
Context: context.Background(),
|
|
|
|
Context: context.Background(),
|
|
|
|
|
|
|
|
Codec: codec.NewCodec(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, o := range opts {
|
|
|
|
for _, o := range opts {
|
|
|
|
o(&options)
|
|
|
|
o(&options)
|
|
|
@@ -130,9 +134,12 @@ func NewLookupOptions(opts ...LookupOption) LookupOptions {
|
|
|
|
|
|
|
|
|
|
|
|
// ListOptions holds the list options for list method
|
|
|
|
// ListOptions holds the list options for list method
|
|
|
|
type ListOptions struct {
|
|
|
|
type ListOptions struct {
|
|
|
|
|
|
|
|
// Context used to store additional options
|
|
|
|
Context context.Context
|
|
|
|
Context context.Context
|
|
|
|
// Namespace to scope the request to
|
|
|
|
// Namespace to scope the request to
|
|
|
|
Namespace string
|
|
|
|
Namespace string
|
|
|
|
|
|
|
|
// Name filter services by name
|
|
|
|
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// NewListOptions returns list options filled by opts
|
|
|
|
// NewListOptions returns list options filled by opts
|
|
|
@@ -294,9 +301,24 @@ func ListNamespace(d string) ListOption {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ListName sets the name for list method to filter needed services
|
|
|
|
|
|
|
|
func ListName(n string) ListOption {
|
|
|
|
|
|
|
|
return func(o *ListOptions) {
|
|
|
|
|
|
|
|
o.Name = n
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Name sets the name
|
|
|
|
// Name sets the name
|
|
|
|
func Name(n string) Option {
|
|
|
|
func Name(n string) Option {
|
|
|
|
return func(o *Options) {
|
|
|
|
return func(o *Options) {
|
|
|
|
o.Name = n
|
|
|
|
o.Name = n
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type codecKey struct{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func Codec(c codec.Codec) Option {
|
|
|
|
|
|
|
|
return func(o *Options) {
|
|
|
|
|
|
|
|
o.Codec = c
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|