Exemplo n.º 1
0
        /// <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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 static void Main(string[] args)
 {
     Console.WriteLine("Launching vault probe..");
     VaultProbe.EndlessRun();
 }