Skip to content

Commit 54df3e1

Browse files
committed
Moved UriForest into swimos_introspection.
1 parent 6b8419f commit 54df3e1

File tree

13 files changed

+25
-55
lines changed

13 files changed

+25
-55
lines changed

server/swimos_introspection/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66

77
[dependencies]
88
futures = { workspace = true }
9-
swimos_utilities = { path = "../../swimos_utilities", features = ["io", "trigger", "text", "uri_forest", "encoding"] }
9+
swimos_utilities = { path = "../../swimos_utilities", features = ["io", "trigger", "text", "encoding"] }
1010
swimos_runtime = { path = "../../runtime/swimos_runtime" }
1111
bytes = { workspace = true }
1212
tokio = { workspace = true, features = ["sync", "time"] }
@@ -23,6 +23,8 @@ uuid = { workspace = true }
2323
thiserror = { workspace = true }
2424
parking_lot = { workspace = true, features = ["send_guard"] }
2525
once_cell = "1.17.1"
26+
static_assertions = { workspace = true }
27+
smol_str = "0.2.0"
2628

2729
[dev-dependencies]
2830
tokio = { workspace = true, features = ["rt", "macros", "time", "test-util"] }

swimos_utilities/swimos_uri_forest/src/forest/mod.rs renamed to server/swimos_introspection/src/forest/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
pub mod iter;
15+
mod iter;
1616
#[cfg(test)]
1717
mod tests;
1818

@@ -21,7 +21,7 @@ use std::collections::HashMap;
2121
use std::fmt::Debug;
2222
use std::iter::Peekable;
2323

24-
use self::iter::{PathSegmentIterator, UriForestIterator, UriPartIterator};
24+
pub use self::iter::{PathSegmentIterator, UriForestIterator, UriPart, UriPartIterator};
2525

2626
static_assertions::assert_impl_all!(UriForest<()>: Send, Sync);
2727

swimos_utilities/swimos_uri_forest/src/forest/tests.rs renamed to server/swimos_introspection/src/forest/tests.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@
1414

1515
use std::collections::{HashMap, HashSet};
1616

17-
use crate::{
18-
forest::{
19-
iter::{PathSegmentIterator, UriPart},
20-
TreeNode,
21-
},
22-
UriForest,
17+
use crate::forest::{
18+
iter::{PathSegmentIterator, UriPart},
19+
TreeNode, UriForest,
2320
};
2421

2522
#[test]

server/swimos_introspection/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
// limitations under the License.
1414

1515
mod config;
16+
mod forest;
1617
mod meta_agent;
1718
mod meta_mesh;
1819
mod model;

server/swimos_introspection/src/meta_mesh/mod.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515
#[cfg(test)]
1616
mod tests;
1717

18-
use crate::task::AgentMeta;
18+
use crate::{
19+
forest::{UriForest, UriPart},
20+
task::AgentMeta,
21+
};
1922
use futures::future::{BoxFuture, Either};
2023
use futures::stream::select;
2124
use futures::{FutureExt, SinkExt, StreamExt, TryFutureExt};
@@ -33,7 +36,6 @@ use swimos_model::Text;
3336
use swimos_runtime::downlink::Io;
3437
use swimos_utilities::routing::RouteUri;
3538
use swimos_utilities::trigger;
36-
use swimos_utilities::uri_forest::{UriForest, UriPart};
3739
use tokio_util::codec::{FramedRead, FramedWrite};
3840

3941
pub struct MetaMeshAgent {

server/swimos_introspection/src/meta_mesh/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use crate::forest::UriForest;
1516
use crate::meta_mesh::{run_task, NodeInfo, NodeInfoCount, NodeInfoList};
1617
use crate::model::AgentIntrospectionUpdater;
1718
use crate::task::AgentMeta;
@@ -33,7 +34,6 @@ use swimos_form::read::RecognizerReadable;
3334
use swimos_model::{Text, Timestamp};
3435
use swimos_runtime::agent::reporting::UplinkReporter;
3536
use swimos_utilities::io::byte_channel::{byte_channel, ByteReader, ByteWriter};
36-
use swimos_utilities::uri_forest::UriForest;
3737
use swimos_utilities::{non_zero_usize, trigger};
3838
use tokio_util::codec::{FramedRead, FramedWrite};
3939
use uuid::Uuid;

server/swimos_introspection/src/task/mod.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
use crate::forest::UriForest;
1516
use std::sync::Arc;
1617
use std::{collections::HashMap, num::NonZeroUsize};
1718

@@ -25,14 +26,14 @@ use swimos_runtime::agent::{
2526
reporting::{UplinkReportReader, UplinkReporter},
2627
NodeReporting, UplinkReporterRegistration,
2728
};
28-
use swimos_utilities::uri_forest::UriForest;
2929
use swimos_utilities::{routing::RouteUri, trigger};
3030
use tokio::sync::{mpsc, oneshot};
3131
use tokio_stream::wrappers::{ReceiverStream, UnboundedReceiverStream};
3232
use tracing::info;
3333
use uuid::Uuid;
3434

3535
use crate::model::{AgentIntrospectionHandle, AgentIntrospectionUpdater, LaneView};
36+
use crate::MetaMeshAgent;
3637

3738
/// Requests that can be made by to the introspection task.
3839
pub enum IntrospectionMessage {
@@ -96,16 +97,18 @@ impl From<UplinkReporterRegistration> for IntrospectionMessage {
9697
pub fn init_introspection(
9798
stopping: trigger::Receiver,
9899
channel_size: NonZeroUsize,
99-
agents: Arc<RwLock<UriForest<AgentMeta>>>,
100100
) -> (
101101
IntrospectionResolver,
102+
MetaMeshAgent,
102103
impl Future<Output = ()> + Send + 'static,
103104
) {
105+
let agents = Arc::new(RwLock::new(UriForest::new()));
104106
let (msg_tx, msg_rx) = mpsc::unbounded_channel();
105107
let (reg_tx, reg_rx) = mpsc::channel(channel_size.get());
106-
let task = introspection_task(stopping, msg_rx, reg_rx, agents);
108+
let task = introspection_task(stopping, msg_rx, reg_rx, agents.clone());
109+
let meta_agent = MetaMeshAgent::new(agents);
107110
let resolver = IntrospectionResolver::new(msg_tx, reg_tx);
108-
(resolver, task)
111+
(resolver, meta_agent, task)
109112
}
110113

111114
#[derive(Debug)]

server/swimos_server_app/src/server/runtime/mod.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
use futures::future::{join, Either};
1616
use futures::stream::{unfold, FuturesUnordered};
1717
use futures::{FutureExt, Stream, StreamExt};
18-
use parking_lot::RwLock;
1918
use ratchet::{ExtensionProvider, SplittableExtension, WebSocket, WebSocketStream};
2019
use std::collections::hash_map::Entry;
2120
use std::collections::HashMap;
@@ -32,7 +31,7 @@ use swimos_api::error::{
3231
};
3332
use swimos_api::{address::RelativeAddress, persistence::PlanePersistence};
3433
use swimos_introspection::route::{lane_pattern, mesh_pattern, node_pattern};
35-
use swimos_introspection::{init_introspection, IntrospectionResolver, MetaMeshAgent};
34+
use swimos_introspection::{init_introspection, IntrospectionResolver};
3635
use swimos_introspection::{IntrospectionConfig, LaneMetaAgent, NodeMetaAgent};
3736
use swimos_model::Text;
3837
use swimos_net::{BadUrl, Scheme};
@@ -52,7 +51,6 @@ use swimos_remote::ws::{RatchetError, Websockets};
5251
use swimos_utilities::io::byte_channel::{byte_channel, BudgetedFutureExt, ByteReader, ByteWriter};
5352
use swimos_utilities::routing::RoutePattern;
5453
use swimos_utilities::trigger::{self, promise};
55-
use swimos_utilities::uri_forest::UriForest;
5654
use thiserror::Error;
5755
use tokio::sync::{mpsc, oneshot};
5856
use tokio::task::JoinError;
@@ -1241,10 +1239,8 @@ fn start_introspection(
12411239
stopping: trigger::Receiver,
12421240
routes: &mut Routes,
12431241
) -> IntrospectionResolver {
1244-
let agents = Arc::new(RwLock::new(UriForest::new()));
1245-
let (resolver, task) =
1246-
init_introspection(stopping, config.registration_channel_size, agents.clone());
1247-
let mesh_meta = MetaMeshAgent::new(agents);
1242+
let (resolver, mesh_meta, task) =
1243+
init_introspection(stopping, config.registration_channel_size);
12481244
let node_meta = NodeMetaAgent::new(config, resolver.clone());
12491245
let lane_meta = LaneMetaAgent::new(config, resolver.clone());
12501246

swimos_utilities/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ edition = "2021"
66

77
[features]
88
default = []
9-
all = ["future", "errors", "sync", "collections", "time", "text", "rtree", "buf_channel", "algebra", "multi_reader", "uri_forest", "encoding"]
9+
all = ["future", "errors", "sync", "collections", "time", "text", "rtree", "buf_channel", "algebra", "multi_reader", "encoding"]
1010
algebra = ["swimos_algebra"]
1111
buf_channel = ["swimos_byte_channel"]
1212
multi_reader = ["swimos_multi_reader"]
@@ -19,7 +19,6 @@ sync = ["future", "trigger", "swimos_sync"]
1919
text = ["swimos_route", "swimos_format"]
2020
time = ["swimos_time"]
2121
trigger = ["swimos_trigger"]
22-
uri_forest = ["swimos_uri_forest"]
2322
encoding = ["swimos_encoding"]
2423

2524
[dependencies]
@@ -37,5 +36,4 @@ swimos_rtree = { path = "./swimos_rtree", optional = true }
3736
swimos_sync = { path = "./swimos_sync", optional = true }
3837
swimos_time = { path = "./swimos_time", optional = true }
3938
swimos_encoding = { path = "./swimos_encoding", optional = true }
40-
swimos_uri_forest = { path = "./swimos_uri_forest", optional = true }
4139

0 commit comments

Comments
 (0)