@@ -10,8 +10,16 @@ type HandlerOptions struct {
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
func NewHandlerOptions() HandlerOptions {
|
||||
return HandlerOptions{Context: context.Background()}
|
||||
func NewHandlerOptions(opts ...HandlerOption) HandlerOptions {
|
||||
options := HandlerOptions{
|
||||
Context: context.Background(),
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&options)
|
||||
}
|
||||
|
||||
return options
|
||||
}
|
||||
|
||||
type SubscriberOption func(*SubscriberOptions)
|
||||
@@ -26,16 +34,16 @@ type SubscriberOptions struct {
|
||||
}
|
||||
|
||||
func NewSubscriberOptions(opts ...SubscriberOption) SubscriberOptions {
|
||||
opt := SubscriberOptions{
|
||||
options := SubscriberOptions{
|
||||
AutoAck: true,
|
||||
Context: context.Background(),
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
o(&options)
|
||||
}
|
||||
|
||||
return opt
|
||||
return options
|
||||
}
|
||||
|
||||
// EndpointMetadata is a Handler option that allows metadata to be added to
|
||||
|
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/unistack-org/micro/v3/logger"
|
||||
"github.com/unistack-org/micro/v3/registry"
|
||||
"github.com/unistack-org/micro/v3/tracer"
|
||||
"github.com/unistack-org/micro/v3/transport"
|
||||
"github.com/unistack-org/micro/v3/network/transport"
|
||||
)
|
||||
|
||||
type Options struct {
|
||||
|
Reference in New Issue
Block a user