/// <inheritdoc/> public async Task CancelAsync(DiscoveryCancelModel request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } await _events.PublishAsync(request); }
/// <inhertitdoc/> public async Task CancelAsync(string discovererId, DiscoveryCancelModel request, CancellationToken ct) { if (request == null) { throw new ArgumentNullException(nameof(request)); } await CallServiceOnDiscovererAsync(discovererId, "Cancel_V2", request, ct); }
/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public DiscoveryCancelApiModel(DiscoveryCancelModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } Id = model.Id; Context = model.Context == null ? null : new RegistryOperationContextApiModel(model.Context); }
/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public static DiscoveryCancelInternalApiModel ToApiModel( this DiscoveryCancelModel model) { if (model == null) { return(null); } return(new DiscoveryCancelInternalApiModel { Id = model.Id, Context = model.Context.ToApiModel() }); }
/// <inheritdoc/> public async Task CancelAsync(DiscoveryCancelModel request, CancellationToken ct) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var discoverers = _discoverers; foreach (var id in discoverers) { try { await _client.CancelAsync(id, request, ct); } catch (Exception ex) { _logger.Debug(ex, "Failed to call cancel on {id}. Continue...", id); } } }
/// <inheritdoc/> public async Task CancelAsync(DiscoveryCancelModel request, CancellationToken ct) { kCancelAsync.Inc(); if (request == null) { throw new ArgumentNullException(nameof(request)); } await _lock.WaitAsync(); try { foreach (var task in _pending.Where(r => r.Request.Id == request.Id)) { // Cancel the task task.Cancel(); } } finally { _lock.Release(); } }
/// <inheritdoc/> public Task CancelAsync(DiscoveryCancelModel request, CancellationToken ct) { return(_client.CancelAsync(request.ToApiModel(), ct)); }