@@ -69,11 +69,15 @@ struct Rescue;
69
69
// === impl Config ===
70
70
71
71
impl Config {
72
+ /// Builds the admin endpoint server.
73
+ ///
74
+ /// This method is asynchronous, as it must discover a `ServerPolicy` for
75
+ /// the admin port.
72
76
#[ allow( clippy:: too_many_arguments) ]
73
- pub fn build < B , R , P > (
77
+ pub async fn build < B , R , P > (
74
78
self ,
75
79
bind : B ,
76
- policy : P ,
80
+ policy : & P ,
77
81
identity : identity:: Server ,
78
82
report : R ,
79
83
metrics : inbound:: Metrics ,
@@ -91,16 +95,11 @@ impl Config {
91
95
let ( listen_addr, listen) = bind. bind ( & self . server ) ?;
92
96
93
97
let ( ready, latch) = crate :: server:: Readiness :: new ( ) ;
94
- let serve = Box :: pin ( async move {
95
- // Get the policy for the admin server.
96
- // TODO(eliza): don't expect this...
97
- let policy = policy
98
- . get_policy ( OrigDstAddr ( listen_addr. into ( ) ) )
99
- . await
100
- . expect ( "must be able to get policy for admin server" ) ;
101
-
102
- let admin = crate :: server:: Admin :: new ( report, ready, shutdown, trace) ;
103
- let admin = svc:: stack ( move |_| admin. clone ( ) )
98
+ // Get the policy for the admin server.
99
+ let policy = policy. get_policy ( OrigDstAddr ( listen_addr. into ( ) ) ) . await ?;
100
+
101
+ let admin = crate :: server:: Admin :: new ( report, ready, shutdown, trace) ;
102
+ let admin = svc:: stack ( move |_| admin. clone ( ) )
104
103
. push ( metrics. proxy . http_endpoint . to_layer :: < classify:: Response , _ , Permitted > ( ) )
105
104
. push_map_target ( |( permit, http) | Permitted { permit, http } )
106
105
. push ( inbound:: policy:: NewHttpPolicy :: layer ( metrics. http_authz . clone ( ) ) )
@@ -164,8 +163,7 @@ impl Config {
164
163
identity,
165
164
} ) )
166
165
. into_inner ( ) ;
167
- serve:: serve ( listen, admin, drain. signaled ( ) ) . await
168
- } ) ;
166
+ let serve = Box :: pin ( serve:: serve ( listen, admin, drain. signaled ( ) ) ) ;
169
167
Ok ( Task {
170
168
listen_addr,
171
169
latch,
0 commit comments