Skip to content

Commit

Permalink
Manager.Observe eliminated. All tests passed
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuryshev committed May 23, 2019
1 parent 367dadc commit 46dc47c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 24 deletions.
2 changes: 0 additions & 2 deletions pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ func New(config *Config) *Router {

// Serve starts transport listening loop.
func (r *Router) Serve(ctx context.Context) error {
// acceptCh, dialCh := r.tm.Observe()

go func() {
for tr := range r.tm.AcceptedTrChan {
go func(t transport.Transport) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/setup/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,8 @@ func (sn *Node) Serve(ctx context.Context) error {
sn.Logger.Info("Connected to messaging servers")
}

acceptCh, dialCh := sn.tm.Observe()
go func() {
for tr := range acceptCh {
for tr := range sn.tm.AcceptedTrChan {
go func(t transport.Transport) {
for {
if err := sn.serveTransport(t); err != nil {
Expand All @@ -105,7 +104,7 @@ func (sn *Node) Serve(ctx context.Context) error {
}()

go func() {
for range dialCh {
for range sn.tm.DialedTrChan {
}
}()

Expand Down
5 changes: 2 additions & 3 deletions pkg/setup/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,14 @@ func newMockNode(tm *transport.Manager) *mockNode {
}

func (n *mockNode) serve() error {
acceptCh, dialCh := n.tm.Observe()
go func() {
for tr := range dialCh {
for tr := range n.tm.DialedTrChan {
go func(t transport.Transport) { n.serveTransport(t) }(tr) // nolint: errcheck
}
}()

go func() {
for tr := range acceptCh {
for tr := range n.tm.AcceptedTrChan {
go func(t transport.Transport) { n.serveTransport(t) }(tr) // nolint: errcheck
}
}()
Expand Down
16 changes: 0 additions & 16 deletions pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,6 @@ func NewManager(config *ManagerConfig, factories ...Factory) (*Manager, error) {
// Observe returns channel for notifications about new Transport
// registration. Only single observer is supported.
func (tm *Manager) Observe() (accept <-chan *ManagedTransport, dial <-chan *ManagedTransport) {
// dialCh := make(chan *ManagedTransport)
// acceptCh := make(chan *ManagedTransport)
// go func() {
// for {
// select {
// case <-tm.doneChan:
// // close(dialCh)
// // close(acceptCh)
// return
// case tr := <-tm.acceptedTrChan:
// acceptCh <- tr
// case tr := <-tm.dialedTrChan:
// dialCh <- tr
// }
// }
// }()
return tm.AcceptedTrChan, tm.DialedTrChan
}

Expand Down

0 comments on commit 46dc47c

Please sign in to comment.