|
|
@@ -66,6 +66,9 @@ type Peer interface {
|
|
|
// connection hands over to the peer. The peer will close the connection
|
|
|
// when it is no longer used.
|
|
|
attachOutgoingConn(conn *outgoingConn)
|
|
|
+ // activeSince returns the time that the connection with the
|
|
|
+ // peer becomes active.
|
|
|
+ activeSince() time.Time
|
|
|
// Stop performs any necessary finalization and terminates the peer
|
|
|
// elegantly.
|
|
|
Stop()
|
|
|
@@ -87,6 +90,8 @@ type peer struct {
|
|
|
id types.ID
|
|
|
r Raft
|
|
|
|
|
|
+ status *peerStatus
|
|
|
+
|
|
|
msgAppWriter *streamWriter
|
|
|
writer *streamWriter
|
|
|
pipeline *pipeline
|
|
|
@@ -112,6 +117,7 @@ func startPeer(tr http.RoundTripper, urls types.URLs, local, to, cid types.ID, r
|
|
|
p := &peer{
|
|
|
id: to,
|
|
|
r: r,
|
|
|
+ status: status,
|
|
|
msgAppWriter: startStreamWriter(to, status, fs, r),
|
|
|
writer: startStreamWriter(to, status, fs, r),
|
|
|
pipeline: newPipeline(tr, picker, local, to, cid, status, fs, r, errorc),
|
|
|
@@ -223,6 +229,8 @@ func (p *peer) attachOutgoingConn(conn *outgoingConn) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func (p *peer) activeSince() time.Time { return p.status.activeSince }
|
|
|
+
|
|
|
// Pause pauses the peer. The peer will simply drops all incoming
|
|
|
// messages without retruning an error.
|
|
|
func (p *peer) Pause() {
|