feat: improve testing interface for the `router` crate
@@ -37,6 +37,23 @@ impl RouterServer {
remote_template: Option<RemoteTemplate>,
trace_collector: Option<Arc<dyn TraceCollector>>,
time_provider: Arc<dyn TimeProvider>,
+ ) -> Self {
+ Self::new_inner(remote_template, trace_collector, time_provider, false).await
+ }
+
+ pub async fn for_testing(
+ remote_template: Option<RemoteTemplate>,
+ trace_collector: Option<Arc<dyn TraceCollector>>,
+ time_provider: Arc<dyn TimeProvider>,
+ ) -> Self {
+ Self::new_inner(remote_template, trace_collector, time_provider, true).await
+ }
+
+ async fn new_inner(
+ remote_template: Option<RemoteTemplate>,
+ trace_collector: Option<Arc<dyn TraceCollector>>,
+ time_provider: Arc<dyn TimeProvider>,
+ use_mock_grpc: bool,
) -> Self {
let metric_registry = Arc::new(metric::Registry::new());
@@ -47,7 +64,8 @@ impl RouterServer {
routers: Default::default(),
resolver: Arc::new(Resolver::new(remote_template)),
connection_pool: Arc::new(
- ConnectionPool::new(false, WriteBufferConfigFactory::new(time_provider)).await,
+ ConnectionPool::new(use_mock_grpc, WriteBufferConfigFactory::new(time_provider))
+ .await,
),
}
}
@@ -123,6 +141,11 @@ impl RouterServer {
pub fn resolver(&self) -> &Arc<Resolver> {
&self.resolver
}
+
+ /// Connection pool associated with this server.
+ pub fn connection_pool(&self) -> &Arc<ConnectionPool> {
+ &self.connection_pool
+ }
}
pub mod test_utils {
