Skip to content

Commit 1a5f1e9

Browse files
committed
fix(rl): require worker metadata when enabled
Signed-off-by: Biswa Panda <biswa.panda@gmail.com>
1 parent 3e7eef8 commit 1a5f1e9

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

lib/backend-common/src/worker.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,18 +1014,34 @@ impl Worker {
10141014
let serve_fut = builder.start();
10151015
tokio::pin!(serve_fut);
10161016

1017-
let rl_endpoint = match (crate::rl::enabled(), self.config.rl_metadata.clone()) {
1018-
(true, Some(metadata)) => match crate::rl::serve_endpoint(&endpoint, metadata) {
1017+
let rl_endpoint = if crate::rl::enabled() {
1018+
let setup = self
1019+
.config
1020+
.rl_metadata
1021+
.clone()
1022+
.ok_or_else(|| {
1023+
err(
1024+
ErrorType::Backend(BackendError::InvalidArgument),
1025+
"DYN_ENABLE_RL requires worker RL metadata",
1026+
)
1027+
})
1028+
.and_then(|metadata| {
1029+
crate::rl::serve_endpoint(&endpoint, metadata).map_err(|error| {
1030+
err(
1031+
ErrorType::Backend(BackendError::Unknown),
1032+
format!("RL endpoint setup: {error}"),
1033+
)
1034+
})
1035+
});
1036+
match setup {
10191037
Ok(endpoint) => Some(endpoint),
10201038
Err(error) => {
10211039
self.orchestrator_steps(&endpoint).await;
1022-
return Err(err(
1023-
ErrorType::Backend(BackendError::Unknown),
1024-
format!("RL endpoint setup: {error}"),
1025-
));
1040+
return Err(error);
10261041
}
1027-
},
1028-
_ => None,
1042+
}
1043+
} else {
1044+
None
10291045
};
10301046
let rl_endpoint_handle = rl_endpoint.as_ref().map(|rl| rl.endpoint.clone());
10311047
let rl_serve = async move {

0 commit comments

Comments
 (0)