Initialise registry for broker
This commit is contained in:
@@ -3,6 +3,7 @@ package broker
|
||||
import (
|
||||
"crypto/tls"
|
||||
|
||||
"github.com/micro/go-micro/registry"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
@@ -41,6 +42,12 @@ type PublishOption func(*PublishOptions)
|
||||
|
||||
type SubscribeOption func(*SubscribeOptions)
|
||||
|
||||
type contextKeyT string
|
||||
|
||||
var (
|
||||
registryKey = contextKeyT("github.com/micro/go-micro/registry")
|
||||
)
|
||||
|
||||
func newSubscribeOptions(opts ...SubscribeOption) SubscribeOptions {
|
||||
opt := SubscribeOptions{
|
||||
AutoAck: true,
|
||||
@@ -68,6 +75,12 @@ func QueueName(name string) SubscribeOption {
|
||||
}
|
||||
}
|
||||
|
||||
func Registry(r registry.Registry) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = context.WithValue(o.Context, registryKey, r)
|
||||
}
|
||||
}
|
||||
|
||||
// Secure communication with the broker
|
||||
func Secure(b bool) Option {
|
||||
return func(o *Options) {
|
||||
|
Reference in New Issue
Block a user