Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion benchmarks/ClusterBenchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public static class Program

public static async Task Main(string[] args)
{
//AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
// ThreadPool.SetMinThreads(500, 500);
Request = new HelloRequest();
Configuration.SetupLogger(LogLevel.Error);
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/GossipBenchmark/Node1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ private static async Task Main()
);
var logger = Log.CreateLogger("benchmark");

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var system = new ActorSystem(
new ActorSystemConfig()
.WithDeveloperSupervisionLogging(true)
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/GossipBenchmark/Node2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ private static async Task Main()

var logger = Log.CreateLogger("benchmark");

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
var system = new ActorSystem(
new ActorSystemConfig()
.WithDeveloperSupervisionLogging(true)
Expand Down
3 changes: 0 additions & 3 deletions benchmarks/RemoteBenchmark/Node1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ private static async Task Main()
);

var logger = Log.CreateLogger<Program>();
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif

var serverRemote = 0;

Expand Down
3 changes: 0 additions & 3 deletions examples/ClusterGrainHelloWorld/Node1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@
Log.SetLoggerFactory(
LoggerFactory.Create(l => l.AddConsole().SetMinimumLevel(LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var system = new ActorSystem()
.WithRemote(RemoteConfig.BindToLocalhost().WithProtoMessages(ProtosReflection.Descriptor))
.WithCluster(ClusterConfig
Expand Down
3 changes: 0 additions & 3 deletions examples/ClusterGrainHelloWorld/Node2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@
Log.SetLoggerFactory(
LoggerFactory.Create(l => l.AddConsole().SetMinimumLevel(LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
// AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var system = new ActorSystem(new ActorSystemConfig().WithDeveloperSupervisionLogging(true))
.WithRemote(RemoteConfig.BindToLocalhost(8090).WithProtoMessages(ProtosReflection.Descriptor))
.WithCluster(ClusterConfig
Expand Down
3 changes: 0 additions & 3 deletions examples/ClusterK8sGrains/Node1/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@
.AddFilter("Proto.Cluster.Gossip", LogLevel.Information)
.AddFilter("Proto.Context.ActorContext", LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var kubernetesProvider = new KubernetesProvider();
var advertisedHost = await kubernetesProvider.GetPodFqdn();

Expand Down
3 changes: 0 additions & 3 deletions examples/ClusterK8sGrains/Node2/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
.AddFilter("Proto.Cluster.Gossip", LogLevel.Information)
.AddFilter("Proto.Context.ActorContext", LogLevel.Information)));

// Required to allow unencrypted GrpcNet connections
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);

var kubernetesProvider = new KubernetesProvider();
var advertisedHost = await kubernetesProvider.GetPodFqdn();

Expand Down
15 changes: 2 additions & 13 deletions src/Proto.Actor/Timers/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ namespace Proto.Timers;
public class Scheduler
{
private readonly ISenderContext _context;
#if NET8_0_OR_GREATER
private readonly TimeProvider _timeProvider;
#endif

/// <summary>
/// Creates a new scheduler.
Expand All @@ -28,13 +26,9 @@ public class Scheduler
public Scheduler(ISenderContext context)
{
_context = context;

#if NET8_0_OR_GREATER
_timeProvider = TimeProvider.System;
#endif
}

#if NET8_0_OR_GREATER
/// <summary>
/// Creates a new scheduler.
/// </summary>
Expand All @@ -45,7 +39,6 @@ public Scheduler(ISenderContext context, TimeProvider timeProvider)
_context = context;
_timeProvider = timeProvider;
}
#endif

/// <summary>
/// Schedules a single message to be sent in the future.
Expand Down Expand Up @@ -141,10 +134,6 @@ public CancellationTokenSource RequestRepeatedly(TimeSpan delay, TimeSpan interv

private async Task Delay(TimeSpan delay, CancellationToken token)
{
#if NET8_0_OR_GREATER
await Task.Delay(delay, _timeProvider, token).ConfigureAwait(false);
#else
await Task.Delay(delay, token).ConfigureAwait(false);
#endif
await Task.Delay(delay, _timeProvider, token).ConfigureAwait(false);
}
}
}
6 changes: 2 additions & 4 deletions src/Proto.Actor/Timers/TimerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ public static class TimerExtensions
/// <param name="context"></param>
/// <returns></returns>
public static Scheduler Scheduler(this ISenderContext context) => new(context);

#if NET8_0_OR_GREATER

/// <summary>
/// Gets a new scheduler that allows to schedule messages in the future
/// </summary>
/// <param name="context">Context to send the scheduled message through</param>
/// <param name="timeProvider">TimeProvider to use for scheduling (FakeTimeProvider can be used for testing)</param>
/// <returns></returns>
public static Scheduler Scheduler(this ISenderContext context, TimeProvider timeProvider) => new(context, timeProvider);
#endif
}
}
3 changes: 1 addition & 2 deletions tests/Proto.Actor.Tests/SchedulerTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#if NET8_0_OR_GREATER
using System;
using System.Threading.Tasks;
using System.Threading;
Expand Down Expand Up @@ -178,4 +177,4 @@ public async Task RequestRepeatedlyCanBeCancelled()
Assert.False(extraResponse.Task.IsCompleted);
}
}
#endif

5 changes: 1 addition & 4 deletions tests/Proto.Actor.Tests/TimerExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
using System.Threading.Tasks;
using Proto.Timers;
using Xunit;
#if NET8_0_OR_GREATER
using Microsoft.Extensions.Time.Testing;
#endif

namespace Proto.Tests;

Expand Down Expand Up @@ -38,7 +36,6 @@ public async Task SchedulerSchedulesMessageAfterDelay()
await tcs.Task.WaitAsync(TimeSpan.FromSeconds(5));
}

#if NET8_0_OR_GREATER
[Fact]
public async Task SchedulerWithTimeProviderSchedulesMessageAfterDelay()
{
Expand Down Expand Up @@ -67,5 +64,5 @@ public async Task SchedulerWithTimeProviderSchedulesMessageAfterDelay()

await tcs.Task.WaitAsync(TimeSpan.FromMilliseconds(10));
}
#endif
}

6 changes: 2 additions & 4 deletions tests/Proto.Cluster.MongoIdentity.Tests/MongoIdentityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public class MongoIdentityClusterFixture : BaseInMemoryClusterFixture
public MongoIdentityClusterFixture() : base(3,
config => config with { ActorActivationTimeout = TimeSpan.FromSeconds(10) })
{
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
}

protected override IIdentityLookup GetIdentityLookup(string clusterName)
Expand Down Expand Up @@ -95,4 +92,5 @@ public MongoStorageTests(ITestOutputHelper testOutputHelper) : base(Init, testOu

private static IIdentityStorage Init(string clusterName) => new MongoIdentityStorage(clusterName,
MongoFixture.Database.GetCollection<PidLookupEntity>("pids"));
}
}

6 changes: 2 additions & 4 deletions tests/Proto.Cluster.RedisIdentity.Tests/RedisIdentityTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ public class RedisIdentityClusterFixture : BaseInMemoryClusterFixture
{
public RedisIdentityClusterFixture() : base(3)
{
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
}

protected override IIdentityLookup GetIdentityLookup(string clusterName)
Expand Down Expand Up @@ -94,4 +91,5 @@ private static IIdentityStorage Init(string clusterName) =>
RedisFixture.Multiplexer,
TimeSpan.FromMilliseconds(1500)
);
}
}

12 changes: 2 additions & 10 deletions tests/Proto.Remote.Tests/RemoteFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ protected static TRemoteConfig ConfigureClientRemoteConfig<TRemoteConfig>(TRemot

protected static (IHost, HostedGrpcNetRemote) GetHostedGrpcNetRemote(RemoteConfig config)
{
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
var hostBuilder = Host.CreateDefaultBuilder(Array.Empty<string>())
.ConfigureServices(services =>
{
Expand Down Expand Up @@ -120,17 +117,12 @@ protected static (IHost, HostedGrpcNetRemote) GetHostedGrpcNetRemote(RemoteConfi

protected static GrpcNetRemote GetGrpcNetRemote(RemoteConfig config)
{
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
return new GrpcNetRemote(new ActorSystem(), config);
}

protected static GrpcNetClientRemote GetGrpcNetClientRemote(RemoteConfig config)
{
#if NETCOREAPP3_1
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
return new GrpcNetClientRemote(new ActorSystem(), config);
}
}
}

Loading