Cancellation Flow

Cancellation flow discussion involving UX and technical details

Technical details

CGI Electron Behavior

CGI Electron connection supports multi-threading. It is possible to keep the Execute method synchronous and perform cancellation from a different thread. A code like this will work:

this.ExecutionConnection.On<dynamic, ControllerExecutionResult>(Messages.Conversion.Convert, p =>
{
    var executionResult = this.controller.Execute(this.executionParameters);
    if (executionResult.FinalResult != FinalResult.Success)
    {
        this.ExecutionConnection.Send(
            Messages.Conversion.CriticalError,
            new ExecutionEvent() {
                Severity = ExecutionEventSeverity.Critical,
                ExecutionStep = ExecutionStep.LoadingSymbols
            });
    }

    return executionResult;
});

// The following lines of code are just a suggestion:
this.ExecutionConnection.On<dynamic, ControllerExecutionResult>(Messages.Conversion.Cancel, p => {
    return this.controller.Cancel();
});

If the Messages.Conversion.Convert is sent (from the Electron process), and then the Messages.Conversion.Cancel message is sent (from the Electron process), then the CodeProcessor.Cancel method will be called inside the this.controller.Cancel. That will happen after the Messages.Conversion.Cancel message arrives, and it is not necessary to wait for the complete execution of the code that is executed when the Messages.Conversion.Convert message is received (in that case, it would not have been possible to cancel appropriately).

The Controller.Execute method might need to be modified in order to handle the cancellation flow.

Failure of the cancellation

There are some of cases in which the cancellation will result in failure:

  • The Cancel method is not implemented.

  • The Cancel method takes too long and the user terminates the Cancellation by force (see more about this in the following section: The cancellation takes too much time)

  • The Cancel method throws an unhandled exception.

There should be a page for the case in which this failure occurs. Depending on the CodeProcessor which is being used, there might be problems with the reporting of the work that had been done before the cancellation occurred.

The cancellation takes too much time

What happens if the cancellation fails or takes too much? Maybe there could be an option for the user in which the cancellation is terminated by force.

UX/UI details

  • There should be a page for the case in which this fails.

  • The page that will be shown after the cancellation succeeds should be based on the page that is shown when the conversion succeeds. There are some metrics that can be shown here. It is necessary to evaluate which will be available at this point. NOTE: The Code Processor knows how much files will be processed.

  • It is important to consider the cases in which the conversion takes too long.

Side effects of the Cancellation

  • The cancellation should be reported in the logs and the monitoring.

  • All the Processes related to the Code Processors must be canceled of Killed.

  • The workload should be applied to the license or not? It is necessary to consider the case in which the cancellation fails.

  • The logger should also report how did the Code Processor finished.

  • ControllerMonitor.ReportExecutionFinishedEvent should include the status of the execution.

  • CodeProcessorExecutionResult should include new fields with data related to the progress of the execution (processed files, processed units, etc...)

PBIs

Last updated