Skip to content

Commit

Permalink
Re-added initTransports for transport.Manager
Browse files Browse the repository at this point in the history
This was removed for some reason, but it needs to exist in order to reestablish transports on visor restart.
  • Loading branch information
Evan Lin committed Sep 8, 2019
1 parent 461838e commit 6439c70
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions pkg/transport/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ func (tm *Manager) serve(ctx context.Context) {
}
}()
}

tm.initTransports(ctx)
tm.Logger.Info("transport manager is serving.")

// closing logic
Expand All @@ -116,6 +118,26 @@ func (tm *Manager) serve(ctx context.Context) {
}
}

func (tm *Manager) initTransports(ctx context.Context) {
tm.mx.Lock()
defer tm.mx.Unlock()

entries, err := tm.conf.DiscoveryClient.GetTransportsByEdge(ctx, tm.conf.PubKey)
if err != nil {
log.Warnf("No transports found for local node: %v", err)
}
for _, entry := range entries {
var (
tpType = entry.Entry.Type
remote = entry.Entry.RemoteEdge(tm.conf.PubKey)
tpID = entry.Entry.ID
)
if _, err := tm.saveTransport(remote, tpType); err != nil {
tm.Logger.Warnf("INIT: failed to init tp: type(%s) remote(%s) tpID(%s)", tpType, remote, tpID)
}
}
}

func (tm *Manager) acceptTransport(ctx context.Context, lis *snet.Listener) error {
conn, err := lis.AcceptConn() // TODO: tcp panic.
if err != nil {
Expand Down

0 comments on commit 6439c70

Please sign in to comment.