fix: initialize broker and subscribers

This commit is contained in:
武新飞 2018-12-19 17:53:34 +08:00 committed by Vasiliy Tolstov
parent 921f832670
commit 7968395d51
2 changed files with 6 additions and 0 deletions

View File

@ -238,6 +238,7 @@ func newServer(opts ...server.Option) server.Server {
return &httpServer{ return &httpServer{
opts: newOptions(opts...), opts: newOptions(opts...),
exit: make(chan chan error), exit: make(chan chan error),
subscribers: make(map[*httpSubscriber][]broker.Subscriber),
} }
} }

View File

@ -3,6 +3,7 @@ package http
import ( import (
"context" "context"
"github.com/micro/go-micro/broker"
"github.com/micro/go-micro/codec" "github.com/micro/go-micro/codec"
"github.com/micro/go-micro/registry" "github.com/micro/go-micro/registry"
"github.com/micro/go-micro/server" "github.com/micro/go-micro/server"
@ -19,6 +20,10 @@ func newOptions(opt ...server.Option) server.Options {
o(&opts) o(&opts)
} }
if opts.Broker == nil {
opts.Broker = broker.DefaultBroker
}
if opts.Registry == nil { if opts.Registry == nil {
opts.Registry = registry.DefaultRegistry opts.Registry = registry.DefaultRegistry
} }