(id proto.NodeID)
| 133 | } |
| 134 | |
| 135 | func (p *SessionPool) getSession(id proto.NodeID) (sess *Session, loaded bool) { |
| 136 | // NO Blocking operation in this function |
| 137 | p.Lock() |
| 138 | defer p.Unlock() |
| 139 | sess, exist := p.sessions[id] |
| 140 | if exist { |
| 141 | //log.WithField("node", id).Debug("load session for target node") |
| 142 | loaded = true |
| 143 | } else { |
| 144 | // new session |
| 145 | sess = &Session{ |
| 146 | target: id, |
| 147 | } |
| 148 | p.sessions[id] = sess |
| 149 | } |
| 150 | return |
| 151 | } |
| 152 | |
| 153 | // Get returns existing session to the node, if not exist try best to create one. |
| 154 | func (p *SessionPool) Get(id proto.NodeID) (conn rpc.Client, err error) { |
no outgoing calls