diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 4463d907..cd3efc60 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -14,7 +14,7 @@ jobs:
- os: windows-latest
target-framework: net6.0
- os: windows-latest
- target-framework: net461
+ target-framework: net462
runs-on: ${{ matrix.os }}
env:
TEST_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
diff --git a/.github/workflows/on-push-to-main-branch.yaml b/.github/workflows/on-push-to-main-branch.yaml
index d6f74b70..1ee763cd 100644
--- a/.github/workflows/on-push-to-main-branch.yaml
+++ b/.github/workflows/on-push-to-main-branch.yaml
@@ -12,7 +12,7 @@ jobs:
- os: ubuntu-latest
target-framework: net6.0
- os: windows-latest
- target-framework: net461
+ target-framework: net462
runs-on: ${{ matrix.os }}
env:
TEST_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
diff --git a/Makefile b/Makefile
index 15c45e8f..827d0e62 100644
--- a/Makefile
+++ b/Makefile
@@ -46,7 +46,7 @@ test-net6:
.PHONY: test-net-framework
## Run unit and integration tests on the .NET Framework runtime
test-net-framework:
- @dotnet test -f net461
+ @dotnet test -f net462
.PHONY: run-examples
diff --git a/src/Momento.Sdk/CacheClient.cs b/src/Momento.Sdk/CacheClient.cs
index 0d718142..a47a9e03 100644
--- a/src/Momento.Sdk/CacheClient.cs
+++ b/src/Momento.Sdk/CacheClient.cs
@@ -35,7 +35,7 @@ private ScsDataClient DataClient
protected readonly IConfiguration config;
///
protected readonly ILogger _logger;
-
+
///
/// Async factory function to construct a Momento CacheClient with an eager connection to the
/// Momento server. Calling the CacheClient constructor directly will not establish a connection
@@ -66,10 +66,9 @@ public static async Task CreateAsync(IConfiguration config, ICrede
public CacheClient(IConfiguration config, ICredentialProvider authProvider, TimeSpan defaultTtl)
{
this.config = config;
- var _loggerFactory = config.LoggerFactory;
- this._logger = _loggerFactory.CreateLogger();
+ this._logger = config.LoggerFactory.CreateLogger();
Utils.ArgumentStrictlyPositive(defaultTtl, "defaultTtl");
- this.controlClient = new(_loggerFactory, authProvider.AuthToken, authProvider.ControlEndpoint);
+ this.controlClient = new(config, authProvider.AuthToken, authProvider.ControlEndpoint);
this.dataClients = new List();
int minNumGrpcChannels = this.config.TransportStrategy.GrpcConfig.MinNumGrpcChannels;
int currentMaxConcurrentRequests = this.config.TransportStrategy.MaxConcurrentRequests;
@@ -995,7 +994,7 @@ public async Task SetFetchAsync(string cacheName, string
return await this.DataClient.SetFetchAsync(cacheName, setName);
}
-
+
///
public async Task SetSampleAsync(string cacheName, string setName, int limit)
{
diff --git a/src/Momento.Sdk/Config/Configuration.cs b/src/Momento.Sdk/Config/Configuration.cs
index 407e0a37..9f8973ce 100644
--- a/src/Momento.Sdk/Config/Configuration.cs
+++ b/src/Momento.Sdk/Config/Configuration.cs
@@ -61,6 +61,12 @@ public IConfiguration WithTransportStrategy(ITransportStrategy transportStrategy
return new Configuration(LoggerFactory, RetryStrategy, Middlewares, transportStrategy);
}
+ ///
+ public IConfiguration WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions options)
+ {
+ return new Configuration(LoggerFactory, RetryStrategy, Middlewares, TransportStrategy.WithSocketsHttpHandlerOptions(options));
+ }
+
///
/// Add the specified middlewares to an existing instance of Configuration object in addition to already specified middlewares.
///
diff --git a/src/Momento.Sdk/Config/Configurations.cs b/src/Momento.Sdk/Config/Configurations.cs
index dc1f640e..b426ce91 100644
--- a/src/Momento.Sdk/Config/Configurations.cs
+++ b/src/Momento.Sdk/Config/Configurations.cs
@@ -177,6 +177,17 @@ private Lambda(ILoggerFactory loggerFactory, IRetryStrategy retryStrategy, ITran
}
+ ///
+ /// Provides the latest recommended configuration for a lambda environment.
+ ///
+ ///
+ ///
+ public static IConfiguration V1(ILoggerFactory? loggerFactory = null)
+ {
+ return Default.V1(loggerFactory).WithSocketsHttpHandlerOptions(
+ SocketsHttpHandlerOptions.Of(pooledConnectionIdleTimeout: TimeSpan.FromMinutes(6)));
+ }
+
///
/// Provides the latest recommended configuration for a lambda environment.
///
@@ -184,7 +195,7 @@ private Lambda(ILoggerFactory loggerFactory, IRetryStrategy retryStrategy, ITran
///
public static IConfiguration Latest(ILoggerFactory? loggerFactory = null)
{
- return Default.V1(loggerFactory);
+ return V1(loggerFactory);
}
}
}
diff --git a/src/Momento.Sdk/Config/IConfiguration.cs b/src/Momento.Sdk/Config/IConfiguration.cs
index e1b7998e..20f306d7 100644
--- a/src/Momento.Sdk/Config/IConfiguration.cs
+++ b/src/Momento.Sdk/Config/IConfiguration.cs
@@ -43,6 +43,13 @@ public interface IConfiguration
/// Configuration object with custom transport strategy provided
public IConfiguration WithTransportStrategy(ITransportStrategy transportStrategy);
+ ///
+ /// Creates a new instance of the Configuration object, updated to use the specified SocketHttpHandler options.
+ ///
+ /// Customizations to the SocketsHttpHandler
+ ///
+ public IConfiguration WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions options);
+
///
/// Creates a new instance of the Configuration object, updated to use the specified client timeout.
///
diff --git a/src/Momento.Sdk/Config/Transport/IGrpcConfiguration.cs b/src/Momento.Sdk/Config/Transport/IGrpcConfiguration.cs
index d2e1e758..11f4751f 100644
--- a/src/Momento.Sdk/Config/Transport/IGrpcConfiguration.cs
+++ b/src/Momento.Sdk/Config/Transport/IGrpcConfiguration.cs
@@ -33,6 +33,15 @@ public interface IGrpcConfiguration
///
public GrpcChannelOptions GrpcChannelOptions { get; }
+ ///
+ /// Override the SocketsHttpHandler's options.
+ /// This is irrelevant if the client is using the web client or the HttpClient (older .NET runtimes).
+ ///
+ ///
+ /// This is not part of the gRPC config because it is not part of .
+ ///
+ public SocketsHttpHandlerOptions SocketsHttpHandlerOptions { get; }
+
///
/// Copy constructor to override the Deadline
///
@@ -54,4 +63,11 @@ public interface IGrpcConfiguration
///
/// A new IGrpcConfiguration with the specified channel options
public IGrpcConfiguration WithGrpcChannelOptions(GrpcChannelOptions grpcChannelOptions);
+
+ ///
+ /// Copy constructor to override the SocketsHttpHandler's options.
+ ///
+ ///
+ ///
+ public IGrpcConfiguration WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions idleTimeout);
}
diff --git a/src/Momento.Sdk/Config/Transport/ITransportStrategy.cs b/src/Momento.Sdk/Config/Transport/ITransportStrategy.cs
index 78849ec5..3031f837 100644
--- a/src/Momento.Sdk/Config/Transport/ITransportStrategy.cs
+++ b/src/Momento.Sdk/Config/Transport/ITransportStrategy.cs
@@ -36,6 +36,13 @@ public interface ITransportStrategy
/// A new ITransportStrategy with the specified grpcConfig
public ITransportStrategy WithGrpcConfig(IGrpcConfiguration grpcConfig);
+ ///
+ /// Copy constructor to update the SocketsHttpHandler's options
+ ///
+ ///
+ ///
+ public ITransportStrategy WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions options);
+
///
/// Copy constructor to update the client timeout
///
diff --git a/src/Momento.Sdk/Config/Transport/SocketsHttpHandlerOptions.cs b/src/Momento.Sdk/Config/Transport/SocketsHttpHandlerOptions.cs
new file mode 100644
index 00000000..4393bcf6
--- /dev/null
+++ b/src/Momento.Sdk/Config/Transport/SocketsHttpHandlerOptions.cs
@@ -0,0 +1,66 @@
+#pragma warning disable 1591
+using System;
+using Momento.Sdk.Internal;
+namespace Momento.Sdk.Config.Transport;
+
+public class SocketsHttpHandlerOptions
+{
+ public static TimeSpan DefaultPooledConnectionIdleTimeout { get; } = TimeSpan.FromMinutes(1);
+ public TimeSpan PooledConnectionIdleTimeout { get; } = DefaultPooledConnectionIdleTimeout;
+ public bool EnableMultipleHttp2Connections { get; } = true;
+
+ public SocketsHttpHandlerOptions() { }
+ public SocketsHttpHandlerOptions(TimeSpan pooledConnectionIdleTimeout) : this(pooledConnectionIdleTimeout, true) { }
+ public SocketsHttpHandlerOptions(bool enableMultipleHttp2Connections) : this(DefaultPooledConnectionIdleTimeout, enableMultipleHttp2Connections) { }
+
+ public SocketsHttpHandlerOptions(TimeSpan pooledConnectionIdleTimeout, bool enableMultipleHttp2Connections)
+ {
+ Utils.ArgumentStrictlyPositive(pooledConnectionIdleTimeout, nameof(pooledConnectionIdleTimeout));
+ PooledConnectionIdleTimeout = pooledConnectionIdleTimeout;
+ EnableMultipleHttp2Connections = enableMultipleHttp2Connections;
+ }
+
+ public SocketsHttpHandlerOptions WithPooledConnectionIdleTimeout(TimeSpan pooledConnectionIdleTimeout)
+ {
+ return new SocketsHttpHandlerOptions(pooledConnectionIdleTimeout, EnableMultipleHttp2Connections);
+ }
+
+ public SocketsHttpHandlerOptions WithEnableMultipleHttp2Connections(bool enableMultipleHttp2Connections)
+ {
+ return new SocketsHttpHandlerOptions(PooledConnectionIdleTimeout, enableMultipleHttp2Connections);
+ }
+
+ public static SocketsHttpHandlerOptions Of(TimeSpan pooledConnectionIdleTimeout)
+ {
+ return new SocketsHttpHandlerOptions(pooledConnectionIdleTimeout);
+ }
+
+ public static SocketsHttpHandlerOptions Of(bool enableMultipleHttp2Connections)
+ {
+ return new SocketsHttpHandlerOptions(enableMultipleHttp2Connections);
+ }
+
+ public static SocketsHttpHandlerOptions Of(TimeSpan pooledConnectionIdleTimeout, bool enableMultipleHttp2Connections)
+ {
+ return new SocketsHttpHandlerOptions(pooledConnectionIdleTimeout, enableMultipleHttp2Connections);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (obj == null || GetType() != obj.GetType())
+ {
+ return false;
+ }
+
+ var other = (SocketsHttpHandlerOptions)obj;
+ return PooledConnectionIdleTimeout.Equals(other.PooledConnectionIdleTimeout) &&
+ EnableMultipleHttp2Connections.Equals(other.EnableMultipleHttp2Connections);
+ }
+
+ public override int GetHashCode()
+ {
+ return PooledConnectionIdleTimeout.GetHashCode() * 17 + EnableMultipleHttp2Connections.GetHashCode();
+ }
+
+
+}
diff --git a/src/Momento.Sdk/Config/Transport/StaticTransportStrategy.cs b/src/Momento.Sdk/Config/Transport/StaticTransportStrategy.cs
index e329f5e7..97d90dc0 100644
--- a/src/Momento.Sdk/Config/Transport/StaticTransportStrategy.cs
+++ b/src/Momento.Sdk/Config/Transport/StaticTransportStrategy.cs
@@ -17,6 +17,8 @@ public class StaticGrpcConfiguration : IGrpcConfiguration
public int MinNumGrpcChannels { get; }
///
public GrpcChannelOptions GrpcChannelOptions { get; }
+ ///
+ public SocketsHttpHandlerOptions SocketsHttpHandlerOptions { get; }
///
///
@@ -24,30 +26,38 @@ public class StaticGrpcConfiguration : IGrpcConfiguration
/// Maximum amount of time before a request will timeout
/// Customizations to low-level gRPC channel configuration
/// minimum number of gRPC channels to open
- public StaticGrpcConfiguration(TimeSpan deadline, GrpcChannelOptions? grpcChannelOptions = null, int minNumGrpcChannels = 1)
+ /// Customizations to the SocketsHttpHandler
+ public StaticGrpcConfiguration(TimeSpan deadline, GrpcChannelOptions? grpcChannelOptions = null, int minNumGrpcChannels = 1, SocketsHttpHandlerOptions? socketsHttpHandlerOptions = null)
{
Utils.ArgumentStrictlyPositive(deadline, nameof(deadline));
this.Deadline = deadline;
this.MinNumGrpcChannels = minNumGrpcChannels;
this.GrpcChannelOptions = grpcChannelOptions ?? new GrpcChannelOptions();
+ this.SocketsHttpHandlerOptions = socketsHttpHandlerOptions ?? new SocketsHttpHandlerOptions();
}
///
public IGrpcConfiguration WithDeadline(TimeSpan deadline)
{
- return new StaticGrpcConfiguration(deadline, this.GrpcChannelOptions, this.MinNumGrpcChannels);
+ return new StaticGrpcConfiguration(deadline, GrpcChannelOptions, MinNumGrpcChannels, SocketsHttpHandlerOptions);
}
///
public IGrpcConfiguration WithMinNumGrpcChannels(int minNumGrpcChannels)
{
- return new StaticGrpcConfiguration(this.Deadline, this.GrpcChannelOptions, minNumGrpcChannels);
+ return new StaticGrpcConfiguration(Deadline, GrpcChannelOptions, minNumGrpcChannels, SocketsHttpHandlerOptions);
}
///
public IGrpcConfiguration WithGrpcChannelOptions(GrpcChannelOptions grpcChannelOptions)
{
- return new StaticGrpcConfiguration(this.Deadline, grpcChannelOptions, this.MinNumGrpcChannels);
+ return new StaticGrpcConfiguration(Deadline, grpcChannelOptions, MinNumGrpcChannels);
+ }
+
+ ///
+ public IGrpcConfiguration WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions options)
+ {
+ return new StaticGrpcConfiguration(Deadline, GrpcChannelOptions, MinNumGrpcChannels, options);
}
///
@@ -61,7 +71,8 @@ public override bool Equals(object obj)
var other = (StaticGrpcConfiguration)obj;
return Deadline.Equals(other.Deadline) &&
- MinNumGrpcChannels == other.MinNumGrpcChannels;
+ MinNumGrpcChannels == other.MinNumGrpcChannels &&
+ SocketsHttpHandlerOptions.Equals(other.SocketsHttpHandlerOptions);
// TODO: gRPC doesn't implement a to equals for this
//GrpcChannelOptions.Equals(other.GrpcChannelOptions);
}
@@ -121,6 +132,12 @@ public ITransportStrategy WithGrpcConfig(IGrpcConfiguration grpcConfig)
return new StaticTransportStrategy(_loggerFactory, MaxConcurrentRequests, grpcConfig);
}
+ ///
+ public ITransportStrategy WithSocketsHttpHandlerOptions(SocketsHttpHandlerOptions options)
+ {
+ return new StaticTransportStrategy(_loggerFactory, MaxConcurrentRequests, GrpcConfig.WithSocketsHttpHandlerOptions(options));
+ }
+
///
public ITransportStrategy WithClientTimeout(TimeSpan clientTimeout)
{
diff --git a/src/Momento.Sdk/ITopicClient.cs b/src/Momento.Sdk/ITopicClient.cs
index cd2667b1..f00f0b1d 100644
--- a/src/Momento.Sdk/ITopicClient.cs
+++ b/src/Momento.Sdk/ITopicClient.cs
@@ -1,6 +1,4 @@
using System;
-#if NETSTANDARD2_0_OR_GREATER
-
using System.Threading.Tasks;
using Momento.Sdk.Responses;
@@ -36,7 +34,7 @@ public interface ITopicClient : IDisposable
///
///
public Task PublishAsync(string cacheName, string topicName, byte[] value);
-
+
///
public Task PublishAsync(string cacheName, string topicName, string value);
@@ -66,4 +64,3 @@ public interface ITopicClient : IDisposable
///
public Task SubscribeAsync(string cacheName, string topicName, ulong? resumeAtSequenceNumber = null);
}
-#endif
\ No newline at end of file
diff --git a/src/Momento.Sdk/Internal/ControlGrpcManager.cs b/src/Momento.Sdk/Internal/ControlGrpcManager.cs
index 7a1bdbfd..e357ba39 100644
--- a/src/Momento.Sdk/Internal/ControlGrpcManager.cs
+++ b/src/Momento.Sdk/Internal/ControlGrpcManager.cs
@@ -4,12 +4,13 @@
using System.Threading.Tasks;
using Grpc.Core;
using Grpc.Net.Client;
-#if USE_GRPC_WEB
using System.Net.Http;
+#if USE_GRPC_WEB
using Grpc.Net.Client.Web;
#endif
using Microsoft.Extensions.Logging;
using Momento.Protos.ControlClient;
+using Momento.Sdk.Config;
using Momento.Sdk.Config.Middleware;
using Momento.Sdk.Internal.Middleware;
using static System.Reflection.Assembly;
@@ -86,8 +87,9 @@ internal sealed class ControlGrpcManager : IDisposable
private readonly string runtimeVersion = $"{moniker}:{System.Environment.Version}";
private readonly ILogger _logger;
- public ControlGrpcManager(ILoggerFactory loggerFactory, string authToken, string endpoint)
+ public ControlGrpcManager(IConfiguration config, string authToken, string endpoint)
{
+ this._logger = config.LoggerFactory.CreateLogger();
#if USE_GRPC_WEB
// Note: all web SDK requests are routed to a `web.` subdomain to allow us flexibility on the server
endpoint = $"web.{endpoint}";
@@ -98,20 +100,24 @@ public ControlGrpcManager(ILoggerFactory loggerFactory, string authToken, string
Credentials = ChannelCredentials.SecureSsl,
MaxReceiveMessageSize = Internal.Utils.DEFAULT_MAX_MESSAGE_SIZE,
MaxSendMessageSize = Internal.Utils.DEFAULT_MAX_MESSAGE_SIZE,
-#if USE_GRPC_WEB
- HttpHandler = new GrpcWebHandler(new HttpClientHandler()),
+#if NET5_0_OR_GREATER
+ HttpHandler = new System.Net.Http.SocketsHttpHandler
+ {
+ EnableMultipleHttp2Connections = config.TransportStrategy.GrpcConfig.SocketsHttpHandlerOptions.EnableMultipleHttp2Connections,
+ PooledConnectionIdleTimeout = config.TransportStrategy.GrpcConfig.SocketsHttpHandlerOptions.PooledConnectionIdleTimeout
+ }
+#elif USE_GRPC_WEB
+ HttpHandler = new GrpcWebHandler(new HttpClientHandler())
#endif
});
List headers = new List { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version), new Header(name: Header.RuntimeVersionKey, value: runtimeVersion) };
CallInvoker invoker = this.channel.CreateCallInvoker();
var middlewares = new List {
- new HeaderMiddleware(loggerFactory, headers)
+ new HeaderMiddleware(config.LoggerFactory, headers)
};
Client = new ControlClientWithMiddleware(new ScsControl.ScsControlClient(invoker), middlewares);
-
- this._logger = loggerFactory.CreateLogger();
}
public void Dispose()
diff --git a/src/Momento.Sdk/Internal/DataGrpcManager.cs b/src/Momento.Sdk/Internal/DataGrpcManager.cs
index 5f7444ef..09960dc0 100644
--- a/src/Momento.Sdk/Internal/DataGrpcManager.cs
+++ b/src/Momento.Sdk/Internal/DataGrpcManager.cs
@@ -5,8 +5,8 @@
using System.Threading.Tasks;
using Grpc.Core;
using Grpc.Net.Client;
-#if USE_GRPC_WEB
using System.Net.Http;
+#if USE_GRPC_WEB
using Grpc.Net.Client.Web;
#endif
using Microsoft.Extensions.Logging;
@@ -182,7 +182,7 @@ public async Task<_SetSampleResponse> SetSampleAsync(_SetSampleRequest request,
var wrapped = await _middlewares.WrapRequest(request, callOptions, (r, o) => _generatedClient.SetSampleAsync(r, o));
return await wrapped.ResponseAsync;
}
-
+
public async Task<_SetLengthResponse> SetLengthAsync(_SetLengthRequest request, CallOptions callOptions)
{
var wrapped = await _middlewares.WrapRequest(request, callOptions, (r, o) => _generatedClient.SetLengthAsync(r, o));
@@ -269,6 +269,7 @@ public class DataGrpcManager : IDisposable
internal DataGrpcManager(IConfiguration config, string authToken, string endpoint)
{
+ this._logger = config.LoggerFactory.CreateLogger();
#if USE_GRPC_WEB
// Note: all web SDK requests are routed to a `web.` subdomain to allow us flexibility on the server
endpoint = $"web.{endpoint}";
@@ -282,16 +283,20 @@ internal DataGrpcManager(IConfiguration config, string authToken, string endpoin
channelOptions.Credentials = ChannelCredentials.SecureSsl;
channelOptions.MaxReceiveMessageSize = Internal.Utils.DEFAULT_MAX_MESSAGE_SIZE;
channelOptions.MaxSendMessageSize = Internal.Utils.DEFAULT_MAX_MESSAGE_SIZE;
-
-#if USE_GRPC_WEB
+
+#if NET5_0_OR_GREATER
+ channelOptions.HttpHandler = new SocketsHttpHandler
+ {
+ EnableMultipleHttp2Connections = config.TransportStrategy.GrpcConfig.SocketsHttpHandlerOptions.EnableMultipleHttp2Connections,
+ PooledConnectionIdleTimeout = config.TransportStrategy.GrpcConfig.SocketsHttpHandlerOptions.PooledConnectionIdleTimeout
+ };
+#elif USE_GRPC_WEB
channelOptions.HttpHandler = new GrpcWebHandler(new HttpClientHandler());
#endif
this.channel = GrpcChannel.ForAddress(uri, channelOptions);
List headers = new List { new Header(name: Header.AuthorizationKey, value: authToken), new Header(name: Header.AgentKey, value: version), new Header(name: Header.RuntimeVersionKey, value: runtimeVersion) };
- this._logger = config.LoggerFactory.CreateLogger();
-
CallInvoker invoker = this.channel.CreateCallInvoker();
var middlewares = config.Middlewares.Concat(
@@ -305,7 +310,7 @@ internal DataGrpcManager(IConfiguration config, string authToken, string endpoin
var client = new Scs.ScsClient(invoker);
Client = new DataClientWithMiddleware(client, middlewares);
}
-
+
internal async Task EagerConnectAsync(TimeSpan eagerConnectionTimeout)
{
_logger.LogDebug("Attempting eager connection to server");
diff --git a/src/Momento.Sdk/Internal/LoggingUtils.cs b/src/Momento.Sdk/Internal/LoggingUtils.cs
index 82bc408b..a9df1380 100644
--- a/src/Momento.Sdk/Internal/LoggingUtils.cs
+++ b/src/Momento.Sdk/Internal/LoggingUtils.cs
@@ -379,8 +379,6 @@ public static TSuccess LogTraceCollectionRequestSuccess(this ILogger _
}
return success;
}
-
-#if NETSTANDARD2_0_OR_GREATER
///
/// Logs a message at TRACE level that indicates that a topic request is about to be executed.
@@ -396,7 +394,7 @@ public static void LogTraceExecutingTopicRequest(this ILogger logger, string req
logger.LogTrace("Executing '{}' request: cacheName: {}; topicName: {}", requestType, cacheName, topicName);
}
}
-
+
///
/// Logs a message at TRACE level that indicates that a topic request resulted in an error.
///
@@ -435,7 +433,7 @@ public static TSuccess LogTraceTopicRequestSuccess(this ILogger logger
}
return success;
}
-
+
///
/// Logs a message at TRACE level that indicates that a topic message was received.
///
@@ -450,7 +448,7 @@ public static void LogTraceTopicMessageReceived(this ILogger logger, string mess
logger.LogTrace("Received '{}' message on: cacheName: {}; topicName: {}", messageType, cacheName, topicName);
}
}
-
+
///
/// Logs a message at TRACE level that indicates that a discontinuity was received.
///
@@ -466,7 +464,7 @@ public static void LogTraceTopicDiscontinuityReceived(this ILogger logger, strin
logger.LogTrace("Received discontinuity: cacheName: {}; topicName: {}, lastSequenceNumber: {}, newSequenceNumber: {}", cacheName, topicName, lastSequenceNumber, newSequenceNumber);
}
}
-
+
///
/// Logs a message at TRACE level that indicates that a topic subscription received an error.
///
@@ -484,7 +482,6 @@ public static TError LogTraceTopicSubscriptionError(this ILogger logger,
}
return error;
}
-#endif
///
/// Logs a message at TRACE level that indicates that an request is about to be executed.
@@ -565,7 +562,7 @@ public static TError LogTraceVectorIndexRequestError(this ILogger logger
}
return error;
}
-
+
///
/// Logs a message at TRACE level that indicates that a vector index request resulted in a success.
///
diff --git a/src/Momento.Sdk/Internal/ScsControlClient.cs b/src/Momento.Sdk/Internal/ScsControlClient.cs
index c7bf653a..9ec7e952 100644
--- a/src/Momento.Sdk/Internal/ScsControlClient.cs
+++ b/src/Momento.Sdk/Internal/ScsControlClient.cs
@@ -3,6 +3,7 @@
using Grpc.Core;
using Microsoft.Extensions.Logging;
using Momento.Protos.ControlClient;
+using Momento.Sdk.Config;
using Momento.Sdk.Exceptions;
using Momento.Sdk.Responses;
@@ -17,12 +18,12 @@ internal sealed class ScsControlClient : IDisposable
private readonly ILogger _logger;
private readonly CacheExceptionMapper _exceptionMapper;
- public ScsControlClient(ILoggerFactory loggerFactory, string authToken, string endpoint)
+ public ScsControlClient(IConfiguration config, string authToken, string endpoint)
{
- this.grpcManager = new ControlGrpcManager(loggerFactory, authToken, endpoint);
+ this.grpcManager = new ControlGrpcManager(config, authToken, endpoint);
this.authToken = authToken;
- this._logger = loggerFactory.CreateLogger();
- this._exceptionMapper = new CacheExceptionMapper(loggerFactory);
+ this._logger = config.LoggerFactory.CreateLogger();
+ this._exceptionMapper = new CacheExceptionMapper(config.LoggerFactory);
}
public async Task CreateCacheAsync(string cacheName)
diff --git a/src/Momento.Sdk/Internal/ScsTopicClient.cs b/src/Momento.Sdk/Internal/ScsTopicClient.cs
index 75c53df3..bfabbbfc 100644
--- a/src/Momento.Sdk/Internal/ScsTopicClient.cs
+++ b/src/Momento.Sdk/Internal/ScsTopicClient.cs
@@ -1,7 +1,5 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-#if NETSTANDARD2_0_OR_GREATER
-
using System;
using System.Threading;
using System.Threading.Tasks;
@@ -287,4 +285,3 @@ public void Dispose()
}
}
}
-#endif
diff --git a/src/Momento.Sdk/Internal/TopicGrpcManager.cs b/src/Momento.Sdk/Internal/TopicGrpcManager.cs
index f2753af5..c58f869c 100644
--- a/src/Momento.Sdk/Internal/TopicGrpcManager.cs
+++ b/src/Momento.Sdk/Internal/TopicGrpcManager.cs
@@ -1,7 +1,5 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
-#if NETSTANDARD2_0_OR_GREATER
-
using System;
using System.Collections.Generic;
using System.Linq;
@@ -135,4 +133,3 @@ public void Dispose()
GC.SuppressFinalize(this);
}
}
-#endif
diff --git a/src/Momento.Sdk/Momento.Sdk.csproj b/src/Momento.Sdk/Momento.Sdk.csproj
index e5372f84..4aea7550 100644
--- a/src/Momento.Sdk/Momento.Sdk.csproj
+++ b/src/Momento.Sdk/Momento.Sdk.csproj
@@ -2,11 +2,9 @@
- netstandard2.0;net461
+ netstandard2.0;net6.0;net462
latest
enable
-
- true
true
@@ -33,9 +31,9 @@
-
+ Dependency resolution: .NET Framework binaries or libraries >= v4.62 that link
+ to Momento.Sdk will link to the .NET Framework 4.62 build. -->
+
USE_GRPC_WEB
diff --git a/src/Momento.Sdk/Responses/TopicMessage.cs b/src/Momento.Sdk/Responses/TopicMessage.cs
index 2863864d..3b2284bf 100644
--- a/src/Momento.Sdk/Responses/TopicMessage.cs
+++ b/src/Momento.Sdk/Responses/TopicMessage.cs
@@ -1,5 +1,3 @@
-#if NETSTANDARD2_0_OR_GREATER
-
using Momento.Protos.CacheClient.Pubsub;
using Momento.Sdk.Exceptions;
@@ -53,14 +51,14 @@ public Text(_TopicValue topicValue, string? tokenId = null)
/// The text value of this message.
///
public string Value { get; }
-
+
///
/// The TokenId that was used to publish the message, or null if the token did not have an id.
/// This can be used to securely identify the sender of a message.
///
public string? TokenId { get; }
}
-
+
///
/// A topic message containing a binary value.
///
@@ -79,7 +77,7 @@ public Binary(_TopicValue topicValue, string? tokenId = null)
/// The binary value of this message.
///
public byte[] Value { get; }
-
+
///
/// The TokenId that was used to publish the message, or null if the token did not have an id.
/// This can be used to securely identify the sender of a message.
@@ -115,4 +113,3 @@ public override string ToString()
}
}
-#endif
\ No newline at end of file
diff --git a/src/Momento.Sdk/Responses/TopicPublishResponse.cs b/src/Momento.Sdk/Responses/TopicPublishResponse.cs
index f39987e8..c7c5dd4a 100644
--- a/src/Momento.Sdk/Responses/TopicPublishResponse.cs
+++ b/src/Momento.Sdk/Responses/TopicPublishResponse.cs
@@ -1,5 +1,3 @@
-#if NETSTANDARD2_0_OR_GREATER
-
using Momento.Sdk.Exceptions;
namespace Momento.Sdk.Responses;
@@ -32,7 +30,7 @@ namespace Momento.Sdk.Responses;
public abstract class TopicPublishResponse
{
///
- public class Success : TopicPublishResponse {}
+ public class Success : TopicPublishResponse { }
///
public class Error : TopicPublishResponse, IError
@@ -62,4 +60,3 @@ public override string ToString()
}
}
-#endif
\ No newline at end of file
diff --git a/src/Momento.Sdk/Responses/TopicSubscribeResponse.cs b/src/Momento.Sdk/Responses/TopicSubscribeResponse.cs
index a26e438d..da268546 100644
--- a/src/Momento.Sdk/Responses/TopicSubscribeResponse.cs
+++ b/src/Momento.Sdk/Responses/TopicSubscribeResponse.cs
@@ -1,5 +1,3 @@
-#if NETSTANDARD2_0_OR_GREATER
-
using System;
using System.Collections.Generic;
using System.Threading;
@@ -103,7 +101,7 @@ public async ValueTask MoveNextAsync()
Current = null;
return false;
}
-
+
var nextMessage = await _moveNextFunction.Invoke(_enumeratorCancellationToken);
switch (nextMessage)
{
@@ -153,4 +151,3 @@ public override string ToString()
}
}
}
-#endif
\ No newline at end of file
diff --git a/src/Momento.Sdk/TopicClient.cs b/src/Momento.Sdk/TopicClient.cs
index a558b3bf..fb70cb4f 100644
--- a/src/Momento.Sdk/TopicClient.cs
+++ b/src/Momento.Sdk/TopicClient.cs
@@ -1,5 +1,3 @@
-#if NETSTANDARD2_0_OR_GREATER
-
using System;
using System.Threading.Tasks;
using Momento.Sdk.Auth;
@@ -16,8 +14,8 @@ namespace Momento.Sdk;
public class TopicClient : ITopicClient
{
private readonly ScsTopicClient scsTopicClient;
-
-
+
+
///
/// Client to perform operations against Momento topics.
///
@@ -74,11 +72,10 @@ public async Task SubscribeAsync(string cacheName, strin
}
return await scsTopicClient.Subscribe(cacheName, topicName, resumeAtSequenceNumber);
}
-
+
///
public void Dispose()
{
scsTopicClient.Dispose();
}
}
-#endif
\ No newline at end of file
diff --git a/tests/Integration/Momento.Sdk.Tests/AuthClientTopicTest.cs b/tests/Integration/Momento.Sdk.Tests/AuthClientTopicTest.cs
index 3b39b60b..35843770 100644
--- a/tests/Integration/Momento.Sdk.Tests/AuthClientTopicTest.cs
+++ b/tests/Integration/Momento.Sdk.Tests/AuthClientTopicTest.cs
@@ -1,5 +1,3 @@
-#if NET6_0_OR_GREATER
-
using System.Threading.Tasks;
using System.Threading;
using Momento.Sdk.Auth;
@@ -585,4 +583,3 @@ public async Task GenerateDisposableTopicAuthToken_MultiplePerms()
}
}
}
-#endif
diff --git a/tests/Integration/Momento.Sdk.Tests/Fixtures.cs b/tests/Integration/Momento.Sdk.Tests/Fixtures.cs
index 97ce8e16..abcf9772 100644
--- a/tests/Integration/Momento.Sdk.Tests/Fixtures.cs
+++ b/tests/Integration/Momento.Sdk.Tests/Fixtures.cs
@@ -52,13 +52,12 @@ public class CacheClientCollection : ICollectionFixture
}
-#if NET6_0_OR_GREATER
public class TopicClientFixture : IDisposable
{
public ITopicClient Client { get; private set; }
public ICredentialProvider AuthProvider { get; private set; }
-
+
public TopicClientFixture()
{
AuthProvider = new EnvMomentoTokenProvider("TEST_AUTH_TOKEN");
@@ -89,7 +88,6 @@ public class TopicClientCollection : ICollectionFixture
{
}
-#endif
public class AuthClientFixture : IDisposable
{
diff --git a/tests/Integration/Momento.Sdk.Tests/Momento.Sdk.Tests.Integration.csproj b/tests/Integration/Momento.Sdk.Tests/Momento.Sdk.Tests.Integration.csproj
index 184926a3..f406c94e 100644
--- a/tests/Integration/Momento.Sdk.Tests/Momento.Sdk.Tests.Integration.csproj
+++ b/tests/Integration/Momento.Sdk.Tests/Momento.Sdk.Tests.Integration.csproj
@@ -1,13 +1,10 @@
- net6.0;net461
+ net6.0;net462
false
enable
latest
-
- true
diff --git a/tests/Unit/Momento.Sdk.Tests/Momento.Sdk.Tests.Unit.csproj b/tests/Unit/Momento.Sdk.Tests/Momento.Sdk.Tests.Unit.csproj
index f92b120f..813fab06 100644
--- a/tests/Unit/Momento.Sdk.Tests/Momento.Sdk.Tests.Unit.csproj
+++ b/tests/Unit/Momento.Sdk.Tests/Momento.Sdk.Tests.Unit.csproj
@@ -1,13 +1,10 @@
- net6.0;net461
+ net6.0;net462
false
enable
latest
-
- true