/// <inheritdoc />
 public Task IncorporateStrongFingerprints(
     Context context,
     string cacheNamespace,
     IncorporateStrongFingerprintsRequest incorporateStrongFingerprintsRequest)
 {
     return(ArtifactHttpClientErrorDetectionStrategy.ExecuteAsync(
                context,
                "IncorporateStrongFingerprints",
                () => _buildCacheHttpClient.IncorporateStrongFingerprints(cacheNamespace, incorporateStrongFingerprintsRequest),
                CancellationToken.None));
 }
Beispiel #2
0
        /// <summary>
        /// Creates an http client that can communicate with a VSTS Build Cache Service.
        /// </summary>
        public async Task <IBlobBuildCacheHttpClient> CreateBlobBuildCacheHttpClientAsync(Context context)
        {
            RetryPolicy authRetryPolicy = new RetryPolicy <AuthorizationErrorDetectionStrategy>(RetryStrategy.DefaultExponential);
            var         creds           = await authRetryPolicy.ExecuteAsync(() => _vssCredentialsFactory.CreateVssCredentialsAsync(_buildCacheBaseUri, _useAad)).ConfigureAwait(false);

            var httpClientFactory = new ArtifactHttpClientFactory(
                creds,
                _httpSendTimeout,
                tracer: new AppTraceSourceContextAdapter(context, "BuildCacheHttpClientFactory", SourceLevels.All),
                verifyConnectionCancellationToken: CancellationToken.None); // TODO: Pipe down cancellation support (bug 1365340)
            IBlobBuildCacheHttpClient client =
                httpClientFactory.CreateVssHttpClient <IArtifactBlobBuildCacheHttpClient, BlobBuildCacheHttpClient>(_buildCacheBaseUri);
            await ArtifactHttpClientErrorDetectionStrategy.ExecuteAsync(
                context,
                "VerifyBlobBuildCacheHttpClientConnection",
                () => httpClientFactory.VerifyConnectionAsync(client as IArtifactHttpClient),
                CancellationToken.None).ConfigureAwait(false);

            context.TraceMessage(
                Severity.Debug, $"Verified connection to {_buildCacheBaseUri} with SessionId=[{httpClientFactory.ClientSettings.SessionId}]");
            return(client);
        }
Beispiel #3
0
        /// <summary>
        /// Creates an http client that can communicate with a VSTS Build Cache Service.
        /// </summary>
        public async Task <IBuildCacheHttpClient> CreateBuildCacheHttpClientAsync(Context context)
        {
            IRetryPolicy retryPolicy = RetryPolicyFactory.GetExponentialPolicy(AuthorizationErrorDetectionStrategy.IsTransient);
            var          creds       = await retryPolicy.ExecuteAsync(
                () => _vssCredentialsFactory.GetOrCreateVssCredentialsAsync(_buildCacheBaseUri, _useAad, PatType.CacheReadWrite),
                CancellationToken.None).ConfigureAwait(false);

            var httpClientFactory = new ArtifactHttpClientFactory(
                creds,
                _httpSendTimeout,
                tracer: new AppTraceSourceContextAdapter(context, "BuildCacheHttpClientFactory", SourceLevels.All),
                verifyConnectionCancellationToken: CancellationToken.None); // TODO: Pipe down cancellation support (bug 1365340)
            IBuildCacheHttpClient client =
                httpClientFactory.CreateVssHttpClient <IArtifactBuildCacheHttpClient, ItemBuildCacheHttpClient>(_buildCacheBaseUri);
            await ArtifactHttpClientErrorDetectionStrategy.ExecuteAsync(
                context,
                "VerifyBuildCacheHttpClientConnection",
                () => httpClientFactory.VerifyConnectionAsync(client as IArtifactHttpClient),
                CancellationToken.None).ConfigureAwait(false);

            _tracer.Debug(context, $"Verified connection to {_buildCacheBaseUri} with SessionId=[{httpClientFactory.ClientSettings.SessionId}]");
            return(client);
        }