Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make event handlers more deterministic #1920

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

andchiind
Copy link
Contributor

@andchiind andchiind commented Jan 2, 2025

Closes #1891

Ready for review checklist:

  • A self-review has been performed
  • All commits run individually
  • Temporary changes have been removed, like console.log, TODO, etc.
  • The PR has been tested locally
  • A test have been written
    • This change doesn't need a new test
  • Relevant issues are linked
  • Remaining work is documented in issues
    • There is no remaining work from this PR that require new issues
  • The changes does not introduce dead code as unused imports, functions etc.

@andchiind andchiind added backend Backend related functionality improvement Improvement to existing functionality labels Jan 2, 2025
@andchiind andchiind self-assigned this Jan 2, 2025
@andchiind andchiind marked this pull request as draft January 2, 2025 08:52
@andchiind andchiind marked this pull request as ready for review January 2, 2025 09:19
@andchiind andchiind force-pushed the 1891-deterministic-event-handlers branch from 679b070 to f32f840 Compare January 2, 2025 09:26
);
var robot = await RobotService.ReadById(e.RobotId, readOnly: true);
if (robot == null)
if (e.Robot == null)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the robot be required to be a part of the event args so this can be known to never be null?

return;
}

_startMissionSemaphore.WaitOne();
try
{
await MissionScheduling.StartNextMissionRunIfSystemIsAvailable(robot);
await MissionScheduling.StartNextMissionRunIfSystemIsAvailable(e.Robot);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rather than passing the entire robot object, would it make sense to only pass the relevant information about the robot needed to start the next mission

@@ -573,7 +573,7 @@ private async void OnIsarBatteryUpdate(object? sender, MqttReceivedArgs mqttArgs
robot.Name
);
EmergencyActionService.SendRobotToDock(
new RobotEmergencyEventArgs(robot.Id, RobotFlotillaStatus.Recharging)
new RobotEmergencyEventArgs(robot, RobotFlotillaStatus.Recharging)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to pass the entire robot object, or can we only pass the relevant informations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Backend related functionality improvement Improvement to existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make MissionEventHandler events pass the relevant robot state in the event arguments
2 participants