Decruft the broker by removing Event interface (#1940)

This commit is contained in:
Asim Aslam
2020-08-18 14:00:51 +01:00
committed by GitHub
parent a2a808f2d6
commit 4413372a3f
14 changed files with 45 additions and 226 deletions

View File

@@ -13,10 +13,6 @@ type Options struct {
Secure bool
Codec codec.Marshaler
// Handler executed when error happens in broker message
// processing
ErrorHandler Handler
TLSConfig *tls.Config
// Registry used for clustering
Registry registry.Registry
@@ -32,9 +28,9 @@ type PublishOptions struct {
}
type SubscribeOptions struct {
// AutoAck defaults to true. When a handler returns
// with a nil error the message is acked.
AutoAck bool
// Handler executed when errors occur processing messages
ErrorHandler ErrorHandler
// Subscribers with the same queue name
// will create a shared subscription where each
// receives a subset of messages.
@@ -59,9 +55,7 @@ func PublishContext(ctx context.Context) PublishOption {
type SubscribeOption func(*SubscribeOptions)
func NewSubscribeOptions(opts ...SubscribeOption) SubscribeOptions {
opt := SubscribeOptions{
AutoAck: true,
}
opt := SubscribeOptions{}
for _, o := range opts {
o(&opt)
@@ -85,18 +79,10 @@ func Codec(c codec.Marshaler) Option {
}
}
// DisableAutoAck will disable auto acking of messages
// after they have been handled.
func DisableAutoAck() SubscribeOption {
return func(o *SubscribeOptions) {
o.AutoAck = false
}
}
// ErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func ErrorHandler(h Handler) Option {
return func(o *Options) {
func HandleError(h ErrorHandler) SubscribeOption {
return func(o *SubscribeOptions) {
o.ErrorHandler = h
}
}