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); }
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)); }
public static void GetMicManifestWithCancelledTokenThrows(string hostname) { Assert.Throws <TaskCanceledException>(() => { var cts = new CancellationTokenSource(); cts.Cancel(); MicManifest.GetMicManifest(hostname, cts.Token) .GetAwaiter().GetResult(); }); }
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); }
public static async Task GetMicManifestForHostname(string hostname) { var manifest = await MicManifest.GetMicManifest(hostname); AssertMicManifest(manifest); }