1+ use crate :: { Recognize , Router } ;
12use futures:: Poll ;
2- use http;
33use linkerd2_error:: { Error , Never } ;
4- use linkerd2_router as rt;
5- pub use linkerd2_router:: { error, Recognize , Router } ;
64use std:: marker:: PhantomData ;
75use std:: time:: Duration ;
86use tracing:: { info_span, trace} ;
@@ -27,7 +25,7 @@ pub struct Layer<Req, Rec: Recognize<Req>> {
2725}
2826
2927#[ derive( Debug ) ]
30- pub struct Stack < Req , Rec : Recognize < Req > , Mk > {
28+ pub struct Make < Req , Rec : Recognize < Req > , Mk > {
3129 config : Config ,
3230 recognize : Rec ,
3331 inner : Mk ,
@@ -37,7 +35,7 @@ pub struct Stack<Req, Rec: Recognize<Req>, Mk> {
3735pub struct Service < Req , Rec , Mk >
3836where
3937 Rec : Recognize < Req > ,
40- Mk : rt :: Make < Rec :: Target > ,
38+ Mk : super :: Make < Rec :: Target > ,
4139 Mk :: Value : tower:: Service < Req > ,
4240{
4341 inner : Router < Req , Rec , Mk > ,
@@ -56,29 +54,30 @@ impl Config {
5654
5755// === impl Layer ===
5856
59- pub fn layer < Rec , Req > ( config : Config , recognize : Rec ) - > Layer < Req , Rec >
57+ impl < Req , Rec > Layer < Req , Rec >
6058where
6159 Rec : Recognize < Req > + Clone + Send + Sync + ' static ,
6260{
63- Layer {
64- config,
65- recognize,
66- _p : PhantomData ,
61+ pub fn new ( config : Config , recognize : Rec ) -> Self {
62+ Self {
63+ config,
64+ recognize,
65+ _p : PhantomData ,
66+ }
6767 }
6868}
6969
70- impl < Req , Rec , Mk , B > tower:: layer:: Layer < Mk > for Layer < Req , Rec >
70+ impl < Req , Rec , Mk > tower:: layer:: Layer < Mk > for Layer < Req , Rec >
7171where
7272 Rec : Recognize < Req > + Clone + Send + Sync + ' static ,
73- Mk : rt :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
74- Mk :: Value : tower:: Service < Req , Response = http :: Response < B > > + Clone ,
73+ Mk : super :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
74+ Mk :: Value : tower:: Service < Req > + Clone ,
7575 <Mk :: Value as tower:: Service < Req > >:: Error : Into < Error > ,
76- B : Default + Send + ' static ,
7776{
78- type Service = Stack < Req , Rec , Mk > ;
77+ type Service = Make < Req , Rec , Mk > ;
7978
8079 fn layer ( & self , inner : Mk ) -> Self :: Service {
81- Stack {
80+ Make {
8281 inner,
8382 config : self . config . clone ( ) ,
8483 recognize : self . recognize . clone ( ) ,
@@ -92,19 +91,18 @@ where
9291 Rec : Recognize < Req > + Clone + Send + Sync + ' static ,
9392{
9493 fn clone ( & self ) -> Self {
95- layer ( self . config . clone ( ) , self . recognize . clone ( ) )
94+ Self :: new ( self . config . clone ( ) , self . recognize . clone ( ) )
9695 }
9796}
98- // === impl Stack ===
97+ // === impl Make ===
9998
100- impl < Req , Rec , Mk , B > Stack < Req , Rec , Mk >
99+ impl < Req , Rec , Mk > Make < Req , Rec , Mk >
101100where
102101 Rec : Recognize < Req > + Clone + Send + Sync + ' static ,
103102 <Rec as Recognize < Req > >:: Target : Send + ' static ,
104- Mk : rt :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
105- Mk :: Value : tower:: Service < Req , Response = http :: Response < B > > + Clone + Send + ' static ,
103+ Mk : super :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
104+ Mk :: Value : tower:: Service < Req > + Clone + Send + ' static ,
106105 <Mk :: Value as tower:: Service < Req > >:: Error : Into < Error > ,
107- B : Default + Send + ' static ,
108106{
109107 pub fn make ( & self ) -> Service < Req , Rec , Mk > {
110108 let ( inner, cache_bg) = Router :: new (
@@ -118,14 +116,13 @@ where
118116 }
119117}
120118
121- impl < Req , Rec , Mk , B , T > tower:: Service < T > for Stack < Req , Rec , Mk >
119+ impl < Req , Rec , Mk , T > tower:: Service < T > for Make < Req , Rec , Mk >
122120where
123121 Rec : Recognize < Req > + Clone + Send + Sync + ' static ,
124122 <Rec as Recognize < Req > >:: Target : Send + ' static ,
125- Mk : rt :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
126- Mk :: Value : tower:: Service < Req , Response = http :: Response < B > > + Clone + Send + ' static ,
123+ Mk : super :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
124+ Mk :: Value : tower:: Service < Req > + Clone + Send + ' static ,
127125 <Mk :: Value as tower:: Service < Req > >:: Error : Into < Error > ,
128- B : Default + Send + ' static ,
129126{
130127 type Response = Service < Req , Rec , Mk > ;
131128 type Error = Never ;
@@ -140,7 +137,7 @@ where
140137 }
141138}
142139
143- impl < Req , Rec , Mk > Clone for Stack < Req , Rec , Mk >
140+ impl < Req , Rec , Mk > Clone for Make < Req , Rec , Mk >
144141where
145142 Rec : Recognize < Req > + Clone ,
146143 Mk : Clone ,
@@ -156,13 +153,12 @@ where
156153}
157154// === impl Service ===
158155
159- impl < Req , Rec , Mk , B > tower:: Service < Req > for Service < Req , Rec , Mk >
156+ impl < Req , Rec , Mk > tower:: Service < Req > for Service < Req , Rec , Mk >
160157where
161158 Rec : Recognize < Req > + Send + Sync + ' static ,
162- Mk : rt :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
163- Mk :: Value : tower:: Service < Req , Response = http :: Response < B > > + Clone ,
159+ Mk : super :: Make < Rec :: Target > + Clone + Send + Sync + ' static ,
160+ Mk :: Value : tower:: Service < Req > + Clone ,
164161 <Mk :: Value as tower:: Service < Req > >:: Error : Into < Error > ,
165- B : Default + Send + ' static ,
166162{
167163 type Response = <Router < Req , Rec , Mk > as tower:: Service < Req > >:: Response ;
168164 type Error = <Router < Req , Rec , Mk > as tower:: Service < Req > >:: Error ;
@@ -181,7 +177,7 @@ where
181177impl < Req , Rec , Mk > Clone for Service < Req , Rec , Mk >
182178where
183179 Rec : Recognize < Req > ,
184- Mk : rt :: Make < Rec :: Target > ,
180+ Mk : super :: Make < Rec :: Target > ,
185181 Mk :: Value : tower:: Service < Req > ,
186182 Router < Req , Rec , Mk > : Clone ,
187183{
0 commit comments