/// <nodoc />
        public DeploymentProxyService(
            ProxyServiceConfiguration configuration,
            HostParameters hostParameters,
            IAbsFileSystem fileSystem = null,
            IClock clock = null,
            IDeploymentServiceClient client = null)
        {
            clock ??= SystemClock.Instance;
            Configuration        = configuration;
            Root                 = new AbsolutePath(configuration.RootPath);
            Clock                = clock;
            ContentCacheRequests = new VolatileMap <(string, string), AsyncLazy <BoolResult> >(Clock);
            ProxyAddress         = new VolatileMap <UnitValue, AsyncLazy <string> >(Clock);
            Client               = client ?? DeploymentLauncherHost.Instance.CreateServiceClient();
            HostParameters       = hostParameters;

            DownloadQueue = new ActionQueue(configuration.DownloadConcurrency ?? Environment.ProcessorCount);

            Store = new FileSystemContentStoreInternal(
                fileSystem ?? new PassThroughFileSystem(),
                Clock,
                DeploymentUtilities.GetCasRootPath(Root),
                new ConfigurationModel(new ContentStoreConfiguration(new MaxSizeQuota($"{Configuration.RetentionSizeGb}GB"))),
                settings: new ContentStoreSettings()
            {
                TraceFileSystemContentStoreDiagnosticMessages = true,
            });
        }
Beispiel #2
0
        private AsyncLazy <TValue> GetOrAddExpirableAsyncLazy <TKey, TValue>(
            VolatileMap <TKey, AsyncLazy <TValue> > map,
            TKey key,
            TimeSpan timeToLive,
            Func <Task <TValue> > func)
        {
            AsyncLazy <TValue> asyncLazyValue;

            while (!map.TryGetValue(key, out asyncLazyValue))
            {
                bool invalidate()
                {
                    map.Invalidate(key);
                    return(false);
                }

                asyncLazyValue = new AsyncLazy <TValue>(async() =>
                {
                    try
                    {
                        return(await func());
                    }
                    catch (Exception) when(invalidate())
                    {
                        // This should never be reached.
                        // Using Exception filter to invalidate entry on exception
                        // and preserve stack trace
                        throw;
                    }
                });
                map.TryAdd(key, asyncLazyValue, timeToLive);
            }

            return(asyncLazyValue);
        }
Beispiel #3
0
 public KeyVaultClient(string keyVaultUrl, string azureTenantId, string azureAppId, string azureAppKey, IClock clock, TimeSpan cacheTimeToLive)
 {
     _cachedCertificates = new VolatileMap <string, X509Certificate2>(clock);
     _uri             = new Uri(keyVaultUrl);
     _azureCreds      = new ClientSecretCredential(azureTenantId, azureAppId, azureAppKey);
     _cacheTimeToLive = cacheTimeToLive;
 }
Beispiel #4
0
        /// <nodoc />
        public ContentCacheService(
            ContentCacheConfiguration configuration,
            IPushFileHandler pushFileHandler,
            IDistributedStreamStore streamStore,
            IDeploymentServiceClient client = null)
        {
            Configuration        = configuration;
            StreamStore          = streamStore;
            PushFileHandler      = pushFileHandler;
            ContentCacheRequests = new VolatileMap <string, AsyncLazy <BoolResult> >(Clock);
            Client = client ?? DeploymentLauncherHost.Instance.CreateServiceClient();

            DownloadQueue = new ActionQueue(configuration.DownloadConcurrency ?? Environment.ProcessorCount);
        }