Example #1
0
        public static async Task <MicClient> CreateMicClient(string hostname, CancellationToken cancelToken)
        {
            HttpClientHandler httpHandler = new HttpClientHandler();

            if (useProxy)
            {
                httpHandler.Proxy    = new WebProxy("http://localhost:8888/");
                httpHandler.UseProxy = true;
            }

            MicClient micClient;

            if (useLambdaClient)
            {
                MicManifest manifest;
                using (var httpClient = new HttpClient(httpHandler))
                {
                    manifest = await MicManifest.GetMicManifest(hostname, httpClient, cancelToken);
                }
                micClient = new MicLambdaClient(manifest);
            }
            else
            {
                micClient = await MicRestClient.CreateFromHostname(hostname, httpHandler, cancelToken);
            }

            if (useProxy)
            {
                micClient.Config.ProxyHost = "localhost";
                micClient.Config.ProxyPort = 8888;
            }

            return(micClient);
        }
Example #2
0
        public static async Task <MicLambdaClient> CreateFromHostname(
            string hostname, CancellationToken cancelToken = default)
        {
            var manifest = await MicManifest.GetMicManifest(hostname, cancelToken)
                           .ConfigureAwait(continueOnCapturedContext: false);

            return(new MicLambdaClient(manifest));
        }
Example #3
0
 public static void GetMicManifestWithCancelledTokenThrows(string hostname)
 {
     Assert.Throws <TaskCanceledException>(() =>
     {
         var cts = new CancellationTokenSource();
         cts.Cancel();
         MicManifest.GetMicManifest(hostname, cts.Token)
         .GetAwaiter().GetResult();
     });
 }
Example #4
0
        private static async Task <MicRestClient> CreateFromHostname(string hostname, string apiKey, HttpClient httpClient, CancellationToken cancelToken)
        {
            var manifest = await MicManifest.GetMicManifest(hostname, httpClient, cancelToken)
                           .ConfigureAwait(continueOnCapturedContext: false);

            //string apiKey = manifest.ApiKeyId;
            var micClient = new MicRestClient(manifest, apiKey, httpClient);

            return(micClient);
        }
Example #5
0
        public static async Task GetMicManifestForHostname(string hostname)
        {
            var manifest = await MicManifest.GetMicManifest(hostname);

            AssertMicManifest(manifest);
        }