executeWithArtifacts method

Future<CockpitCommandExecution> executeWithArtifacts(
  1. CockpitCommand command
)

Implementation

Future<CockpitCommandExecution> executeWithArtifacts(
  CockpitCommand command,
) async {
  final stopwatch = Stopwatch()..start();

  try {
    final commandTimeout = _hardCommandTimeout(command);
    final execution = _commandRouter.execute(command, stopwatch);
    if (commandTimeout == null) {
      return await execution;
    }
    // The grace lets in-command wait/assert loops that poll up to the same
    // budget finish first, so their detailed diagnostics win over the
    // generic hard-timeout failure.
    final enforcedTimeout = commandTimeout + _hardCommandTimeoutGrace;
    return await execution.timeout(
      enforcedTimeout,
      onTimeout: () => _commandTimeoutExecution(
        command: command,
        durationMs: stopwatch.elapsedMilliseconds,
        timeoutMs: commandTimeout.inMilliseconds,
        enforcedTimeoutMs: enforcedTimeout.inMilliseconds,
      ),
    );
  } finally {
    stopwatch.stop();
  }
}