@@ -55,6 +55,9 @@ type ChannelOptions struct {
5555 // The name of the process, for logging and reporting to peers
5656 ProcessName string
5757
58+ // OnPeerStatusChanged
59+ OnPeerStatusChanged func (* Peer )
60+
5861 // The logger to use for this channel
5962 Logger Logger
6063
@@ -363,18 +366,18 @@ func (ch *Channel) Peers() *PeerList {
363366 return ch .peers
364367}
365368
366- // rootPeers returns the root PeerList for the channel, which is the sole place
369+ // RootPeers returns the root PeerList for the channel, which is the sole place
367370// new Peers are created. All children of the root list (including ch.Peers())
368371// automatically re-use peers from the root list and create new peers in the
369372// root list.
370- func (ch * Channel ) rootPeers () * RootPeerList {
373+ func (ch * Channel ) RootPeers () * RootPeerList {
371374 return ch .peers .parent
372375}
373376
374377// BeginCall starts a new call to a remote peer, returning an OutboundCall that can
375378// be used to write the arguments of the call.
376379func (ch * Channel ) BeginCall (ctx context.Context , hostPort , serviceName , methodName string , callOptions * CallOptions ) (* OutboundCall , error ) {
377- p := ch .rootPeers ().GetOrAdd (hostPort )
380+ p := ch .RootPeers ().GetOrAdd (hostPort )
378381 return p .BeginCall (ctx , serviceName , methodName , callOptions )
379382}
380383
@@ -431,7 +434,7 @@ func (ch *Channel) serve() {
431434
432435// Ping sends a ping message to the given hostPort and waits for a response.
433436func (ch * Channel ) Ping (ctx context.Context , hostPort string ) error {
434- peer := ch .rootPeers ().GetOrAdd (hostPort )
437+ peer := ch .RootPeers ().GetOrAdd (hostPort )
435438 conn , err := peer .GetConnection (ctx )
436439 if err != nil {
437440 return err
@@ -524,7 +527,7 @@ func (ch *Channel) exchangeUpdated(c *Connection) {
524527 return
525528 }
526529
527- p , ok := ch .rootPeers ().Get (c .remotePeerInfo .HostPort )
530+ p , ok := ch .RootPeers ().Get (c .remotePeerInfo .HostPort )
528531 if ! ok {
529532 return
530533 }
@@ -575,7 +578,7 @@ func (ch *Channel) connectionActive(c *Connection, direction connectionDirection
575578}
576579
577580func (ch * Channel ) addConnectionToPeer (hostPort string , c * Connection , direction connectionDirection ) {
578- p := ch .rootPeers ().GetOrAdd (hostPort )
581+ p := ch .RootPeers ().GetOrAdd (hostPort )
579582 if err := p .addConnection (c , direction ); err != nil {
580583 c .log .WithFields (
581584 LogField {"remoteHostPort" , c .remotePeerInfo .HostPort },
@@ -620,13 +623,13 @@ func (ch *Channel) getMinConnectionState() connectionState {
620623// connectionCloseStateChange is called when a connection's close state changes.
621624func (ch * Channel ) connectionCloseStateChange (c * Connection ) {
622625 ch .removeClosedConn (c )
623- if peer , ok := ch .rootPeers ().Get (c .remotePeerInfo .HostPort ); ok {
626+ if peer , ok := ch .RootPeers ().Get (c .remotePeerInfo .HostPort ); ok {
624627 peer .connectionCloseStateChange (c )
625628 ch .updatePeer (peer )
626629 }
627630 if c .outboundHP != "" && c .outboundHP != c .remotePeerInfo .HostPort {
628631 // Outbound connections may be in multiple peers.
629- if peer , ok := ch .rootPeers ().Get (c .outboundHP ); ok {
632+ if peer , ok := ch .RootPeers ().Get (c .outboundHP ); ok {
630633 peer .connectionCloseStateChange (c )
631634 ch .updatePeer (peer )
632635 }
0 commit comments