Skip to content

Commit c699fee

Browse files
committed
Renames aggregations AggregateAgent to CityAgent
1 parent 20202c3 commit c699fee

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

example_apps/aggregations/src/area.rs

Lines changed: 1 addition & 1 deletion
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)]

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
});

0 commit comments

Comments
 (0)