Skip to content

Commit 50b9658

Browse files
committed
Updates to new structure
1 parent a84c6a2 commit 50b9658

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed

example_apps/supply_lane/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::agent::{ExampleAgent, ExampleLifecycle};
2626
mod agent;
2727

2828
#[tokio::main]
29-
async fn main() -> Result<(), Box<dyn Error>> {
29+
async fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
3030
example_logging()?;
3131
let route = RoutePattern::parse_str("/example/:name}")?;
3232

server/swim_agent/src/lanes/supply/tests.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,11 @@ fn supply_event_handler() {
8383
&agent,
8484
);
8585

86+
let _modification = Modification::no_trigger(LANE_ID);
8687
assert!(matches!(
8788
result,
8889
StepResult::Complete {
89-
modified_item: Some(Modification {
90-
item_id: LANE_ID,
91-
trigger_handler: false
92-
}),
90+
modified_item: Some(_modification),
9391
result: ()
9492
}
9593
));
@@ -120,13 +118,11 @@ fn supply_lane_sync_handler() {
120118
&agent,
121119
);
122120

121+
let _modification = Modification::no_trigger(LANE_ID);
123122
assert!(matches!(
124123
result,
125124
StepResult::Complete {
126-
modified_item: Some(Modification {
127-
item_id: LANE_ID,
128-
trigger_handler: false
129-
}),
125+
modified_item: Some(_modification),
130126
result: ()
131127
}
132128
));

server/swim_agent_derive/src/lane_model_derive/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ impl<'a> HandlerType<'a> {
455455
WarpLaneSpec::Demand(_)
456456
| WarpLaneSpec::DemandMap(_, _)
457457
| WarpLaneSpec::JoinValue(_, _)
458-
| LaneSpec::Supply(_) => {
458+
| WarpLaneSpec::Supply(_) => {
459459
quote!(#root::event_handler::UnitHandler)
460460
}
461461
}
@@ -487,7 +487,7 @@ impl<'a> SyncHandlerType<'a> {
487487
WarpLaneSpec::JoinValue(k, v) => {
488488
quote!(#root::lanes::join_value::JoinValueLaneSync<#agent_name, #k, #v>)
489489
}
490-
LaneSpec::Supply(t) => {
490+
WarpLaneSpec::Supply(t) => {
491491
quote!(#root::lanes::supply::SupplyLaneSync<#agent_name, #t>)
492492
}
493493
}
@@ -549,7 +549,7 @@ impl<'a> WarpLaneHandlerMatch<'a> {
549549
WarpLaneSpec::Demand(_)
550550
| WarpLaneSpec::DemandMap(_, _)
551551
| WarpLaneSpec::JoinValue(_, _)
552-
| LaneSpec::Supply(_) => {
552+
| WarpLaneSpec::Supply(_) => {
553553
quote!(#root::event_handler::UnitHandler::default())
554554
}
555555
};
@@ -652,7 +652,7 @@ impl<'a> SyncHandlerMatch<'a> {
652652
WarpLaneSpec::JoinValue(k, v) => {
653653
quote!(#root::lanes::join_value::JoinValueLaneSync::<#agent_name, #k, #v>::new(|agent: &#agent_name| &agent.#name, id))
654654
}
655-
LaneSpec::Supply(ty) => {
655+
WarpLaneSpec::Supply(ty) => {
656656
quote!(#root::lanes::supply::SupplyLaneSync::<#agent_name, #ty>::new(|agent: &#agent_name| &agent.#name, id))
657657
}
658658
};
@@ -809,7 +809,7 @@ impl<'a> LaneSpecInsert<'a> {
809809
}
810810
ItemSpec::Http(_) => quote!(#root::agent_model::ItemDescriptor::Http),
811811
ItemSpec::Supply(_) => {
812-
quote!(#root::agent_model::ItemKind::Lane(#root::agent_model::LaneKind::Supply))
812+
quote!(#root::agent_model::ItemDescriptor::WarpLane { kind: #root::agent_model::WarpLaneKind::Supply, flags: #flags })
813813
}
814814
};
815815
let external_lane_name = model.external_literal();

server/swim_agent_derive/src/lane_model_derive/model.rs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ impl<'a> ItemSpec<'a> {
117117
ItemSpec::Value(ItemKind::Lane, t) => Some(WarpLaneSpec::Value(t)),
118118
ItemSpec::Map(ItemKind::Lane, k, v) => Some(WarpLaneSpec::Map(k, v)),
119119
ItemSpec::JoinValue(k, v) => Some(WarpLaneSpec::JoinValue(k, v)),
120-
ItemSpec::Supply(t) => Some(LaneSpec::Supply(t))
120+
ItemSpec::Supply(t) => Some(WarpLaneSpec::Supply(t)),
121121
_ => None,
122122
}
123123
}
@@ -448,12 +448,15 @@ fn extract_lane_model(field: &Field) -> Validation<ItemModel<'_>, Errors<syn::Er
448448
Err(e) => Validation::fail(Errors::of(e)),
449449
},
450450
SUPPLY_LANE_NAME => {
451-
let param = single_param(arguments)?;
452-
Ok(ItemModel::new(
453-
fld_name,
454-
ItemSpec::Supply(param),
455-
ItemFlags::TRANSIENT, //Supply lanes are always transient.
456-
))
451+
match single_param(arguments) {
452+
Ok(param) => Validation::valid(ItemModel::new(
453+
fld_name,
454+
ItemSpec::Supply(param),
455+
ItemFlags::TRANSIENT, //Supply lanes are always transient.
456+
transform,
457+
)),
458+
Err(e) => Validation::fail(Errors::of(e)),
459+
}
457460
}
458461
name @ (HTTP_LANE_NAME | SIMPLE_HTTP_LANE_NAME) => {
459462
match http_params(arguments, name == SIMPLE_HTTP_LANE_NAME) {

swim/tests/deriveagentlanemodel.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@
1313
// limitations under the License.
1414

1515
use std::collections::HashMap;
16-
1716
use std::fmt::Write;
17+
1818
use swim::agent::agent_model::ItemFlags;
1919
use swim::agent::lanes::{CommandLane, MapLane, ValueLane};
2020
use swim::agent::model::MapMessage;
2121
use swim::agent::model::Text;
2222
use swim::agent::reexport::bytes::BytesMut;
2323
use swim::agent::reexport::uuid::Uuid;
2424
use swim::agent::AgentLaneModel;
25-
use swim_agent::agent_model::ItemKind;
2625
use swim_agent::agent_model::{ItemDescriptor, ItemSpec};
2726
use swim_agent::lanes::http::Recon;
2827
use swim_agent::lanes::supply::SupplyLane;
@@ -236,7 +235,7 @@ fn single_supply_lane() {
236235
lane: SupplyLane<i32>,
237236
}
238237

239-
check_agent::<SingleSupplyLane>(vec![transient_lane("lane", LaneKind::Supply)]);
238+
check_agent::<SingleSupplyLane>(vec![transient_lane(0, "lane", WarpLaneKind::Supply)]);
240239
}
241240

242241
#[test]
@@ -332,8 +331,8 @@ fn two_supply_lanes() {
332331
}
333332

334333
check_agent::<TwoSupplyLanes>(vec![
335-
transient_lane("first", LaneKind::Supply),
336-
transient_lane("second", LaneKind::Supply),
334+
transient_lane(0, "first", WarpLaneKind::Supply),
335+
transient_lane(1, "second", WarpLaneKind::Supply),
337336
]);
338337
}
339338

@@ -397,15 +396,15 @@ fn multiple_lanes() {
397396

398397
check_agent::<MultipleLanes>(vec![
399398
persistent_lane(0, "first", WarpLaneKind::Value),
400-
persistent_lane(2, "third", WarpLaneKind::Value),
401-
transient_lane(4, "fifth", WarpLaneKind::Command),
402-
transient_lane(6, "seventh", WarpLaneKind::Demand),
403399
persistent_lane(1, "second", WarpLaneKind::Map),
400+
persistent_lane(2, "third", WarpLaneKind::Value),
404401
persistent_lane(3, "fourth", WarpLaneKind::Map),
402+
transient_lane(4, "fifth", WarpLaneKind::Command),
405403
persistent_lane(5, "sixth", WarpLaneKind::JoinValue),
404+
transient_lane(6, "seventh", WarpLaneKind::Demand),
406405
transient_lane(7, "eighth", WarpLaneKind::DemandMap),
407406
http_lane(8, "ninth"),
408-
transient_lane("tenth", LaneKind::Supply),
407+
transient_lane(9, "tenth", WarpLaneKind::Supply),
409408
]);
410409
}
411410

@@ -521,14 +520,14 @@ fn demand_lane_tagged_transient() {
521520
fn supply_lane_tagged_transient() {
522521
#[derive(AgentLaneModel)]
523522
struct TwoSupplyLanes {
524-
#[transient]
523+
#[lane(transient)]
525524
first: SupplyLane<i32>,
526525
second: SupplyLane<i32>,
527526
}
528527

529528
check_agent::<TwoSupplyLanes>(vec![
530-
transient_lane("first", LaneKind::Supply),
531-
transient_lane("second", LaneKind::Supply),
529+
transient_lane(0, "first", WarpLaneKind::Supply),
530+
transient_lane(1, "second", WarpLaneKind::Supply),
532531
]);
533532
}
534533

@@ -659,11 +658,12 @@ fn two_general_http_lanes() {
659658
}
660659

661660
mod isolated {
661+
use swim_api::lane::WarpLaneKind;
662+
use swim_api::store::StoreKind;
663+
662664
use crate::check_agent;
663665

664666
use super::{http_lane, persistent_lane, persistent_store, transient_lane};
665-
use swim_api::lane::WarpLaneKind;
666-
use swim_api::store::StoreKind;
667667

668668
#[test]
669669
fn multiple_items_qualified() {

0 commit comments

Comments
 (0)