chore: expose some methods (#5784)

This commit is contained in:
fys
2025-03-27 17:00:51 +08:00
committed by GitHub
parent 2b4ed43692
commit 898e0bd828
3 changed files with 20 additions and 0 deletions

View File

@@ -61,6 +61,14 @@ impl Instance {
pub fn new(frontend: Frontend, _guard: Vec<WorkerGuard>) -> Self {
Self { frontend, _guard }
}
pub fn inner(&self) -> &Frontend {
&self.frontend
}
pub fn mut_inner(&mut self) -> &mut Frontend {
&mut self.frontend
}
}
#[async_trait]

View File

@@ -12,6 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use std::net::SocketAddr;
use std::sync::Arc;
use std::{fs, path};
@@ -254,6 +255,13 @@ pub struct Instance {
_guard: Vec<WorkerGuard>,
}
impl Instance {
/// Find the socket addr of a server by its `name`.
pub async fn server_addr(&self, name: &str) -> Option<SocketAddr> {
self.frontend.server_handlers().addr(name).await
}
}
#[async_trait]
impl App for Instance {
fn name(&self) -> &str {

View File

@@ -131,6 +131,10 @@ impl Frontend {
.await
.context(error::ShutdownServerSnafu)
}
pub fn server_handlers(&self) -> &ServerHandlers {
&self.servers
}
}
#[cfg(test)]