move implementations to external repos (#17)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2020-08-25 13:44:41 +03:00
committed by GitHub
parent c4a303190a
commit 0f4b1435d9
238 changed files with 151 additions and 37364 deletions

View File

@@ -9,10 +9,15 @@ import (
)
type Options struct {
AutoAck bool
Addrs []string
Secure bool
Codec codec.Marshaler
// Handler executed when errors occur processing messages
ErrorHandler Handler
TLSConfig *tls.Config
// Registry used for clustering
Registry registry.Registry
@@ -28,13 +33,16 @@ type PublishOptions struct {
}
type SubscribeOptions struct {
// Handler executed when errors occur processing messages
ErrorHandler ErrorHandler
// AutoAck ack messages if handler returns nil err
AutoAck bool
// Subscribers with the same queue name
// Handler executed when errors occur processing messages
ErrorHandler Handler
// Subscribers with the same group name
// will create a shared subscription where each
// receives a subset of messages.
Queue string
Group string
// Other options for implementations of the interface
// can be stored in a context
@@ -81,16 +89,24 @@ func Codec(c codec.Marshaler) Option {
// ErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func HandleError(h ErrorHandler) SubscribeOption {
func ErrorHandler(h Handler) Option {
return func(o *Options) {
o.ErrorHandler = h
}
}
// SubscribeErrorHandler will catch all broker errors that cant be handled
// in normal way, for example Codec errors
func SubscribeErrorHandler(h Handler) SubscribeOption {
return func(o *SubscribeOptions) {
o.ErrorHandler = h
}
}
// Queue sets the name of the queue to share messages on
func Queue(name string) SubscribeOption {
// SubscribeGroup sets the name of the queue to share messages on
func SubscribeGroup(name string) SubscribeOption {
return func(o *SubscribeOptions) {
o.Queue = name
o.Group = name
}
}