waitForFinalOperationStatus method

Future<bool> waitForFinalOperationStatus(
  1. String operationID
)

waitForFinalOperationStatus waits for operation to be final

Implementation

Future<bool> waitForFinalOperationStatus(String operationID) async {
  bool timeoutReached = false;
  Timer timeoutTimer = Timer(CommonConstants.waitOperationTimeout, () {
    timeoutReached = true;
  });

  final filter =
      NewSlotExecutionOutputsFilter(executedOpsChangesFilter: ExecutedOpsChangesFilter(operationId: operationID));
  await for (var resp in _grpc.newSlotExecutionOutputs(filters: [filter])) {
    if (resp.status == ExecutionOutputStatus.EXECUTION_OUTPUT_STATUS_FINAL) {
      timeoutTimer.cancel();
      return true;
    }
    if (timeoutReached) {
      timeoutTimer.cancel();
      return false;
    }
  }

  timeoutTimer.cancel();
  return false;
}