/// <summary> /// Start an endless run of probing. /// </summary> public static void EndlessRun() { VaultProbe vaultProbe = null; TimeSpan downtime = TimeSpan.FromSeconds(2.0); for (; ;) { try { // initialize a vault probe with settings read from environment // one time only, but do retry if (vaultProbe == null) { vaultProbe = new VaultProbe(ProbeConfig.FromEnvironment()); downtime = TimeSpan.FromSeconds(vaultProbe.config.ProbeIntervalInSeconds); } // start probe var result = Task.Run(async() => await vaultProbe.ProbeSecretAsync().ConfigureAwait(false)) .GetAwaiter() .GetResult(); Console.WriteLine($"sleeping for {downtime.Seconds}s.."); } catch (Exception ex) { Console.WriteLine($"encountered '{ex.Message}'; retrying in {downtime.Seconds}.."); } // rest Thread.Sleep(downtime); } }
/// <summary> /// Initializes a vault probe object with the specified config. /// </summary> /// <param name="config"></param> public VaultProbe(ProbeConfig config) { this.config = config; var handler = new HttpClientHandler(); handler.ServerCertificateCustomValidationCallback += ServerCertificateValidation; httpClient = new HttpClient(handler); }
public async Task <ActionResult <String> > Get() { // initialize a vault probe with settings read from environment VaultProbe vaultProbe = new VaultProbe(ProbeConfig.FromEnvironment()); String result = await vaultProbe.ProbeSecretAsync() .ConfigureAwait(false); return(result); }
/// <summary> /// Initializes a vault probe object with default configuration /// </summary> public VaultProbe() : this(ProbeConfig.FromEnvironment()) { }
/// <summary> /// Initializes a vault probe object with the specified config. /// </summary> /// <param name="config"></param> public VaultProbe(ProbeConfig config) { this.config = config; httpClient = new HttpClient(); }