summaryrefslogtreecommitdiffstats
path: root/src/endpoint/util.rs
diff options
context:
space:
mode:
authorMatthias Beyer <matthias.beyer@atos.net>2021-03-05 13:20:12 +0100
committerMatthias Beyer <matthias.beyer@atos.net>2021-03-05 13:20:13 +0100
commitb818f01f5408c37d1a889b1ad61529321257f56a (patch)
treedb23499d1ee5cad428b60049edb1c87e583c6076 /src/endpoint/util.rs
parent60a3fa633a33e315c1439a9f2436fcdb48da62ae (diff)
Move endpoint connection setup to utility module
Because we can re-use this function in our commandline endpoint maintenance commands implementation. Signed-off-by: Matthias Beyer <matthias.beyer@atos.net>
Diffstat (limited to 'src/endpoint/util.rs')
-rw-r--r--src/endpoint/util.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/endpoint/util.rs b/src/endpoint/util.rs
new file mode 100644
index 0000000..5f6bbc8
--- /dev/null
+++ b/src/endpoint/util.rs
@@ -0,0 +1,30 @@
+//
+// Copyright (c) 2020-2021 science+computing ag and other contributors
+//
+// This program and the accompanying materials are made
+// available under the terms of the Eclipse Public License 2.0
+// which is available at https://www.eclipse.org/legal/epl-2.0/
+//
+// SPDX-License-Identifier: EPL-2.0
+//
+
+use std::sync::Arc;
+
+use anyhow::Result;
+use futures::FutureExt;
+use tokio_stream::StreamExt;
+
+use crate::endpoint::Endpoint;
+use crate::endpoint::EndpointConfiguration;
+
+pub async fn setup_endpoints(endpoints: Vec<EndpointConfiguration>) -> Result<Vec<Arc<Endpoint>>> {
+ let unordered = futures::stream::FuturesUnordered::new();
+
+ for cfg in endpoints.into_iter() {
+ unordered
+ .push(Endpoint::setup(cfg).map(|r_ep| r_ep.map(Arc::new)));
+ }
+
+ unordered.collect().await
+}
+