Add extra options to be used by others that need them

This commit is contained in:
Asim 2015-12-31 18:14:40 +00:00
parent 64b45f7846
commit 191e835aa9
5 changed files with 26 additions and 5 deletions

View File

@ -6,7 +6,10 @@ type Options struct {
Options map[string]string Options map[string]string
} }
type PublishOptions struct{} type PublishOptions struct {
// Other options to be used by broker implementations
Options map[string]string
}
type SubscribeOptions struct { type SubscribeOptions struct {
// AutoAck defaults to true. When a handler returns // AutoAck defaults to true. When a handler returns
@ -16,6 +19,9 @@ type SubscribeOptions struct {
// will create a shared subscription where each // will create a shared subscription where each
// receives a subset of messages. // receives a subset of messages.
Queue string Queue string
// Other options to be used by broker implementations
Options map[string]string
} }
type Option func(*Options) type Option func(*Options)

View File

@ -6,6 +6,9 @@ import (
type Options struct { type Options struct {
Timeout time.Duration Timeout time.Duration
// Other options to be used by registry implementations
Options map[string]string
} }
func Timeout(t time.Duration) Option { func Timeout(t time.Duration) Option {

View File

@ -6,10 +6,16 @@ import (
type Options struct { type Options struct {
Registry registry.Registry Registry registry.Registry
// Other options to be used by broker implementations
Options map[string]string
} }
type SelectOptions struct { type SelectOptions struct {
Filters []SelectFilter Filters []SelectFilter
// Other options to be used by broker implementations
Options map[string]string
} }
// Option used to initialise the selector // Option used to initialise the selector

View File

@ -87,7 +87,7 @@ func (h *httpTransportClient) Send(m *Message) error {
func (h *httpTransportClient) Recv(m *Message) error { func (h *httpTransportClient) Recv(m *Message) error {
var r *http.Request var r *http.Request
if !h.dialOpts.stream { if !h.dialOpts.Stream {
rc, ok := <-h.r rc, ok := <-h.r
if !ok { if !ok {
return io.EOF return io.EOF

View File

@ -29,10 +29,16 @@ type Transport interface {
String() string String() string
} }
type Options struct{} type Options struct {
// Other options to be used by broker implementations
Options map[string]string
}
type DialOptions struct { type DialOptions struct {
stream bool Stream bool
// Other options to be used by broker implementations
Options map[string]string
} }
type Option func(*Options) type Option func(*Options)
@ -45,7 +51,7 @@ var (
func WithStream() DialOption { func WithStream() DialOption {
return func(o *DialOptions) { return func(o *DialOptions) {
o.stream = true o.Stream = true
} }
} }