2222 *
2323 */
2424
25- use crate :: client:: {
26- load_balancing:: {
27- ChannelController , ExternalSubchannel , ForwardingSubchannel , LbState , Subchannel ,
28- WorkScheduler ,
29- } ,
30- name_resolution:: Address ,
25+ use crate :: client:: load_balancing:: {
26+ ChannelController , ExternalSubchannel , ForwardingSubchannel , LbState , Subchannel , WorkScheduler ,
3127} ;
28+ use crate :: client:: name_resolution:: Address ;
3229use crate :: service:: { Message , Request , Response , Service } ;
33- use std:: {
34- fmt:: Display ,
35- hash:: { Hash , Hasher } ,
36- ops:: Add ,
37- sync:: Arc ,
38- } ;
39- use tokio:: {
40- sync:: { mpsc, Notify } ,
41- task:: AbortHandle ,
42- } ;
30+ use std:: hash:: { Hash , Hasher } ;
31+ use std:: { fmt:: Display , ops:: Add , sync:: Arc } ;
32+ use tokio:: sync:: { mpsc, Notify } ;
33+ use tokio:: task:: AbortHandle ;
4334
4435pub ( crate ) struct EmptyMessage { }
4536impl Message for EmptyMessage { }
@@ -90,13 +81,13 @@ impl Hash for TestSubchannel {
9081
9182impl PartialEq for TestSubchannel {
9283 fn eq ( & self , other : & Self ) -> bool {
93- self . address == other. address
84+ std :: ptr :: eq ( self , other)
9485 }
9586}
9687impl Eq for TestSubchannel { }
9788
9889pub ( crate ) enum TestEvent {
99- NewSubchannel ( Address , Arc < dyn Subchannel > ) ,
90+ NewSubchannel ( Arc < dyn Subchannel > ) ,
10091 UpdatePicker ( LbState ) ,
10192 RequestResolution ,
10293 Connect ( Address ) ,
@@ -106,7 +97,7 @@ pub(crate) enum TestEvent {
10697impl Display for TestEvent {
10798 fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
10899 match self {
109- Self :: NewSubchannel ( addr , _ ) => write ! ( f, "NewSubchannel({})" , addr ) ,
100+ Self :: NewSubchannel ( sc ) => write ! ( f, "NewSubchannel({})" , sc . address ( ) ) ,
110101 Self :: UpdatePicker ( state) => write ! ( f, "UpdatePicker({})" , state. connectivity_state) ,
111102 Self :: RequestResolution => write ! ( f, "RequestResolution" ) ,
112103 Self :: Connect ( addr) => write ! ( f, "Connect({})" , addr. address. to_string( ) ) ,
@@ -115,11 +106,11 @@ impl Display for TestEvent {
115106 }
116107}
117108
118- // A test channel controller that forwards calls to a channel. This allows
119- // tests to verify when a channel controller is asked to create subchannels or
120- // update the picker.
109+ /// A test channel controller that forwards calls to a channel. This allows
110+ /// tests to verify when a channel controller is asked to create subchannels or
111+ /// update the picker.
121112pub ( crate ) struct TestChannelController {
122- pub tx_events : mpsc:: UnboundedSender < TestEvent > ,
113+ pub ( crate ) tx_events : mpsc:: UnboundedSender < TestEvent > ,
123114}
124115
125116impl ChannelController for TestChannelController {
@@ -129,10 +120,7 @@ impl ChannelController for TestChannelController {
129120 let subchannel: Arc < dyn Subchannel > =
130121 Arc :: new ( TestSubchannel :: new ( address. clone ( ) , self . tx_events . clone ( ) ) ) ;
131122 self . tx_events
132- . send ( TestEvent :: NewSubchannel (
133- address. clone ( ) ,
134- subchannel. clone ( ) ,
135- ) )
123+ . send ( TestEvent :: NewSubchannel ( subchannel. clone ( ) ) )
136124 . unwrap ( ) ;
137125 subchannel
138126 }
@@ -148,7 +136,7 @@ impl ChannelController for TestChannelController {
148136}
149137
150138pub ( crate ) struct TestWorkScheduler {
151- pub tx_events : mpsc:: UnboundedSender < TestEvent > ,
139+ pub ( crate ) tx_events : mpsc:: UnboundedSender < TestEvent > ,
152140}
153141
154142impl WorkScheduler for TestWorkScheduler {
0 commit comments