diff --git a/examples/DictionaryExample/Program.cs b/examples/DictionaryExample/Program.cs index 9274013c..a750a232 100644 --- a/examples/DictionaryExample/Program.cs +++ b/examples/DictionaryExample/Program.cs @@ -8,7 +8,7 @@ public class Driver { - private static readonly string AUTH_TOKEN_ENV_VAR = "MOMENTO_AUTH_TOKEN"; + private static readonly string AUTH_TOKEN_ENV_VAR = "MOMENTO_API_KEY"; private static readonly string CACHE_NAME_ENV_VAR = "MOMENTO_CACHE_NAME"; private static readonly ILogger _logger; private static readonly ILoggerFactory _loggerFactory; diff --git a/examples/DisposableTokens/Program.cs b/examples/DisposableTokens/Program.cs index b812fbea..bb2175d2 100644 --- a/examples/DisposableTokens/Program.cs +++ b/examples/DisposableTokens/Program.cs @@ -14,7 +14,7 @@ static class Program static Program() { - authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"); + authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY"); client = new AuthClient(AuthConfigurations.Default.Latest(), authProvider); } diff --git a/examples/DisposableTokens/README.md b/examples/DisposableTokens/README.md index 534144bd..47620f0c 100644 --- a/examples/DisposableTokens/README.md +++ b/examples/DisposableTokens/README.md @@ -6,10 +6,10 @@ This example program demonstrates how to generate disposable Momento auth tokens # Usage -The program assumes that your Momento auth token is available in the `MOMENTO_AUTH_TOKEN` environment variable: +The program assumes that your Momento auth token is available in the `MOMENTO_API_KEY` environment variable: ```bash -MOMENTO_AUTH_TOKEN= dotnet run +MOMENTO_API_KEY= dotnet run ``` The example generates a disposable expiring auth token using the enumerated permissions and expiry defined in the program and prints its attributes to the console. diff --git a/examples/DocExampleApis/Program.cs b/examples/DocExampleApis/Program.cs index 77169b84..3fbe5813 100644 --- a/examples/DocExampleApis/Program.cs +++ b/examples/DocExampleApis/Program.cs @@ -11,15 +11,15 @@ public static async Task Main(string[] args) { var config = Configurations.Laptop.V1(); var client = new CacheClient(config, - new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"), + new EnvMomentoTokenProvider("MOMENTO_API_KEY"), TimeSpan.FromSeconds(10)); IAuthClient authClient = new AuthClient( AuthConfigurations.Default.Latest(), - new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN") + new EnvMomentoTokenProvider("MOMENTO_API_KEY") ); ITopicClient topicClient = new TopicClient( TopicConfigurations.Laptop.latest(), - new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN") + new EnvMomentoTokenProvider("MOMENTO_API_KEY") ); await Example_API_CreateCache(client); @@ -240,7 +240,7 @@ public static async Task Example_API_InstantiateTopicClient() { new TopicClient( TopicConfigurations.Laptop.latest(), - new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN") + new EnvMomentoTokenProvider("MOMENTO_API_KEY") ); } #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously diff --git a/examples/MomentoApplication/Program.cs b/examples/MomentoApplication/Program.cs index 8bee2b34..52adf158 100644 --- a/examples/MomentoApplication/Program.cs +++ b/examples/MomentoApplication/Program.cs @@ -7,7 +7,7 @@ using Momento.Sdk.Exceptions; using Momento.Sdk.Responses; -ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"); +ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY"); TimeSpan DEFAULT_TTL = TimeSpan.FromSeconds(60); @@ -128,7 +128,7 @@ public static async Task DeleteCacheExample(ICacheClient client) { /// public static void EagerConnectionExample() { - ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"); + ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY"); TimeSpan defaultTtl = TimeSpan.FromSeconds(60); var config = Configurations.Laptop.V1(); var eagerConnectionConfig = config.WithTransportStrategy(config.TransportStrategy.WithEagerConnectionTimeout(TimeSpan.FromSeconds(10))); diff --git a/examples/MomentoApplication/README.md b/examples/MomentoApplication/README.md index b98859b4..8d2428d7 100644 --- a/examples/MomentoApplication/README.md +++ b/examples/MomentoApplication/README.md @@ -20,13 +20,13 @@ functionality, including: Run the following from within the `examples` directory: ```bash -MOMENTO_AUTH_TOKEN= dotnet run --project MomentoApplication +MOMENTO_API_KEY= dotnet run --project MomentoApplication ``` Within the `MomentoAppication` directory you can run: ```bash -MOMENTO_AUTH_TOKEN= dotnet run +MOMENTO_API_KEY= dotnet run ``` ## Error Handling diff --git a/examples/MomentoFSharpApplication/Program.fs b/examples/MomentoFSharpApplication/Program.fs index 28f4bbfc..a8208b61 100644 --- a/examples/MomentoFSharpApplication/Program.fs +++ b/examples/MomentoFSharpApplication/Program.fs @@ -6,7 +6,7 @@ open System let CACHE_NAME = "cache" let DEFAULT_TTL = TimeSpan.FromSeconds(60.0) -let authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN") +let authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY") let exerciseCache() = ( printfn "Howdy" diff --git a/examples/MomentoLoadGen/Program.cs b/examples/MomentoLoadGen/Program.cs index 6ac4e56d..5956f630 100644 --- a/examples/MomentoLoadGen/Program.cs +++ b/examples/MomentoLoadGen/Program.cs @@ -90,7 +90,7 @@ public CsharpLoadGenerator(IConfiguration momentoClientConfig, CsharpLoadGenerat public async Task Run() { - var authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"); + var authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY"); using (ICacheClient momento = new CacheClient( _momentoClientConfig, diff --git a/examples/MomentoLoadGen/README.md b/examples/MomentoLoadGen/README.md index 8deddd60..042a58fc 100644 --- a/examples/MomentoLoadGen/README.md +++ b/examples/MomentoLoadGen/README.md @@ -31,14 +31,14 @@ To run the load generator (from the `examples` directory): ```bash # Run example load generator -MOMENTO_AUTH_TOKEN= dotnet run --project MomentoLoadGen +MOMENTO_API_KEY= dotnet run --project MomentoLoadGen ``` Within the `MomentoLoadGen` directory you can run: ```bash # Run example load generator -MOMENTO_AUTH_TOKEN= dotnet run +MOMENTO_API_KEY= dotnet run ``` If you make modifications to the code, remember to do a clean otherwise @@ -46,5 +46,5 @@ the program might not run. ```bash dotnet clean -MOMENTO_AUTH_TOKEN= dotnet run +MOMENTO_API_KEY= dotnet run ``` diff --git a/examples/MomentoUsage/Program.cs b/examples/MomentoUsage/Program.cs index 137d5fd4..f3b121d1 100644 --- a/examples/MomentoUsage/Program.cs +++ b/examples/MomentoUsage/Program.cs @@ -4,20 +4,22 @@ using Momento.Sdk.Config; using Momento.Sdk.Responses; -ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN"); +ICredentialProvider authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY"); const string CACHE_NAME = "cache"; const string KEY = "MyKey"; const string VALUE = "MyData"; TimeSpan DEFAULT_TTL = TimeSpan.FromSeconds(60); -using (ICacheClient client = new CacheClient(Configurations.Laptop.V1(), authProvider, DEFAULT_TTL)) +var config = Configurations.Laptop.V1(); +config = config.WithTransportStrategy(config.TransportStrategy.WithEagerConnectionTimeout(TimeSpan.FromSeconds(10))); +using (ICacheClient client = new CacheClient(config, authProvider, DEFAULT_TTL)) { - var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME); - if (createCacheResponse is CreateCacheResponse.Error createError) - { - Console.WriteLine($"Error creating cache: {createError.Message}. Exiting."); - Environment.Exit(1); - } + // var createCacheResponse = await client.CreateCacheAsync(CACHE_NAME); + // if (createCacheResponse is CreateCacheResponse.Error createError) + // { + // Console.WriteLine($"Error creating cache: {createError.Message}. Exiting."); + // Environment.Exit(1); + // } Console.WriteLine($"Setting key: {KEY} with value: {VALUE}"); var setResponse = await client.SetAsync(CACHE_NAME, KEY, VALUE); diff --git a/examples/MomentoUsage/README.md b/examples/MomentoUsage/README.md index ac283d33..0ac84cfb 100644 --- a/examples/MomentoUsage/README.md +++ b/examples/MomentoUsage/README.md @@ -16,13 +16,13 @@ the client's full capabilities, take a look at the more advanced [MomentoApplic Run the following from within the `examples` directory: ```bash -MOMENTO_AUTH_TOKEN= dotnet run --project MomentoUsage +MOMENTO_API_KEY= dotnet run --project MomentoUsage ``` Within the `MomentoUsage` directory you can run: ```bash -MOMENTO_AUTH_TOKEN= dotnet run +MOMENTO_API_KEY= dotnet run ``` ## Error Handling diff --git a/examples/TopicExample/Program.cs b/examples/TopicExample/Program.cs index e51ce391..c4e8a9dd 100644 --- a/examples/TopicExample/Program.cs +++ b/examples/TopicExample/Program.cs @@ -9,7 +9,7 @@ namespace TopicExample; public class Driver { - private const string AuthTokenEnvVar = "MOMENTO_AUTH_TOKEN"; + private const string AuthTokenEnvVar = "MOMENTO_API_KEY"; private const string CacheNameEnvVar = "MOMENTO_CACHE_NAME"; private const string TopicName = "example-topic"; private static readonly ILogger Logger; diff --git a/src/Momento.Sdk/Internal/DataGrpcManager.cs b/src/Momento.Sdk/Internal/DataGrpcManager.cs index 61e36f47..c295a6a3 100644 --- a/src/Momento.Sdk/Internal/DataGrpcManager.cs +++ b/src/Momento.Sdk/Internal/DataGrpcManager.cs @@ -310,7 +310,7 @@ internal DataGrpcManager(IConfiguration config, string authToken, string endpoin pingClient.Ping(new _PingRequest(), new CallOptions(deadline: DateTime.UtcNow.Add(eagerConnectionTimeout))); } - catch (RpcException) + catch (RpcException ex) { _logger.LogWarning("Failed to eagerly connect to the server; continuing with execution in case failure is recoverable later."); }