-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allows aliases to be used as source/destination of activities
The approach followed for this is pretty straight-forward: instead of loading PK directly to our ActivityDefinition data struct, we allow it to be NodeId (in the same fashion we do for allowing aliases in node definitions). However, we internally identify activities using PK, so we do an additional mapping step once the data is loaded to go from NodeId{PK, Alias} to NodeId(PK), hence, once data is passed to the simulator it is always identified by NodeId(PK). Notice that, after `Simulation::validate_activity` it is safe to call `NodeId::get_pk::unwrap()`, given no NodeId::Alias should have passed validation. For activity destinations, we also need to make sure that if an alias has been provided we do control that node, otherwise the Alias->PK mapping cannot be done, in which case we fail with a `ValidationError`.I've performed the validation in main to avoid having to pass the reverse_pk_alias map to the simulator (given we will need an alias_pk map in the simulator later on to be able to log both PKs and aliases). This may break a bit the layer separation (we may not want to raise a `ValidationError` in main), so I'm happy to re-structure this in the next commit if we are happy with two maps (or any alternative approach you can come up with)
- Loading branch information
Showing
4 changed files
with
128 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters