Skip to content

Commit 7c8cca7

Browse files
Merge branch 'main' into docs9
2 parents 07707e0 + c2e5776 commit 7c8cca7

File tree

37 files changed

+485
-175
lines changed

37 files changed

+485
-175
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ members = [
3939
"example_apps/join_map",
4040
"example_apps/join_value",
4141
"example_apps/aggregations",
42+
"example_apps/time_series",
4243
]
4344

4445
exclude = [
@@ -93,7 +94,7 @@ ratchet_fixture = "0.4"
9394
flate2 = "1.0.22"
9495
bitflags = "2.5"
9596
rocksdb = "0.22"
96-
integer-encoding = "3.0.4"
97+
integer-encoding = "4.0.0"
9798
rustls = "0.20"
9899
webpki = "0.22"
99100
webpki-roots = "0.22"

example_apps/aggregations/src/area.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl AreaLifecycle {
122122
impl AreaLifecycle {
123123
#[on_start]
124124
pub fn on_start(&self, context: HandlerContext<AreaAgent>) -> impl EventHandler<AreaAgent> {
125-
context.send_command(None, "/aggregate", "register", self.area.to_string())
125+
context.send_command(None, "/city", "register", self.area.to_string())
126126
}
127127

128128
#[on_command(registrations)]
@@ -140,8 +140,10 @@ impl AreaLifecycle {
140140
format!("/cars/{car_id}").as_str(),
141141
"speed",
142142
)
143-
.boxed(),
144-
Action::Deregister(car_id) => context.remove_downlink(AreaAgent::CARS, *car_id).boxed(),
143+
.boxed_local(),
144+
Action::Deregister(car_id) => context
145+
.remove_downlink(AreaAgent::CARS, *car_id)
146+
.boxed_local(),
145147
}
146148
}
147149
#[on_update(cars)]

example_apps/aggregations/src/aggregate.rs renamed to example_apps/aggregations/src/city.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,38 @@ use swimos::{
2424

2525
#[derive(AgentLaneModel)]
2626
#[projections]
27-
pub struct AggregateAgent {
27+
pub struct CityAgent {
2828
aggregated: JoinValueLane<String, f64>,
2929
average_speed: ValueLane<f64>,
3030
register: CommandLane<String>,
3131
}
3232

3333
#[derive(Clone, Default)]
34-
pub struct AggregateLifecycle;
34+
pub struct CityLifecycle;
3535

36-
#[lifecycle(AggregateAgent)]
37-
impl AggregateLifecycle {
36+
#[lifecycle(CityAgent)]
37+
impl CityLifecycle {
3838
#[on_update(aggregated)]
3939
fn aggregated(
4040
&self,
41-
context: HandlerContext<AggregateAgent>,
41+
context: HandlerContext<CityAgent>,
4242
averages: &HashMap<String, f64>,
4343
_key: String,
4444
_prev: Option<f64>,
4545
_new_value: &f64,
46-
) -> impl EventHandler<AggregateAgent> {
46+
) -> impl EventHandler<CityAgent> {
4747
let average = averages.values().sum::<f64>() / averages.len() as f64;
48-
context.set_value(AggregateAgent::AVERAGE_SPEED, average)
48+
context.set_value(CityAgent::AVERAGE_SPEED, average)
4949
}
5050

5151
#[on_command(register)]
5252
pub fn register(
5353
&self,
54-
context: HandlerContext<AggregateAgent>,
54+
context: HandlerContext<CityAgent>,
5555
area_id: &String,
56-
) -> impl EventHandler<AggregateAgent> {
56+
) -> impl EventHandler<CityAgent> {
5757
context.add_downlink(
58-
AggregateAgent::AGGREGATED,
58+
CityAgent::AGGREGATED,
5959
area_id.clone(),
6060
None,
6161
format!("/area/{}", area_id).as_str(),

example_apps/aggregations/src/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use std::time::Duration;
1818

1919
use crate::area::Area;
2020
use crate::{
21-
aggregate::{AggregateAgent, AggregateLifecycle},
2221
area::{AreaAgent, AreaLifecycle},
2322
car::CarAgent,
2423
car::CarLifecycle,
24+
city::{CityAgent, CityLifecycle},
2525
};
2626
use example_util::{example_logging, manage_handle};
2727
use swimos::route::RouteUri;
@@ -31,9 +31,9 @@ use swimos::{
3131
server::{Server, ServerBuilder},
3232
};
3333

34-
mod aggregate;
3534
mod area;
3635
mod car;
36+
mod city;
3737

3838
#[tokio::main]
3939
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
@@ -46,12 +46,11 @@ async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
4646
AreaLifecycle::new(name).into_lifecycle(),
4747
)
4848
};
49-
let aggregate_agent =
50-
AgentModel::new(AggregateAgent::default, AggregateLifecycle.into_lifecycle());
49+
let aggregate_agent = AgentModel::new(CityAgent::default, CityLifecycle.into_lifecycle());
5150

5251
let mut builder = ServerBuilder::with_plane_name("Example Plane")
5352
.add_route(RoutePattern::parse_str("/cars/:car_id")?, car_agent)
54-
.add_route(RoutePattern::parse_str("/aggregate")?, aggregate_agent)
53+
.add_route(RoutePattern::parse_str("/city")?, aggregate_agent)
5554
.update_config(|config| {
5655
config.agent_runtime.inactive_timeout = Duration::from_secs(5 * 60);
5756
});

example_apps/command_lane/src/agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ impl ExampleLifecycle {
7676
cmd: &Instruction,
7777
) -> impl EventHandler<ExampleAgent> {
7878
match *cmd {
79-
Instruction::Zero => context.set_value(ExampleAgent::LANE, 0).boxed(),
79+
Instruction::Zero => context.set_value(ExampleAgent::LANE, 0).boxed_local(),
8080
Instruction::Add(n) => context
8181
.get_value(ExampleAgent::LANE)
8282
.and_then(move |v| context.set_value(ExampleAgent::LANE, v + n))
83-
.boxed(),
84-
Instruction::Stop => context.stop().boxed(),
83+
.boxed_local(),
84+
Instruction::Stop => context.stop().boxed_local(),
8585
}
8686
}
8787
}

example_apps/event_downlink/src/consumer/agent.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ impl ConsumerLifecycle {
101101
),
102102
})
103103
.discard()
104-
.boxed(),
104+
.boxed_local(),
105105
Instruction::CloseLink => handle
106106
.with_mut(|h| {
107107
if let Some(h) = h.as_mut() {
108108
h.stop();
109109
}
110110
})
111-
.boxed(),
112-
Instruction::Stop => context.stop().boxed(),
111+
.boxed_local(),
112+
Instruction::Stop => context.stop().boxed_local(),
113113
};
114114
context
115115
.effect(move || println!("{}", msg))

example_apps/local_downlink/src/consumer/agent.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@ impl ConsumerLifecycle {
9898
),
9999
})
100100
.discard()
101-
.boxed(),
101+
.boxed_local(),
102102
Instruction::CloseLink => handle
103103
.with_mut(|h| {
104104
if let Some(h) = h.as_mut() {
105105
h.stop();
106106
}
107107
})
108-
.boxed(),
108+
.boxed_local(),
109109
Instruction::Send(n) => handle
110110
.with_mut(move |maybe| {
111111
if let Some(handle) = maybe.as_mut() {
@@ -114,8 +114,8 @@ impl ConsumerLifecycle {
114114
}
115115
}
116116
})
117-
.boxed(),
118-
Instruction::Stop => context.stop().boxed(),
117+
.boxed_local(),
118+
Instruction::Stop => context.stop().boxed_local(),
119119
};
120120
context
121121
.effect(move || println!("{}", msg))

example_apps/map_downlink/src/consumer/agent.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ impl ConsumerLifecycle {
105105
),
106106
})
107107
.discard()
108-
.boxed(),
108+
.boxed_local(),
109109
Instruction::CloseLink => handle
110110
.with_mut(|h| {
111111
if let Some(h) = h.as_mut() {
112112
h.stop();
113113
}
114114
})
115-
.boxed(),
115+
.boxed_local(),
116116
Instruction::Send(n) => handle
117117
.with_mut(move |h| {
118118
if let Some(handle) = h.as_mut() {
@@ -121,8 +121,8 @@ impl ConsumerLifecycle {
121121
}
122122
}
123123
})
124-
.boxed(),
125-
Instruction::Stop => context.stop().boxed(),
124+
.boxed_local(),
125+
Instruction::Stop => context.stop().boxed_local(),
126126
};
127127
context
128128
.effect(move || println!("{}", msg))

example_apps/map_store/src/agent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ impl ExampleLifecycle {
8585
context
8686
.get_value(ExampleAgent::LANE)
8787
.and_then(move |v| context.update(ExampleAgent::SAVED, key, v))
88-
.boxed()
88+
.boxed_local()
8989
}
9090
Instruction::Restore(name) => {
9191
let key = name.clone();
9292
context
9393
.get_entry(ExampleAgent::SAVED, key)
9494
.map(|maybe: Option<i32>| maybe.unwrap_or_default())
9595
.and_then(move |v| context.set_value(ExampleAgent::LANE, v))
96-
.boxed()
96+
.boxed_local()
9797
}
9898
}
9999
}

example_apps/map_store_persistence/src/agent.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,14 @@ impl ExampleLifecycle {
8989
cmd: &Instruction,
9090
) -> impl EventHandler<ExampleAgent> {
9191
match cmd {
92-
Instruction::Wake => UnitHandler::default().boxed(),
92+
Instruction::Wake => UnitHandler::default().boxed_local(),
9393
Instruction::SetValue { key, value } => context
9494
.update(ExampleAgent::VALUE, key.clone(), *value)
95-
.boxed(),
95+
.boxed_local(),
9696
Instruction::SetTemp { key, value } => context
9797
.update(ExampleAgent::TEMPORARY, key.clone(), *value)
98-
.boxed(),
99-
Instruction::Stop => context.stop().boxed(),
98+
.boxed_local(),
99+
Instruction::Stop => context.stop().boxed_local(),
100100
}
101101
}
102102
}

0 commit comments

Comments
 (0)