├── VERSION ├── .nuget ├── NuGet.exe └── NuGet.Config ├── tools └── nunit │ ├── nunit.exe │ ├── nunit-x86.exe │ ├── lib │ ├── log4net.dll │ ├── nunit.core.dll │ ├── nunit.util.dll │ ├── Images │ │ ├── pinned.gif │ │ ├── Ellipsis.gif │ │ ├── unpinned.gif │ │ └── Tree │ │ │ ├── Circles │ │ │ ├── Failure.jpg │ │ │ ├── Ignored.jpg │ │ │ ├── Skipped.jpg │ │ │ ├── Success.jpg │ │ │ └── Inconclusive.jpg │ │ │ ├── Classic │ │ │ ├── Failure.jpg │ │ │ ├── Ignored.jpg │ │ │ ├── Skipped.jpg │ │ │ ├── Success.jpg │ │ │ └── Inconclusive.jpg │ │ │ ├── Default │ │ │ ├── Failure.png │ │ │ ├── Ignored.png │ │ │ ├── Skipped.png │ │ │ ├── Success.png │ │ │ └── Inconclusive.png │ │ │ └── Visual Studio │ │ │ ├── Failure.png │ │ │ ├── Ignored.png │ │ │ ├── Skipped.png │ │ │ ├── Success.png │ │ │ ├── Inconclusive.png │ │ │ └── SeriousWarning.png │ ├── NSubstitute.dll │ ├── Rhino.Mocks.dll │ ├── nunit.uikit.dll │ ├── nunit-gui-runner.dll │ ├── nunit.uiexception.dll │ ├── nunit-console-runner.dll │ └── nunit.core.interfaces.dll │ ├── nunit-agent.exe │ ├── nunit-editor.exe │ ├── pnunit-agent.exe │ ├── pnunit.tests.dll │ ├── nunit-console.exe │ ├── nunit-agent-x86.exe │ ├── nunit-console-x86.exe │ ├── nunit.framework.dll │ ├── pnunit-launcher.exe │ ├── pnunit.framework.dll │ ├── runpnunit.bat │ ├── agent.conf │ ├── tests │ ├── mock-assembly.dll │ ├── test-assembly.dll │ ├── nunit-gui.tests.dll │ ├── nunit.core.tests.dll │ ├── nunit.framework.dll │ ├── nunit.util.tests.dll │ ├── test-utilities.dll │ ├── nunit-editor.tests.dll │ ├── nunit.mocks.tests.dll │ ├── nunit.uikit.tests.dll │ ├── nonamespace-assembly.dll │ ├── nunit-console.tests.dll │ ├── nunit.framework.tests.dll │ └── nunit.uiexception.tests.dll │ ├── framework │ ├── nunit.mocks.dll │ ├── nunit.framework.dll │ └── pnunit.framework.dll │ ├── agent.log.conf │ ├── launcher.log.conf │ ├── NUnitTests.nunit │ ├── nunit.exe.config │ ├── nunit-x86.exe.config │ ├── nunit-console.exe.config │ ├── nunit-console-x86.exe.config │ ├── nunit-agent.exe.config │ └── nunit-agent-x86.exe.config ├── benchmark ├── Helios.Tests.Performance │ ├── packages.config │ ├── Socket │ │ ├── TcpThroughputSpec.cs │ │ └── UdpThroughputSpec.cs │ ├── Channels │ │ ├── CounterHandlerInbound.cs │ │ ├── CounterHandlerOutbound.cs │ │ ├── ReadFinishedHandler.cs │ │ └── IReadFinishedSignal.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.HorizontalScaling.Performance │ ├── packages.config │ └── Channels │ │ └── ErrorCounterHandler.cs ├── Helios.Benchmark.TCPThroughput │ ├── App.config │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.Benchmark.DedicatedThreadFiber │ └── App.config └── Helios.Benchmark.SocketReliability │ ├── App.config │ └── Properties │ └── AssemblyInfo.cs ├── samples ├── Helios.RawSocket │ ├── App.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ └── AssemblyInfo.cs │ └── Program.cs ├── Helios.RawUdpSocket │ ├── App.config │ ├── Properties │ │ ├── Settings.settings │ │ ├── Settings.Designer.cs │ │ └── AssemblyInfo.cs │ └── Program.cs ├── TimeService │ ├── TimeServiceClient │ │ ├── App.config │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ └── TimeServiceServer │ │ ├── App.config │ │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.Samples.TcpDownloadServer │ ├── App.config │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.Samples.TcpReactorServer │ └── App.config ├── Helios.Samples.UdpPerformanceTest │ └── App.config └── Helios.Samples.UdpReactorServer │ └── App.config ├── src ├── SharedAssemblyInfo.cs └── Helios │ ├── Channels │ ├── IChannelId.cs │ ├── ConnectionPendingException.cs │ ├── AlreadyConnectedException.cs │ ├── SkipAttribute.cs │ ├── Sockets │ │ ├── IServerSocketChannelConfiguration.cs │ │ ├── IServerSocketChannel.cs │ │ ├── ISocketChannel.cs │ │ ├── ISocketChannelConfiguration.cs │ │ └── SocketChannelAsyncOperation.cs │ ├── ConnectException.cs │ ├── Embedded │ │ ├── EmbeddedSocketAddress.cs │ │ └── EmbeddedChannelId.cs │ ├── IEventLoopGroup.cs │ ├── IServerChannel.cs │ ├── ClosedChannelException.cs │ ├── NotYetConnectedException.cs │ ├── ConnectTimeoutException.cs │ ├── Bootstrap │ │ ├── INameResolver.cs │ │ └── DefaultNameResolver.cs │ ├── ChannelException.cs │ ├── IRecvByteBufAllocator.cs │ ├── ChannelPipelineException.cs │ ├── DefaultChannelHandlerContext.cs │ ├── ActionChannelInitializer.cs │ ├── IMessageSizeEstimator.cs │ ├── IChannelUnsafe.cs │ ├── IChannelConfiguration.cs │ ├── IRecvByteBufferAllocatorHandle.cs │ ├── DefaultChannelId.cs │ ├── SingleThreadEventLoop.cs │ ├── DefaultConnectionConfig.cs │ ├── IChannel.cs │ └── FixedRecvByteBufAllocator.cs │ ├── Concurrency │ ├── IScheduledRunnable.cs │ ├── FiberMode.cs │ ├── IEventLoop.cs │ ├── IRunnable.cs │ ├── IScheduledTask.cs │ ├── RejectedTaskException.cs │ ├── ActionScheduledTask.cs │ ├── ActionWithStateScheduledTask.cs │ ├── ActionScheduledAsyncTask.cs │ ├── IPausableEventExecutor.cs │ ├── ActionWithStateScheduledAsyncTask.cs │ ├── ActionWithStateAndContextScheduledTask.cs │ ├── ActionWithStateAndContextScheduledAsyncTask.cs │ ├── PromiseUtil.cs │ ├── ScheduledAsyncTask.cs │ └── TaskCompletionSource.cs │ ├── Exceptions │ ├── ExceptionType.cs │ ├── Events │ │ ├── ExceptionEventArgs.cs │ │ └── ExceptionTopicSubscription.cs │ ├── HeliosConnectionException.cs │ └── HeliosNodeException.cs │ ├── Serialization │ ├── ByteOrder.cs │ ├── ITransportSerializer.cs │ └── Encoders.cs │ ├── Buffers │ ├── ByteOrder.cs │ ├── IByteBufAllocator.cs │ ├── UnpooledByteBufAllocator.cs │ └── Unpooled.cs │ ├── HeliosException.cs │ ├── Net │ ├── IConnectionBuilder.cs │ ├── NetworkDataExtensions.cs │ ├── Bootstrap │ │ ├── IConnectionFactory.cs │ │ ├── TcpConnectionFactory.cs │ │ └── UdpConnectionFactory.cs │ ├── IConnectionExtensions.cs │ ├── MulticastHelper.cs │ └── Transports │ │ └── ITransport.cs │ ├── Eventing │ ├── ITopicSubscription.cs │ ├── Subscriptions │ │ ├── TopicHelpers.cs │ │ └── NormalTopicSubscription.cs │ ├── EventSubscriptionEventArgs.cs │ └── IEventBroker.cs │ ├── Logging │ ├── StandardOutLoggerFactory.cs │ ├── NoOpLoggerFactory.cs │ ├── LogLevel.cs │ └── NoOpLogger.cs │ ├── Ops │ ├── IEventLoop.cs │ ├── EventLoopFactory.cs │ ├── Executors │ │ └── ThreadedEventLoop.cs │ ├── OperationResult.cs │ └── IOperationResult.cs │ ├── Helios.nuspec │ ├── Reactor │ ├── Bootstrap │ │ ├── IServerFactory.cs │ │ ├── UdpServerFactory.cs │ │ └── TcpServerFactory.cs │ └── Response │ │ └── ReactorProxyResponseChannel.cs │ ├── Util │ ├── BitOps.cs │ ├── Collections │ │ ├── DictionaryExtensions.cs │ │ ├── CollectionExtensions.cs │ │ └── IFixedSizeStack.cs │ ├── ThreadLocalRandom.cs │ ├── RecyclableArrayList.cs │ ├── FlagsHelper.cs │ ├── IpHelper.cs │ └── NullGuard.cs │ ├── Topology │ ├── EmptyNode.cs │ ├── NodeExtensions.cs │ └── INode.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── Tracing │ └── HeliosTrace.cs ├── tests ├── Helios.Tests │ ├── Concurrency │ │ └── EventLoopGroupSpecs.cs │ ├── packages.config │ ├── Util │ │ ├── Collections │ │ │ ├── ConcurrentCircularBufferTests.cs │ │ │ └── CircularBufferTests.cs │ │ └── TimedOps │ │ │ └── PreciseDeadlineSpecs.cs │ ├── Buffer │ │ ├── BasicByteBufTests.cs │ │ └── ByteBufferDerivationSpecs.cs │ ├── Channels │ │ ├── Bootstrap │ │ │ ├── BootstrapSpecs.cs │ │ │ └── TcpBootstrapSpec.cs │ │ ├── ReadCountAwaiter.cs │ │ └── IntCodec.cs │ ├── Codecs │ │ └── MessageToMessageEncoderSpecs.cs │ ├── Net │ │ ├── MulticastHelperTests.cs │ │ └── NodeUniquenessTests.cs │ ├── Topology │ │ └── NodeTests.cs │ ├── Ops │ │ └── NetworkEventLoopTests.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.FsCheck.Tests │ ├── app.config │ ├── Channels │ │ ├── Sockets │ │ │ ├── Models │ │ │ │ ├── ConnectionState.cs │ │ │ │ └── ITcpServerSocketModel.cs │ │ │ └── TcpSocketServerSpecs.cs │ │ └── TestChannel.cs │ ├── HeliosModelHelpers.cs │ ├── Buffers │ │ └── BufferHelpers.cs │ ├── packages.config │ ├── HeliosGenerators.cs │ ├── FsharpDelegateHelper.cs │ ├── TestLogger.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Helios.BackwardsCompat.Tests │ ├── packages.config │ └── Properties │ │ └── AssemblyInfo.cs └── Helios.MultiNodeTests │ ├── packages.config │ └── Properties │ └── AssemblyInfo.cs └── .gitignore /VERSION: -------------------------------------------------------------------------------- 1 | 1.3.5.0 -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/.nuget/NuGet.exe -------------------------------------------------------------------------------- /tools/nunit/nunit.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit.exe -------------------------------------------------------------------------------- /tools/nunit/nunit-x86.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-x86.exe -------------------------------------------------------------------------------- /tools/nunit/lib/log4net.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/log4net.dll -------------------------------------------------------------------------------- /tools/nunit/nunit-agent.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-agent.exe -------------------------------------------------------------------------------- /tools/nunit/nunit-editor.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-editor.exe -------------------------------------------------------------------------------- /tools/nunit/pnunit-agent.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/pnunit-agent.exe -------------------------------------------------------------------------------- /tools/nunit/pnunit.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/pnunit.tests.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit.core.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit.core.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit.util.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit.util.dll -------------------------------------------------------------------------------- /tools/nunit/nunit-console.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-console.exe -------------------------------------------------------------------------------- /tools/nunit/lib/Images/pinned.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/pinned.gif -------------------------------------------------------------------------------- /tools/nunit/lib/NSubstitute.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/NSubstitute.dll -------------------------------------------------------------------------------- /tools/nunit/lib/Rhino.Mocks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Rhino.Mocks.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit.uikit.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit.uikit.dll -------------------------------------------------------------------------------- /tools/nunit/nunit-agent-x86.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-agent-x86.exe -------------------------------------------------------------------------------- /tools/nunit/nunit-console-x86.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit-console-x86.exe -------------------------------------------------------------------------------- /tools/nunit/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/nunit.framework.dll -------------------------------------------------------------------------------- /tools/nunit/pnunit-launcher.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/pnunit-launcher.exe -------------------------------------------------------------------------------- /tools/nunit/pnunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/pnunit.framework.dll -------------------------------------------------------------------------------- /tools/nunit/runpnunit.bat: -------------------------------------------------------------------------------- 1 | start pnunit-agent 8080 . 2 | start pnunit-agent 8081 . 3 | pnunit-launcher test.conf 4 | -------------------------------------------------------------------------------- /tools/nunit/agent.conf: -------------------------------------------------------------------------------- 1 | 2 | 8080 3 | . 4 | -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Ellipsis.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Ellipsis.gif -------------------------------------------------------------------------------- /tools/nunit/lib/Images/unpinned.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/unpinned.gif -------------------------------------------------------------------------------- /tools/nunit/tests/mock-assembly.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/mock-assembly.dll -------------------------------------------------------------------------------- /tools/nunit/tests/test-assembly.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/test-assembly.dll -------------------------------------------------------------------------------- /tools/nunit/framework/nunit.mocks.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/framework/nunit.mocks.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit-gui-runner.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit-gui-runner.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit.uiexception.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit.uiexception.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit-gui.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit-gui.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.core.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.core.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.framework.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.util.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.util.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/test-utilities.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/test-utilities.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit-console-runner.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit-console-runner.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit-editor.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit-editor.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.mocks.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.mocks.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.uikit.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.uikit.tests.dll -------------------------------------------------------------------------------- /tools/nunit/framework/nunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/framework/nunit.framework.dll -------------------------------------------------------------------------------- /tools/nunit/framework/pnunit.framework.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/framework/pnunit.framework.dll -------------------------------------------------------------------------------- /tools/nunit/lib/nunit.core.interfaces.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/nunit.core.interfaces.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nonamespace-assembly.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nonamespace-assembly.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit-console.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit-console.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.framework.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.framework.tests.dll -------------------------------------------------------------------------------- /tools/nunit/tests/nunit.uiexception.tests.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/tests/nunit.uiexception.tests.dll -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Circles/Failure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Circles/Failure.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Circles/Ignored.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Circles/Ignored.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Circles/Skipped.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Circles/Skipped.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Circles/Success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Circles/Success.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Classic/Failure.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Classic/Failure.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Classic/Ignored.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Classic/Ignored.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Classic/Skipped.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Classic/Skipped.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Classic/Success.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Classic/Success.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Default/Failure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Default/Failure.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Default/Ignored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Default/Ignored.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Default/Skipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Default/Skipped.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Default/Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Default/Success.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Circles/Inconclusive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Circles/Inconclusive.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Classic/Inconclusive.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Classic/Inconclusive.jpg -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Default/Inconclusive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Default/Inconclusive.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/Failure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/Failure.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/Ignored.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/Ignored.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/Skipped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/Skipped.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/Success.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/Success.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/Inconclusive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/Inconclusive.png -------------------------------------------------------------------------------- /tools/nunit/lib/Images/Tree/Visual Studio/SeriousWarning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/helios-io/helios/HEAD/tools/nunit/lib/Images/Tree/Visual Studio/SeriousWarning.png -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /benchmark/Helios.HorizontalScaling.Performance/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /samples/Helios.RawSocket/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.RawUdpSocket/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/TimeService/TimeServiceClient/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/TimeService/TimeServiceServer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /benchmark/Helios.Benchmark.TCPThroughput/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.Samples.TcpDownloadServer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.Samples.TcpReactorServer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.Samples.UdpPerformanceTest/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.Samples.UdpReactorServer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /benchmark/Helios.Benchmark.DedicatedThreadFiber/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /benchmark/Helios.Benchmark.SocketReliability/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/Helios.RawSocket/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /samples/Helios.RawUdpSocket/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/SharedAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // 2 | using System.Reflection; 3 | 4 | [assembly: AssemblyCompanyAttribute("Helios Framework")] 5 | [assembly: AssemblyCopyrightAttribute("Copyright © Aaron Stannard 2013-2015")] 6 | [assembly: AssemblyVersionAttribute("2.1.2")] 7 | [assembly: AssemblyFileVersionAttribute("2.1.2")] 8 | -------------------------------------------------------------------------------- /tests/Helios.Tests/Concurrency/EventLoopGroupSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Tests.Concurrency 6 | { 7 | public class EventLoopGroupSpecs 8 | { 9 | } 10 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IChannelId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | public interface IChannelId : IComparable 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ConnectionPendingException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class ConnectionPendingException : Exception 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /src/Helios/Channels/AlreadyConnectedException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class AlreadyConnectedException : IOException 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /src/Helios/Channels/SkipAttribute.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | [AttributeUsage(AttributeTargets.Method)] 10 | public class SkipAttribute : Attribute 11 | { 12 | } 13 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/IScheduledRunnable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Concurrency 8 | { 9 | public interface IScheduledRunnable : IRunnable, IScheduledTask, IComparable 10 | { 11 | } 12 | } -------------------------------------------------------------------------------- /samples/Helios.Samples.TcpDownloadServer/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Samples.TcpDownloadServer 6 | { 7 | internal class Program 8 | { 9 | private static void Main(string[] args) 10 | { 11 | } 12 | } 13 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/FiberMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Concurrency 6 | { 7 | public enum FiberMode 8 | { 9 | Synchronous, 10 | MultiThreaded, 11 | SingleThreaded, 12 | MaximumConcurrency 13 | } 14 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Sockets/IServerSocketChannelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels.Sockets 6 | { 7 | public interface IServerSocketChannelConfiguration : IChannelConfiguration 8 | { 9 | int Backlog { get; set; } 10 | } 11 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Sockets/IServerSocketChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels.Sockets 6 | { 7 | public interface IServerSocketChannel : IServerChannel 8 | { 9 | new IServerSocketChannelConfiguration Configuration { get; } 10 | } 11 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Channels/Sockets/Models/ConnectionState.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.FsCheck.Tests.Channels.Sockets.Models 6 | { 7 | public enum ConnectionState 8 | { 9 | Connecting = 1 << 1, 10 | Active = 1 << 2, 11 | Shutdown = 1 << 3 12 | } 13 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ConnectException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class ConnectException : Exception 10 | { 11 | public ConnectException(string s, Exception exception) : base(s, exception) 12 | { 13 | } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Helios/Exceptions/ExceptionType.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Exceptions 6 | { 7 | public enum ExceptionType 8 | { 9 | Unknown, 10 | NotOpen, 11 | AlreadyOpen, 12 | TimedOut, 13 | EndOfFile, 14 | NotSupported, 15 | Closed 16 | } 17 | } -------------------------------------------------------------------------------- /src/Helios/Serialization/ByteOrder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Serialization 6 | { 7 | public enum ByteOrder 8 | { 9 | /// 10 | /// Default on most Windows systems 11 | /// 12 | LittleEndian = 0, 13 | BigEndian = 1 14 | } 15 | } -------------------------------------------------------------------------------- /tools/nunit/agent.log.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tools/nunit/launcher.log.conf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Helios/Channels/Embedded/EmbeddedSocketAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | 7 | namespace Helios.Channels.Embedded 8 | { 9 | internal sealed class EmbeddedSocketAddress : EndPoint 10 | { 11 | public override string ToString() 12 | { 13 | return "embedded"; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /tests/Helios.BackwardsCompat.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Helios/Buffers/ByteOrder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Buffers 6 | { 7 | public enum ByteOrder 8 | { 9 | /// 10 | /// Default on all X86 systems; backgwards compatible with previous Helios defaults. 11 | /// 12 | LittleEndian = 0, 13 | BigEndian = 1 14 | } 15 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Build output 2 | build*/ 3 | 4 | # FAKE output 5 | .fake/ 6 | 7 | #Ruby 8 | Gemfile.lock 9 | 10 | #nuget packages 11 | packages*/ 12 | 13 | #ignore thumbnails created by windows 14 | Thumbs.db 15 | #Ignore files build by Visual Studio 16 | *.obj 17 | *.exe 18 | *.pdb 19 | *.user 20 | *.aps 21 | *.pch 22 | *.vspscc 23 | *_i.c 24 | *_p.c 25 | *.ncb 26 | *.suo 27 | *.tlb 28 | *.tlh 29 | *.bak 30 | *.cache 31 | *.ilk 32 | *.log 33 | [Bb]in 34 | [Dd]ebug*/ 35 | *.lib 36 | *.sbr 37 | obj/ 38 | [Rr]elease*/ 39 | _ReSharper*/ 40 | [Pp]erf[Rr]esult* 41 | [Tt]est[Rr]esult* 42 | 43 | # Mono 44 | *.userprefs -------------------------------------------------------------------------------- /src/Helios/Channels/IEventLoopGroup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | using Helios.Concurrency; 7 | 8 | namespace Helios.Channels 9 | { 10 | public interface IEventLoopGroup 11 | { 12 | Task TerminationCompletion { get; } 13 | 14 | IEventLoop GetNext(); 15 | 16 | Task ShutdownGracefullyAsync(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IServerChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels 6 | { 7 | /// 8 | /// Marker interface for implementations which act as inbound 9 | /// receivers for connections from external clients. 10 | /// 11 | public interface IServerChannel : IChannel 12 | { 13 | } 14 | } -------------------------------------------------------------------------------- /src/Helios/HeliosException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios 8 | { 9 | public class HeliosException : Exception 10 | { 11 | public HeliosException() 12 | { 13 | } 14 | 15 | public HeliosException(string message, Exception inner = null) : base(message, inner) 16 | { 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Socket/TcpThroughputSpec.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | 7 | namespace Helios.Tests.Performance.Socket 8 | { 9 | public class TcpThroughputSpec : SocketThroughputSpec 10 | { 11 | public override TransportType TransportType 12 | { 13 | get { return TransportType.Tcp; } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Socket/UdpThroughputSpec.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | 7 | namespace Helios.Tests.Performance.Socket 8 | { 9 | public class UdpThroughputSpec : SocketThroughputSpec 10 | { 11 | public override TransportType TransportType 12 | { 13 | get { return TransportType.Tcp; } 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ClosedChannelException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class ClosedChannelException : IOException 10 | { 11 | public static readonly ClosedChannelException Instance = new ClosedChannelException(); 12 | 13 | private ClosedChannelException() 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/IEventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | using Helios.Channels; 7 | 8 | namespace Helios.Concurrency 9 | { 10 | public interface IEventLoop : IEventExecutor 11 | { 12 | IChannelHandlerInvoker Invoker { get; } 13 | 14 | Task RegisterAsync(IChannel channel); 15 | 16 | new IEventLoop Unwrap(); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Helios/Channels/NotYetConnectedException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class NotYetConnectedException : IOException 10 | { 11 | public static readonly NotYetConnectedException Instance = new NotYetConnectedException(); 12 | 13 | private NotYetConnectedException() 14 | { 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Helios/Net/IConnectionBuilder.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Net 9 | { 10 | /// 11 | /// Interface used for building connections 12 | /// 13 | public interface IConnectionBuilder 14 | { 15 | TimeSpan Timeout { get; } 16 | 17 | IConnection BuildConnection(INode node); 18 | } 19 | } -------------------------------------------------------------------------------- /tests/Helios.MultiNodeTests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /src/Helios/Channels/ConnectTimeoutException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class ConnectTimeoutException : IOException 10 | { 11 | public ConnectTimeoutException(string message) 12 | : base(message) 13 | { 14 | } 15 | 16 | public ConnectTimeoutException() 17 | { 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Sockets/ISocketChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels.Sockets 6 | { 7 | /// 8 | /// Marker interface for channels which use TCP / UDP sockets 9 | /// 10 | public interface ISocketChannel : IChannel 11 | { 12 | new IServerSocketChannel Parent { get; } 13 | new ISocketChannelConfiguration Configuration { get; } 14 | } 15 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/IRunnable.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | 7 | namespace Helios.Concurrency 8 | { 9 | /// 10 | /// Any aynchronous operation, whether it be a delegate, , etc, which will 11 | /// be executed later by an 12 | /// 13 | public interface IRunnable 14 | { 15 | void Run(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/IScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Runtime.CompilerServices; 6 | using System.Threading.Tasks; 7 | using Helios.Util.TimedOps; 8 | 9 | namespace Helios.Concurrency 10 | { 11 | public interface IScheduledTask 12 | { 13 | PreciseDeadline Deadline { get; } 14 | 15 | Task Completion { get; } 16 | bool Cancel(); 17 | 18 | TaskAwaiter GetAwaiter(); 19 | } 20 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Util/Collections/ConcurrentCircularBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Util.Collections; 6 | 7 | namespace Helios.Tests.Util.Collections 8 | { 9 | public class ConcurrentCircularBufferTests : CircularBufferTests 10 | { 11 | protected override ICircularBuffer GetBuffer(int capacity) 12 | { 13 | return new ConcurrentCircularBuffer(capacity); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /tools/nunit/NUnitTests.nunit: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Helios/Eventing/ITopicSubscription.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Eventing 8 | { 9 | /// 10 | /// A subscription object - exists primarily to make subscription callbacks 11 | /// refactorable in the future 12 | /// 13 | public interface ITopicSubscription 14 | { 15 | void Invoke(); 16 | 17 | void Invoke(object sender, EventArgs e); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Helios/Logging/StandardOutLoggerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Logging 6 | { 7 | /// 8 | /// Creates instances. 9 | /// 10 | public class StandardOutLoggerFactory : LoggingFactory 11 | { 12 | protected override ILogger NewInstance(string name, params LogLevel[] supportedLogLevels) 13 | { 14 | return new StdOutLogger(name); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Bootstrap/INameResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using System.Net.Sockets; 7 | using System.Threading.Tasks; 8 | 9 | namespace Helios.Channels.Bootstrap 10 | { 11 | public interface INameResolver 12 | { 13 | bool IsResolved(EndPoint address); 14 | 15 | Task ResolveAsync(EndPoint address); 16 | 17 | Task ResolveAsync(EndPoint address, AddressFamily preferredFamily); 18 | } 19 | } -------------------------------------------------------------------------------- /src/Helios/Buffers/IByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Buffers 6 | { 7 | /// 8 | /// Thread-safe interface for allocating instances for use inside Helios reactive I/O 9 | /// 10 | public interface IByteBufAllocator 11 | { 12 | IByteBuf Buffer(); 13 | 14 | IByteBuf Buffer(int initialCapcity); 15 | 16 | IByteBuf Buffer(int initialCapacity, int maxCapacity); 17 | } 18 | } -------------------------------------------------------------------------------- /src/Helios/Logging/NoOpLoggerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Logging 6 | { 7 | /// 8 | /// Factory for creating s, which don't actually log anything 9 | /// 10 | public class NoOpLoggerFactory : LoggingFactory 11 | { 12 | protected override ILogger NewInstance(string name, params LogLevel[] supportedLogLevels) 13 | { 14 | return NoOpLogger.Instance; 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /src/Helios/Net/NetworkDataExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | 7 | namespace Helios.Net 8 | { 9 | /// 10 | /// Extension methods for working with NetworkData objects - deals primarily with Stream conversion 11 | /// 12 | public static class NetworkDataExtensions 13 | { 14 | public static Stream ToStream(this NetworkData nd) 15 | { 16 | return new MemoryStream(nd.Buffer, 0, nd.Length); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Buffer/BasicByteBufTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Text; 6 | using Helios.Buffers; 7 | using Xunit; 8 | 9 | namespace Helios.Tests.Buffer 10 | { 11 | public class BasicByteBufTests 12 | { 13 | [Fact] 14 | public void Should_pretty_print_buffer() 15 | { 16 | var buf = Unpooled.Buffer(10).WriteBoolean(true).WriteInt(4); 17 | var str = buf.ToString(Encoding.ASCII); 18 | Assert.NotNull(str); 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Helios/Exceptions/Events/ExceptionEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Exceptions.Events 8 | { 9 | /// 10 | /// Event arguments used for topic subscriptions that subscribe to Exception Events 11 | /// 12 | public class ExceptionEventArgs : EventArgs 13 | { 14 | public ExceptionEventArgs(Exception ex) 15 | { 16 | Exception = ex; 17 | } 18 | 19 | public Exception Exception { get; protected set; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Helios/Eventing/Subscriptions/TopicHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Eventing.Subscriptions 8 | { 9 | /// 10 | /// Extension method class used to help create EventBroker 11 | /// topics from lambda methods 12 | /// 13 | public static class TopicHelpers 14 | { 15 | public static NormalTopicSubscription Subscription(this Action h) 16 | { 17 | return new NormalTopicSubscription(h); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ChannelException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | public class ChannelException : Exception 10 | { 11 | public ChannelException(Exception ex) : this("ChannelException", ex) 12 | { 13 | } 14 | 15 | public ChannelException(string message) : base(message) 16 | { 17 | } 18 | 19 | public ChannelException(string connectionRefused, Exception exception) : base(connectionRefused, exception) 20 | { 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Helios/Net/Bootstrap/IConnectionFactory.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | // Copyright (c) Petabridge . All rights reserved. 3 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 4 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 5 | using Helios.Topology; 6 | 7 | namespace Helios.Net.Bootstrap 8 | { 9 | /// 10 | /// Interface used for spawning new objects 11 | /// 12 | [Obsolete()] 13 | public interface IConnectionFactory 14 | { 15 | IConnection NewConnection(); 16 | 17 | IConnection NewConnection(INode remoteEndpoint); 18 | 19 | IConnection NewConnection(INode localEndpoint, INode remoteEndpoint); 20 | } 21 | } -------------------------------------------------------------------------------- /samples/Helios.RawSocket/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Windows.Forms; 7 | 8 | namespace Helios.RawSocket 9 | { 10 | internal static class Program 11 | { 12 | /// 13 | /// The main entry point for the application. 14 | /// 15 | [STAThread] 16 | private static void Main() 17 | { 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | Application.Run(new SocketClient()); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /samples/Helios.RawUdpSocket/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Windows.Forms; 7 | 8 | namespace Helios.RawUdpSocket 9 | { 10 | internal static class Program 11 | { 12 | /// 13 | /// The main entry point for the application. 14 | /// 15 | [STAThread] 16 | private static void Main() 17 | { 18 | Application.EnableVisualStyles(); 19 | Application.SetCompatibleTextRenderingDefault(false); 20 | Application.Run(new SocketClient()); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IRecvByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels 6 | { 7 | /// 8 | /// Allocates buffers for socket read and receive operations, with enough capacity to read all received 9 | /// data in one shot. 10 | /// 11 | public interface IRecvByteBufAllocator 12 | { 13 | /// 14 | /// Creates a new handle for estimating incoming receive buffer sizes and creating buffers 15 | /// based on those estimates. 16 | /// 17 | IRecvByteBufferAllocatorHandle NewHandle(); 18 | } 19 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/HeliosModelHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace Helios.FsCheck.Tests 9 | { 10 | public static class HeliosModelHelpers 11 | { 12 | public static List> Chunk(this List source, int chunkSize) 13 | { 14 | var list = new List>(); 15 | for (var i = 0; i < source.Count; i = i + chunkSize) 16 | { 17 | list.Add(source.GetRange(i, Math.Min(chunkSize, source.Count - i))); 18 | } 19 | return list; 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/RejectedTaskException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Concurrency 8 | { 9 | /// 10 | /// An exception thrown when a is asked to a queue a task 11 | /// when it is no longer accepting work. 12 | /// 13 | public class RejectedTaskException : Exception 14 | { 15 | public static readonly RejectedTaskException Instance = new RejectedTaskException(); 16 | 17 | public RejectedTaskException() : base("Not accepting new work at this time!") 18 | { 19 | } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Helios/Ops/IEventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Ops 8 | { 9 | /// 10 | /// Interface used for creating chained eventloops 11 | /// for processing network streams / events 12 | /// 13 | public interface IEventLoop : IExecutor, IDisposable 14 | { 15 | /// 16 | /// Was this event loop disposed? 17 | /// 18 | bool WasDisposed { get; } 19 | 20 | /// 21 | /// Return the next executor in the chain 22 | /// 23 | IExecutor Next(); 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ChannelPipelineException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels 8 | { 9 | /// 10 | /// Exception thrown whenever there's an issue modifying the 11 | /// 12 | public class ChannelPipelineException : Exception 13 | { 14 | public ChannelPipelineException(string message) 15 | : base(message) 16 | { 17 | } 18 | 19 | public ChannelPipelineException(string message, Exception innerException) 20 | : base(message, innerException) 21 | { 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Helios/Helios.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | @project@ 5 | @project@@title@ 6 | @build.number@ 7 | @authors@ 8 | @authors@ 9 | @description@ 10 | https://github.com/helios-io/helios/blob/master/LICENSE 11 | https://github.com/helios-io/helios 12 | false 13 | @releaseNotes@ 14 | @copyright@ 15 | @tags@ 16 | @dependencies@ 17 | @references@ 18 | 19 | -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Buffers/BufferHelpers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.FsCheck.Tests.Buffers 6 | { 7 | public static class BufferHelpers 8 | { 9 | public static string PrintByteArray(byte[] bytes) 10 | { 11 | return "byte[" + string.Join("|", bytes) + "]"; 12 | } 13 | 14 | public static object PrintByteBufferItem(object item) 15 | { 16 | if (item is byte[]) 17 | { 18 | var bytes = item as byte[]; 19 | return PrintByteArray(bytes); 20 | } 21 | 22 | return item; 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Eventing/EventSubscriptionEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Eventing 8 | { 9 | public class EventSubscriptionEventArgs : EventArgs 10 | { 11 | public EventSubscriptionEventArgs(TTopic topic, TSubscriber subscriber, int subscriberCount) 12 | { 13 | Topic = topic; 14 | SubscriberCount = subscriberCount; 15 | } 16 | 17 | public TTopic Topic { get; protected set; } 18 | 19 | public TSubscriber Subscriber { get; protected set; } 20 | 21 | public int SubscriberCount { get; protected set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Util.TimedOps; 7 | 8 | namespace Helios.Concurrency 9 | { 10 | internal sealed class ActionScheduledTask : ScheduledTask 11 | { 12 | private readonly Action _action; 13 | 14 | public ActionScheduledTask(AbstractScheduledEventExecutor executor, Action action, PreciseDeadline deadline) 15 | : base(executor, deadline, new TaskCompletionSource()) 16 | { 17 | _action = action; 18 | } 19 | 20 | protected override void Execute() 21 | { 22 | _action(); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Reactor/Bootstrap/IServerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 7 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 8 | using Helios.Net.Bootstrap; 9 | using Helios.Topology; 10 | 11 | namespace Helios.Reactor.Bootstrap 12 | { 13 | /// 14 | /// Factory interface for creating new instances 15 | /// 16 | [Obsolete()] 17 | public interface IServerFactory : IConnectionFactory 18 | { 19 | IReactor NewReactor(INode listenAddress); 20 | } 21 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Sockets/ISocketChannelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels.Sockets 6 | { 7 | /// 8 | /// specific to sockets. 9 | /// 10 | public interface ISocketChannelConfiguration : IChannelConfiguration 11 | { 12 | bool AllowHalfClosure { get; set; } 13 | 14 | int Linger { get; set; } 15 | 16 | int SendBufferSize { get; set; } 17 | 18 | int ReceiveBufferSize { get; set; } 19 | 20 | bool ReuseAddress { get; set; } 21 | 22 | bool KeepAlive { get; set; } 23 | 24 | bool TcpNoDelay { get; set; } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Helios/Util/BitOps.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Runtime.CompilerServices; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Helios.Util 13 | { 14 | public static class BitOps 15 | { 16 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 17 | public static int RightUShift(this int value, int bits) => unchecked((int) ((uint) value >> bits)); 18 | 19 | [MethodImpl(MethodImplOptions.AggressiveInlining)] 20 | public static long RightUShift(this long value, int bits) => unchecked((long) ((ulong) value >> bits)); 21 | } 22 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Channels/CounterHandlerInbound.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Channels; 6 | using NBench; 7 | 8 | namespace Helios.Tests.Performance.Channels 9 | { 10 | internal class CounterHandlerInbound : ChannelHandlerAdapter 11 | { 12 | private readonly Counter _throughput; 13 | 14 | public CounterHandlerInbound(Counter throughput) 15 | { 16 | _throughput = throughput; 17 | } 18 | 19 | public override void ChannelRead(IChannelHandlerContext context, object message) 20 | { 21 | _throughput.Increment(); 22 | context.FireChannelRead(message); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Channels/DefaultChannelHandlerContext.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Diagnostics.Contracts; 6 | 7 | namespace Helios.Channels 8 | { 9 | internal sealed class DefaultChannelHandlerContext : AbstractChannelHandlerContext 10 | { 11 | public DefaultChannelHandlerContext(DefaultChannelPipeline pipeline, IChannelHandlerInvoker invoker, string name, 12 | IChannelHandler handler) 13 | : base(pipeline, invoker, name, GetSkipPropagationFlags(handler)) 14 | { 15 | Contract.Requires(handler != null); 16 | Handler = handler; 17 | } 18 | 19 | public override IChannelHandler Handler { get; } 20 | } 21 | } -------------------------------------------------------------------------------- /src/Helios/Buffers/UnpooledByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Buffers 6 | { 7 | /// 8 | /// Unpooled implementation of . 9 | /// 10 | public class UnpooledByteBufAllocator : AbstractByteBufAllocator 11 | { 12 | /// 13 | /// Default instance 14 | /// 15 | public static readonly UnpooledByteBufAllocator Default = new UnpooledByteBufAllocator(); 16 | 17 | protected override IByteBuf NewDirectBuffer(int initialCapacity, int maxCapacity) 18 | { 19 | return new UnpooledDirectByteBuf(this, initialCapacity, maxCapacity); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Channels/CounterHandlerOutbound.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | using Helios.Channels; 7 | using NBench; 8 | 9 | namespace Helios.Tests.Performance.Channels 10 | { 11 | internal class CounterHandlerOutbound : ChannelHandlerAdapter 12 | { 13 | private readonly Counter _throughput; 14 | 15 | public CounterHandlerOutbound(Counter throughput) 16 | { 17 | _throughput = throughput; 18 | } 19 | 20 | public override Task WriteAsync(IChannelHandlerContext context, object message) 21 | { 22 | _throughput.Increment(); 23 | return context.WriteAsync(message); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionWithStateScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Util.TimedOps; 7 | 8 | namespace Helios.Concurrency 9 | { 10 | internal sealed class ActionWithStateScheduledTask : ScheduledTask 11 | { 12 | private readonly Action _action; 13 | 14 | public ActionWithStateScheduledTask(AbstractScheduledEventExecutor executor, Action action, object state, 15 | PreciseDeadline deadline) : base(executor, deadline, new TaskCompletionSource(state)) 16 | { 17 | _action = action; 18 | } 19 | 20 | protected override void Execute() 21 | { 22 | _action(Completion.AsyncState); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Logging/LogLevel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Logging 6 | { 7 | /// 8 | /// Enumeration representing the various log levels in the system. 9 | /// 10 | public enum LogLevel 11 | { 12 | /// 13 | /// The debug log level. 14 | /// 15 | Debug, 16 | 17 | /// 18 | /// The information log level. 19 | /// 20 | Info, 21 | 22 | /// 23 | /// The warning log level. 24 | /// 25 | Warning, 26 | 27 | /// 28 | /// The error log level. 29 | /// 30 | Error 31 | } 32 | } -------------------------------------------------------------------------------- /src/Helios/Channels/ActionChannelInitializer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Diagnostics.Contracts; 7 | 8 | namespace Helios.Channels 9 | { 10 | public sealed class ActionChannelInitializer : ChannelInitializer 11 | where T : IChannel 12 | { 13 | private readonly Action initializationAction; 14 | 15 | public ActionChannelInitializer(Action initializationAction) 16 | { 17 | Contract.Requires(initializationAction != null); 18 | 19 | this.initializationAction = initializationAction; 20 | } 21 | 22 | protected override void InitChannel(T channel) 23 | { 24 | initializationAction(channel); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Channels/Sockets/TcpSocketServerSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using FsCheck; 6 | using FsCheck.Experimental; 7 | using Xunit; 8 | 9 | namespace Helios.FsCheck.Tests.Channels.Sockets 10 | { 11 | public class TcpSocketServerSpecs 12 | { 13 | [Fact(Skip = "Resolved XUnit issue, but need to disable shrinking")] 14 | public void TcpSeverSocketChannel_should_obey_model() 15 | { 16 | var model = new TcpServerSocketChannelStateMachine(); 17 | try 18 | { 19 | model.ToProperty().VerboseCheckThrowOnFailure(); 20 | } 21 | finally 22 | { 23 | model.ShutdownAll(); 24 | } 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Helios/Serialization/ITransportSerializer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.IO; 6 | using Helios.Net; 7 | 8 | namespace Helios.Serialization 9 | { 10 | /// 11 | /// A binary serializer interface for working with messages 12 | /// sent over IConnection and ITransport objects 13 | /// 14 | public interface ITransportSerializer 15 | { 16 | bool TryDeserialize(out T obj, Stream stream); 17 | 18 | bool TryDeserialize(out T obj, NetworkData data); 19 | 20 | T Deserialize(Stream stream); 21 | 22 | T Deserialize(NetworkData data); 23 | 24 | void Serialize(T obj, Stream stream); 25 | 26 | void Serialize(T obj, NetworkData data); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Helios/Net/IConnectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Net.Builders; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Net 9 | { 10 | /// 11 | /// Extension methods using a default connection builder, to help make it easier to establish ad-hoc connections with 12 | /// INode instances 13 | /// 14 | public static class IConnectionExtensions 15 | { 16 | public static IConnectionBuilder DefaultConnectionBuilder = 17 | new NormalConnectionBuilder(NetworkConstants.DefaultConnectivityTimeout); 18 | 19 | public static IConnection GetConnection(this INode node) 20 | { 21 | return DefaultConnectionBuilder.BuildConnection(node); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Channels/Bootstrap/BootstrapSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading.Tasks; 7 | using Helios.Channels; 8 | 9 | namespace Helios.Tests.Channels.Bootstrap 10 | { 11 | public class BootstrapSpecs : IDisposable 12 | { 13 | private readonly IEventLoopGroup groupA = new MultithreadEventLoopGroup(1); 14 | private readonly IEventLoopGroup groupB = new MultithreadEventLoopGroup(1); 15 | 16 | 17 | public void Dispose() 18 | { 19 | GC.SuppressFinalize(this); 20 | groupA.ShutdownGracefullyAsync(); 21 | groupB.ShutdownGracefullyAsync(); 22 | Task.WaitAll(groupA.TerminationCompletion, groupB.TerminationCompletion); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | using Helios.Util.TimedOps; 8 | 9 | namespace Helios.Concurrency 10 | { 11 | internal sealed class ActionScheduledAsyncTask : ScheduledAsyncTask 12 | { 13 | private readonly Action _action; 14 | 15 | public ActionScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, PreciseDeadline deadline, 16 | CancellationToken cancellationToken) 17 | : base(executor, deadline, new TaskCompletionSource(), cancellationToken) 18 | { 19 | _action = action; 20 | } 21 | 22 | protected override void Execute() 23 | { 24 | _action(); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Helios/Net/Bootstrap/TcpConnectionFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Net.Connections; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Net.Bootstrap 9 | { 10 | /// 11 | /// for spawning instances 12 | /// 13 | public sealed class TcpConnectionFactory : ClientConnectionFactoryBase 14 | { 15 | public TcpConnectionFactory(ClientBootstrap clientBootstrap) : base(clientBootstrap) 16 | { 17 | } 18 | 19 | protected override IConnection CreateConnection(INode localEndpoint, INode remoteEndpoint) 20 | { 21 | return new TcpConnection(EventLoop, remoteEndpoint, Encoder, Decoder, Allocator); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Helios/Net/Bootstrap/UdpConnectionFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Net.Connections; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Net.Bootstrap 9 | { 10 | /// 11 | /// for spawning instances 12 | /// 13 | public sealed class UdpConnectionFactory : ClientConnectionFactoryBase 14 | { 15 | public UdpConnectionFactory(ClientBootstrap clientBootstrap) : base(clientBootstrap) 16 | { 17 | } 18 | 19 | protected override IConnection CreateConnection(INode localEndpoint, INode remoteEndpoint) 20 | { 21 | return new UdpConnection(EventLoop, localEndpoint, Encoder, Decoder, Allocator); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /src/Helios/Serialization/Encoders.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Serialization 6 | { 7 | /// 8 | /// Static factory class for generating encoder instances 9 | /// 10 | public static class Encoders 11 | { 12 | /// 13 | /// The default decoder option 14 | /// 15 | public static IMessageDecoder DefaultDecoder 16 | { 17 | get { return LengthFieldFrameBasedDecoder.Default; } 18 | } 19 | 20 | 21 | /// 22 | /// The default encoder option 23 | /// 24 | public static IMessageEncoder DefaultEncoder 25 | { 26 | get { return LengthFieldPrepender.Default; } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Helios/Reactor/Bootstrap/UdpServerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Reactor.Udp; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Reactor.Bootstrap 9 | { 10 | /// 11 | /// instance for spawning UDP-based instances 12 | /// 13 | public sealed class UdpServerFactory : ServerFactoryBase 14 | { 15 | public UdpServerFactory(ServerBootstrap other) : base(other) 16 | { 17 | } 18 | 19 | protected override ReactorBase NewReactorInternal(INode listenAddress) 20 | { 21 | return new UdpProxyReactor(listenAddress.Host, listenAddress.Port, EventLoop, Encoder, Decoder, Allocator, 22 | BufferBytes); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Ops/EventLoopFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Net; 6 | using Helios.Ops.Executors; 7 | 8 | namespace Helios.Ops 9 | { 10 | /// 11 | /// Static factory class for creating instances 12 | /// 13 | public static class EventLoopFactory 14 | { 15 | public static IEventLoop CreateThreadedEventLoop(int defaultSize = 2, IExecutor internalExecutor = null) 16 | { 17 | return new ThreadedEventLoop(internalExecutor, defaultSize); 18 | } 19 | 20 | public static NetworkEventLoop CreateNetworkEventLoop(int defaultSize = 2, IExecutor internalExecutor = null) 21 | { 22 | return new NetworkEventLoop(internalExecutor, defaultSize); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /benchmark/Helios.HorizontalScaling.Performance/Channels/ErrorCounterHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Helios.Channels; 11 | using NBench; 12 | 13 | namespace Helios.HorizontalScaling.Tests.Performance.Channels 14 | { 15 | public class ErrorCounterHandler : ChannelHandlerAdapter 16 | { 17 | private readonly Counter _errorCount; 18 | 19 | public ErrorCounterHandler(Counter errorCount) 20 | { 21 | _errorCount = errorCount; 22 | } 23 | 24 | public override void ExceptionCaught(IChannelHandlerContext context, Exception exception) 25 | { 26 | _errorCount.Increment(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IMessageSizeEstimator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Channels 6 | { 7 | public interface IMessageSizeEstimator 8 | { 9 | /// 10 | /// Creates a new , which will perform all of the underlying work 11 | /// 12 | IMessageSizeEstimatorHandle NewHandle(); 13 | } 14 | 15 | 16 | public interface IMessageSizeEstimatorHandle 17 | { 18 | /// 19 | /// Estimsates the size, in bytes, of the underlying object. 20 | /// 21 | /// The object whose size we're measuring. 22 | /// The estimated length of the object in bytes. 23 | int Size(object obj); 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Util/Collections/DictionaryExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | 7 | namespace Helios.Util.Collections 8 | { 9 | /// 10 | /// Static helper methods for working with dictionaries 11 | /// 12 | public static class DictionaryExtensions 13 | { 14 | public static TValue GetOrDefault(this IDictionary hash, TKey key) 15 | { 16 | return hash.ContainsKey(key) ? hash[key] : default(TValue); 17 | } 18 | 19 | public static TValue GetOrDefault(this IDictionary hash, 20 | TKey key) 21 | { 22 | return hash.ContainsKey(key) && hash[key] is TValue ? (TValue) hash[key] : default(TValue); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/IPausableEventExecutor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Concurrency 6 | { 7 | /// 8 | /// An that can reject new work while paused. 9 | /// 10 | public interface IPausableEventExecutor : IWrappedEventExecutor 11 | { 12 | /// 13 | /// Returns true if paused, false otherwise. 14 | /// 15 | bool IsAcceptingNewTasks { get; } 16 | 17 | /// 18 | /// Pause - may throw a if work is queued while paused. 19 | /// 20 | void RejectNewTasks(); 21 | 22 | /// 23 | /// Unpause. 24 | /// 25 | void AcceptNewTasks(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Helios/Exceptions/Events/ExceptionTopicSubscription.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Eventing; 7 | 8 | namespace Helios.Exceptions.Events 9 | { 10 | /// 11 | /// Used by internal event brokers for routing events 12 | /// 13 | public class ExceptionTopicSubscription : ITopicSubscription 14 | { 15 | protected readonly Action _callback; 16 | 17 | public ExceptionTopicSubscription(Action callback) 18 | { 19 | _callback = callback; 20 | } 21 | 22 | public void Invoke() 23 | { 24 | //Do nothing 25 | } 26 | 27 | public void Invoke(object sender, EventArgs e) 28 | { 29 | _callback((ExceptionEventArgs) e); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Helios/Logging/NoOpLogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Logging 6 | { 7 | /// 8 | /// Logger that does nothing. 9 | /// 10 | public class NoOpLogger : LoggingAdapter 11 | { 12 | public static NoOpLogger Instance = new NoOpLogger(); 13 | 14 | private NoOpLogger() : base(typeof(NoOpLogger).FullName, new LogLevel[0]) 15 | { 16 | } 17 | 18 | 19 | protected override void DebugInternal(Debug message) 20 | { 21 | } 22 | 23 | protected override void InfoInternal(Info message) 24 | { 25 | } 26 | 27 | protected override void WarningInternal(Warning message) 28 | { 29 | } 30 | 31 | protected override void ErrorInternal(Error message) 32 | { 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IChannelUnsafe.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using Helios.Concurrency; 8 | 9 | namespace Helios.Channels 10 | { 11 | public interface IChannelUnsafe 12 | { 13 | IRecvByteBufferAllocatorHandle RecvBufAllocHandle { get; } 14 | 15 | ChannelOutboundBuffer OutboundBuffer { get; } 16 | 17 | Task RegisterAsync(IEventLoop eventLoop); 18 | 19 | Task DeregisterAsync(); 20 | 21 | Task BindAsync(EndPoint localAddress); 22 | 23 | Task ConnectAsync(EndPoint remoteAddress, EndPoint localAddress); 24 | 25 | Task DisconnectAsync(); 26 | 27 | Task CloseAsync(); 28 | 29 | void CloseForcibly(); 30 | 31 | void BeginRead(); 32 | 33 | Task WriteAsync(object message); 34 | 35 | void Flush(); 36 | } 37 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionWithStateScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | using Helios.Util.TimedOps; 8 | 9 | namespace Helios.Concurrency 10 | { 11 | internal sealed class ActionWithStateScheduledAsyncTask : ScheduledAsyncTask 12 | { 13 | private readonly Action _action; 14 | 15 | public ActionWithStateScheduledAsyncTask(AbstractScheduledEventExecutor executor, Action action, 16 | object state, PreciseDeadline deadline, CancellationToken cancellationToken) 17 | : base(executor, deadline, new TaskCompletionSource(state), cancellationToken) 18 | { 19 | _action = action; 20 | } 21 | 22 | protected override void Execute() 23 | { 24 | _action(Completion.AsyncState); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /tools/nunit/nunit.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tools/nunit/nunit-x86.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/HeliosGenerators.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using FsCheck; 6 | using Helios.Logging; 7 | using Helios.Util.Collections; 8 | 9 | namespace Helios.FsCheck.Tests 10 | { 11 | public class HeliosGenerators 12 | { 13 | public static Arbitrary> CreateCircularBuffer() 14 | { 15 | var generator = Gen.Choose(1, 10).Select(i => new CircularBuffer(i)); 16 | return Arb.From(generator); 17 | } 18 | 19 | public static Arbitrary> CreateCircularBufferInt() 20 | { 21 | return CreateCircularBuffer(); 22 | } 23 | 24 | public static Arbitrary CreateLogLevel() 25 | { 26 | return Arb.From(Gen.Elements(LogLevel.Error, LogLevel.Debug, LogLevel.Info, LogLevel.Warning)); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Buffer/ByteBufferDerivationSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Buffers; 6 | using Xunit; 7 | 8 | namespace Helios.Tests.Buffer 9 | { 10 | public class ByteBufferDerivationSpecs 11 | { 12 | [Fact] 13 | public void Swap_in_reverse_should_be_original() 14 | { 15 | var buf = Unpooled.Buffer(8).SetIndex(1, 7); 16 | var swapped = buf.WithOrder(ByteOrder.BigEndian); 17 | 18 | Assert.IsType(swapped); 19 | Assert.Null(swapped.Unwrap()); 20 | Assert.Same(buf, swapped.WithOrder(ByteOrder.LittleEndian)); 21 | Assert.Same(swapped, swapped.WithOrder(ByteOrder.BigEndian)); 22 | buf.SetIndex(2, 6); 23 | Assert.Equal(swapped.ReaderIndex, 2); 24 | Assert.Equal(swapped.WriterIndex, 6); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/FsharpDelegateHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Microsoft.FSharp.Core; 7 | 8 | namespace Helios.FsCheck.Tests 9 | { 10 | public static class FsharpDelegateHelper 11 | { 12 | public static FSharpFunc Create(Func func) 13 | { 14 | Converter conv = input => func(input); 15 | return FSharpFunc.FromConverter(conv); 16 | } 17 | 18 | public static FSharpFunc> Create(Func func) 19 | { 20 | Converter> conv = 21 | value1 => { return Create(value2 => func(value1, value2)); }; 22 | return FSharpFunc>.FromConverter(conv); 23 | } 24 | } 25 | } -------------------------------------------------------------------------------- /src/Helios/Eventing/Subscriptions/NormalTopicSubscription.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Eventing.Subscriptions 8 | { 9 | /// 10 | /// Basic implementation of a topic subscription 11 | /// 12 | public class NormalTopicSubscription : ITopicSubscription 13 | { 14 | protected Action InternalCallback; 15 | 16 | public NormalTopicSubscription(Action callback) 17 | { 18 | InternalCallback = callback; 19 | } 20 | 21 | public void Invoke() 22 | { 23 | Invoke(this, new EventArgs()); 24 | } 25 | 26 | public void Invoke(object sender, EventArgs e) 27 | { 28 | var h = InternalCallback; 29 | if (h == null) return; 30 | h.Invoke(sender, e); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Embedded/EmbeddedChannelId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Channels.Embedded 8 | { 9 | internal sealed class EmbeddedChannelId : IChannelId 10 | { 11 | public static readonly EmbeddedChannelId Instance = new EmbeddedChannelId(); 12 | 13 | private EmbeddedChannelId() 14 | { 15 | } 16 | 17 | public int CompareTo(IChannelId other) 18 | { 19 | if (other is EmbeddedChannelId) 20 | { 21 | return 0; 22 | } 23 | return string.Compare(ToString(), other.ToString(), StringComparison.Ordinal); 24 | } 25 | 26 | public override string ToString() 27 | { 28 | return "embedded"; 29 | } 30 | 31 | public override int GetHashCode() 32 | { 33 | return 0; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionWithStateAndContextScheduledTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Util.TimedOps; 7 | 8 | namespace Helios.Concurrency 9 | { 10 | internal sealed class ActionWithStateAndContextScheduledTask : ScheduledTask 11 | { 12 | private readonly Action _action; 13 | private readonly object _context; 14 | 15 | public ActionWithStateAndContextScheduledTask(AbstractScheduledEventExecutor executor, 16 | Action action, object context, object state, PreciseDeadline deadline) 17 | : base(executor, deadline, new TaskCompletionSource(state)) 18 | { 19 | _action = action; 20 | _context = context; 21 | } 22 | 23 | protected override void Execute() 24 | { 25 | _action(_context, Completion.AsyncState); 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Helios/Util/ThreadLocalRandom.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | 8 | namespace Helios.Util 9 | { 10 | /// 11 | /// Create random numbers with Thread-specific seeds. 12 | /// Borrowed form Jon Skeet's brilliant C# in Depth: http://csharpindepth.com/Articles/Chapter12/Random.aspx 13 | /// 14 | public static class ThreadLocalRandom 15 | { 16 | private static int _seed = Environment.TickCount; 17 | 18 | private static readonly ThreadLocal _rng = 19 | new ThreadLocal(() => new Random(Interlocked.Increment(ref _seed))); 20 | 21 | /// 22 | /// The current random number seed available to this thread 23 | /// 24 | public static Random Current 25 | { 26 | get { return _rng.Value; } 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /tools/nunit/nunit-console.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Channels/ReadFinishedHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Channels; 6 | 7 | namespace Helios.Tests.Performance.Channels 8 | { 9 | public class ReadFinishedHandler : ChannelHandlerAdapter 10 | { 11 | private readonly int _expectedReads; 12 | private readonly IReadFinishedSignal _signal; 13 | private int _actualReads; 14 | 15 | public ReadFinishedHandler(IReadFinishedSignal signal, int expectedReads) 16 | { 17 | _signal = signal; 18 | _expectedReads = expectedReads; 19 | } 20 | 21 | public override void ChannelRead(IChannelHandlerContext context, object message) 22 | { 23 | if (++_actualReads == _expectedReads) 24 | { 25 | _signal.Signal(); 26 | } 27 | context.FireChannelRead(message); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Channels/ReadCountAwaiter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading; 6 | using Helios.Channels; 7 | 8 | namespace Helios.Tests.Channels 9 | { 10 | public class ReadCountAwaiter : ChannelHandlerAdapter 11 | { 12 | private readonly int _expectedReadCount; 13 | private readonly ManualResetEventSlim _resetEvent; 14 | private int _actualReadCount; 15 | 16 | public ReadCountAwaiter(ManualResetEventSlim resetEvent, int expectedReadCount) 17 | { 18 | _resetEvent = resetEvent; 19 | _expectedReadCount = expectedReadCount; 20 | } 21 | 22 | public override void ChannelRead(IChannelHandlerContext context, object message) 23 | { 24 | if (++_actualReadCount == _expectedReadCount) 25 | _resetEvent.Set(); 26 | context.FireChannelRead(message); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /tools/nunit/nunit-console-x86.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /src/Helios/Channels/IChannelConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Buffers; 7 | 8 | namespace Helios.Channels 9 | { 10 | public interface IChannelConfiguration 11 | { 12 | TimeSpan ConnectTimeout { get; set; } 13 | 14 | int MaxMessagesPerRead { get; set; } 15 | 16 | IByteBufAllocator Allocator { get; set; } 17 | 18 | IRecvByteBufAllocator RecvByteBufAllocator { get; set; } 19 | 20 | IMessageSizeEstimator MessageSizeEstimator { get; set; } 21 | 22 | bool AutoRead { get; set; } 23 | 24 | int WriteBufferHighWaterMark { get; set; } 25 | 26 | int WriteBufferLowWaterMark { get; set; } 27 | 28 | int WriteSpinCount { get; set; } 29 | T GetOption(ChannelOption option); 30 | 31 | bool SetOption(ChannelOption option, object value); 32 | 33 | bool SetOption(ChannelOption option, T value); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Helios/Reactor/Bootstrap/TcpServerFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Reactor.Tcp; 7 | using Helios.Topology; 8 | 9 | namespace Helios.Reactor.Bootstrap 10 | { 11 | /// 12 | /// instance for spawning TCP-based instances 13 | /// 14 | public sealed class TcpServerFactory : ServerFactoryBase 15 | { 16 | public TcpServerFactory(ServerBootstrap other) 17 | : base(other) 18 | { 19 | } 20 | 21 | protected override ReactorBase NewReactorInternal(INode listenAddress) 22 | { 23 | if (UseProxies) 24 | return new TcpProxyReactor(listenAddress.Host, listenAddress.Port, EventLoop, Encoder, Decoder, 25 | Allocator, BufferBytes); 26 | throw new NotImplementedException("Have not implemented non-TCP proxies"); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Helios/Topology/EmptyNode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | 7 | namespace Helios.Topology 8 | { 9 | /// 10 | /// Special case pattern - uses an Empty node to denote when an item is local, rather than networked. 11 | /// 12 | public class EmptyNode : INode 13 | { 14 | private IPEndPoint _endPoint; 15 | public IPAddress Host { get; set; } 16 | public int Port { get; set; } 17 | public TransportType TransportType { get; set; } 18 | public string MachineName { get; set; } 19 | public string OS { get; set; } 20 | public string ServiceVersion { get; set; } 21 | public string CustomData { get; set; } 22 | 23 | public IPEndPoint ToEndPoint() 24 | { 25 | return _endPoint ?? (_endPoint = new IPEndPoint(IPAddress.None, 0)); 26 | } 27 | 28 | public object Clone() 29 | { 30 | return Node.Empty(); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Helios/Util/RecyclableArrayList.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | using System.Threading; 7 | 8 | namespace Helios.Util 9 | { 10 | public class RecyclableArrayList : List 11 | { 12 | private static readonly ThreadLocal> _pool = 13 | new ThreadLocal>( 14 | () => new ObjectPool(handle => new RecyclableArrayList(handle))); 15 | 16 | private readonly PoolHandle _handle; 17 | 18 | public RecyclableArrayList(PoolHandle handle) 19 | { 20 | _handle = handle; 21 | } 22 | 23 | public static RecyclableArrayList Take() 24 | { 25 | return _pool.Value.Take(); 26 | } 27 | 28 | public void Return() 29 | { 30 | Clear(); 31 | _handle.Free(this); // return to the pool 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Helios/Topology/NodeExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Net; 7 | 8 | namespace Helios.Topology 9 | { 10 | /// 11 | /// Extension methods to make it easier to work with INode implementations 12 | /// 13 | public static class NodeExtensions 14 | { 15 | public static INode ToNode(this IPEndPoint endPoint, TransportType transportType) 16 | { 17 | return new Node {Host = endPoint.Address, Port = endPoint.Port, TransportType = transportType}; 18 | } 19 | 20 | public static Uri ToUri(this INode node) 21 | { 22 | return new NodeUri(node); 23 | } 24 | 25 | #if !NET35 && !NET40 26 | public static INode ToNode(this Uri uri) 27 | { 28 | return NodeUri.GetNodeFromUri(uri); 29 | } 30 | #endif 31 | 32 | public static bool IsEmpty(this INode node) 33 | { 34 | return node is EmptyNode; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Codecs/MessageToMessageEncoderSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using Helios.Channels; 8 | using Helios.Channels.Embedded; 9 | using Helios.Codecs; 10 | using Xunit; 11 | 12 | namespace Helios.Tests.Codecs 13 | { 14 | public class MessageToMessageEncoderSpecs 15 | { 16 | [Fact] 17 | public void Should_propagate_exceptions() 18 | { 19 | var ec = new EmbeddedChannel(new ExceptionEncoder()); 20 | var agg = Assert.Throws(() => { ec.WriteOutbound(new object()); }); 21 | Assert.IsType(agg.InnerExceptions[0]); 22 | } 23 | 24 | private class ExceptionEncoder : MessageToMessageEncoder 25 | { 26 | protected override void Encode(IChannelHandlerContext context, object cast, List output) 27 | { 28 | throw new ApplicationException(); 29 | } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IRecvByteBufferAllocatorHandle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Buffers; 6 | 7 | namespace Helios.Channels 8 | { 9 | public interface IRecvByteBufferAllocatorHandle 10 | { 11 | /// 12 | /// Allocates buffers for socket read and receive operations, with enough capacity to read all received 13 | /// data in one shot. 14 | /// 15 | IByteBuf Allocate(IByteBufAllocator allocator); 16 | 17 | /// 18 | /// Guesses the capacity of the next new buffer, but doesn't allocate it. 19 | /// 20 | int Guess(); 21 | 22 | /// 23 | /// Records the actual number of read bytes in the previous read, so it can provide some intelligence 24 | /// as to how big the next buffer should be. 25 | /// 26 | /// The number of bytes actually read. 27 | void Record(int actualReadBytes); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ActionWithStateAndContextScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | using Helios.Util.TimedOps; 8 | 9 | namespace Helios.Concurrency 10 | { 11 | internal sealed class ActionWithStateAndContextScheduledAsyncTask : ScheduledAsyncTask 12 | { 13 | private readonly Action _action; 14 | private readonly object _context; 15 | 16 | public ActionWithStateAndContextScheduledAsyncTask(AbstractScheduledEventExecutor executor, 17 | Action action, object context, object state, PreciseDeadline deadline, 18 | CancellationToken cancellationToken) 19 | : base(executor, deadline, new TaskCompletionSource(state), cancellationToken) 20 | { 21 | _action = action; 22 | _context = context; 23 | } 24 | 25 | protected override void Execute() 26 | { 27 | _action(_context, Completion.AsyncState); 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Helios/Ops/Executors/ThreadedEventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Concurrency; 6 | 7 | namespace Helios.Ops.Executors 8 | { 9 | /// 10 | /// Simple multi-threaded event loop 11 | /// 12 | public class ThreadedEventLoop : AbstractEventLoop 13 | { 14 | public ThreadedEventLoop(int workerThreads) : base(FiberFactory.CreateFiber(workerThreads)) 15 | { 16 | } 17 | 18 | public ThreadedEventLoop(IExecutor internalExecutor, int workerThreads) 19 | : base(FiberFactory.CreateFiber(internalExecutor, workerThreads)) 20 | { 21 | } 22 | 23 | public ThreadedEventLoop(IFiber scheduler) : base(scheduler) 24 | { 25 | } 26 | 27 | public override IExecutor Clone() 28 | { 29 | return new ThreadedEventLoop(Scheduler.Clone()); 30 | } 31 | 32 | public override IExecutor Next() 33 | { 34 | return new ThreadedEventLoop(Scheduler); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Helios/Util/Collections/CollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace Helios.Util.Collections 9 | { 10 | /// 11 | /// Static helpers for working with collections 12 | /// 13 | public static class CollectionExtensions 14 | { 15 | public static IEnumerable Subset(this IEnumerable obj, int offset, int count) 16 | { 17 | return Subset(obj.ToList(), offset, count); 18 | } 19 | 20 | public static IList Subset(this IList obj, int offset, int count) 21 | { 22 | //Guard against bad input 23 | offset.NotLessThan(0); 24 | count.NotLessThan(0); 25 | (obj.Count - (offset + count)).NotNegative(); 26 | 27 | var resultantList = new List(); 28 | 29 | for (var i = offset; i < offset + count; i++) 30 | { 31 | resultantList.Add(obj[i]); 32 | } 33 | 34 | return resultantList; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Helios/Util/FlagsHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Util 6 | { 7 | /// 8 | /// Static helper class for setting bitmask flags 9 | /// 10 | public static class FlagsHelper 11 | { 12 | public static bool IsSet(T flags, T flag) where T : struct 13 | { 14 | var flagsValue = (int) (object) flags; 15 | var flagValue = (int) (object) flag; 16 | 17 | return (flagsValue & flagValue) != 0; 18 | } 19 | 20 | public static void Set(ref T flags, T flag) where T : struct 21 | { 22 | var flagsValue = (int) (object) flags; 23 | var flagValue = (int) (object) flag; 24 | 25 | flags = (T) (object) (flagsValue | flagValue); 26 | } 27 | 28 | public static void Unset(ref T flags, T flag) where T : struct 29 | { 30 | var flagsValue = (int) (object) flags; 31 | var flagValue = (int) (object) flag; 32 | 33 | flags = (T) (object) (flagsValue & ~flagValue); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Channels/TestChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Channels; 6 | using Helios.Channels.Embedded; 7 | 8 | namespace Helios.FsCheck.Tests.Channels 9 | { 10 | /// 11 | /// Internal implementation used for lightweight testing. 12 | /// Mostly for testing things that go INSIDE the channel itself. 13 | /// 14 | internal class TestChannel 15 | { 16 | public static IChannel Instance => NewInstance(); 17 | 18 | public static IChannel NewInstance(params IChannelHandler[] handlers) 19 | { 20 | var instance = new EmbeddedChannel(handlers); 21 | instance.Configuration.WriteBufferHighWaterMark = ChannelOutboundBufferSpecs.WriteHighWaterMark; 22 | instance.Configuration.WriteBufferLowWaterMark = ChannelOutboundBufferSpecs.WriteLowWaterMark; 23 | instance.Configuration.AutoRead = false; 24 | // interferes with testing the invocation model for ChannelReadComplete 25 | return instance; 26 | } 27 | } 28 | } -------------------------------------------------------------------------------- /tools/nunit/nunit-agent.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tools/nunit/nunit-agent-x86.exe.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /tests/Helios.Tests/Util/TimedOps/PreciseDeadlineSpecs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading.Tasks; 7 | using Helios.Util.TimedOps; 8 | using Xunit; 9 | 10 | namespace Helios.Tests.Util.TimedOps 11 | { 12 | public class PreciseDeadlineSpecs 13 | { 14 | [Fact] 15 | public void PreciseDeadline_should_correctly_report_overdue_time() 16 | { 17 | var deadline = new PreciseDeadline(TimeSpan.FromMilliseconds(20)); 18 | Task.Delay(TimeSpan.FromMilliseconds(50)).Wait(); 19 | Assert.True(deadline.IsOverdue); 20 | } 21 | 22 | [Fact] 23 | public void PrecideDeadline_from_addition_should_correctly_report_overduetime() 24 | { 25 | var timeout = TimeSpan.FromMilliseconds(20); 26 | var deadline = PreciseDeadline.Now + timeout; 27 | Assert.True(deadline > PreciseDeadline.Now); 28 | Assert.True(PreciseDeadline.Now < deadline); 29 | Task.Delay(TimeSpan.FromMilliseconds(50)).Wait(); 30 | Assert.True(deadline.IsOverdue); 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Helios/Exceptions/HeliosConnectionException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Exceptions 8 | { 9 | public class HeliosConnectionException : HeliosException 10 | { 11 | public HeliosConnectionException() 12 | : this(ExceptionType.Unknown) 13 | { 14 | } 15 | 16 | public HeliosConnectionException(ExceptionType type) 17 | { 18 | Type = type; 19 | } 20 | 21 | public HeliosConnectionException(ExceptionType type, Exception innerException) 22 | : this(type, innerException == null ? string.Empty : innerException.Message, innerException) 23 | { 24 | } 25 | 26 | public HeliosConnectionException(ExceptionType type, string message) : base(message) 27 | { 28 | Type = type; 29 | } 30 | 31 | public HeliosConnectionException(ExceptionType type, string message, Exception innerException) 32 | : base(message, innerException) 33 | { 34 | Type = type; 35 | } 36 | 37 | public ExceptionType Type { get; } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Helios/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.CompilerServices; 7 | using System.Runtime.InteropServices; 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | 13 | [assembly: AssemblyTitle("Helios")] 14 | [assembly: AssemblyDescription("Network and concurrency middleware for .NET")] 15 | [assembly: AssemblyProduct("Helios")] 16 | [assembly: AssemblyTrademark("")] 17 | [assembly: AssemblyCulture("")] 18 | 19 | // Setting ComVisible to false makes the types in this assembly not visible 20 | // to COM components. If you need to access a type in this assembly from 21 | // COM, set the ComVisible attribute to true on that type. 22 | 23 | [assembly: ComVisible(false)] 24 | 25 | // The following GUID is for the ID of the typelib if this project is exposed to COM 26 | 27 | [assembly: Guid("523dc8d0-1200-4c1e-b50c-9140bd6748c9")] 28 | [assembly: InternalsVisibleTo("Helios.FsCheck.Tests")] 29 | [assembly: InternalsVisibleTo("Helios.Tests")] -------------------------------------------------------------------------------- /src/Helios/Concurrency/PromiseUtil.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Logging; 7 | 8 | namespace Helios.Concurrency 9 | { 10 | /// 11 | /// Utility class for working with 12 | /// 13 | internal static class PromiseUtil 14 | { 15 | public static void SafeSetSuccess(TaskCompletionSource promise, ILogger logger) 16 | { 17 | if (promise != TaskCompletionSource.Void && !promise.TryComplete()) 18 | { 19 | logger.Warning("Failed to complete task successfully because it is done already: {0}", promise); 20 | } 21 | } 22 | 23 | public static void SafeSetFailure(TaskCompletionSource promise, Exception cause, ILogger logger) 24 | { 25 | if (promise != TaskCompletionSource.Void && !promise.TrySetException(cause)) 26 | { 27 | logger.Warning( 28 | "Failed to set exception on task successfully because it is done already: {0}; Cause: {1}", promise, 29 | cause); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /src/Helios/Util/IpHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Diagnostics.Contracts; 2 | using System.Net; 3 | using System.Net.Sockets; 4 | 5 | namespace Helios.Util 6 | { 7 | /// 8 | /// Used to help with determining the correct to specify 9 | /// when binding to a . 10 | /// 11 | /// 12 | /// Used to help resolve https://github.com/akkadotnet/akka.net/issues/2194 and 13 | /// https://github.com/helios-io/helios/issues/118, which were caused by inconsistencies 14 | /// between .NET and Mono / Linux. 15 | /// 16 | public static class IpHelper 17 | { 18 | /// 19 | /// Resolves the most specific for a given endpoint. 20 | /// 21 | /// The we're going to find a fit for. 22 | /// The closest fitting InterNetwork . 23 | public static AddressFamily BestAddressFamily(this EndPoint ep) 24 | { 25 | Contract.Requires(ep != null); 26 | if (ep.AddressFamily == AddressFamily.Unspecified) 27 | { 28 | return Socket.OSSupportsIPv6 ? AddressFamily.InterNetworkV6 : AddressFamily.InterNetwork; 29 | } 30 | 31 | return ep.AddressFamily; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /tests/Helios.Tests/Channels/Bootstrap/TcpBootstrapSpec.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Net; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using Helios.Channels; 12 | using Helios.Channels.Bootstrap; 13 | using Helios.Channels.Sockets; 14 | using Xunit; 15 | 16 | namespace Helios.Tests.Channels.Bootstrap 17 | { 18 | public class TcpBootstrapSpec : IDisposable 19 | { 20 | private MultithreadEventLoopGroup _serverGroup = new MultithreadEventLoopGroup(1); 21 | 22 | [Fact] 23 | public void ServerBootrap_must_support_BindAsync_on_DnsEndpoints_for_SocketChannels() 24 | { 25 | var sb = new ServerBootstrap() 26 | .Channel() 27 | .ChildHandler(new ActionChannelInitializer(channel => { })) 28 | .Group(_serverGroup); 29 | 30 | var c = sb.BindAsync(new DnsEndPoint("localhost", 0)).Result; 31 | } 32 | 33 | public void Dispose() 34 | { 35 | _serverGroup.ShutdownGracefullyAsync(); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Net/MulticastHelperTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using Helios.Net; 7 | using Xunit; 8 | 9 | namespace Helios.Tests.Net 10 | { 11 | public class MulticastHelperTests 12 | { 13 | #region Setup / Teardown 14 | 15 | #endregion 16 | 17 | #region Tests 18 | 19 | [Fact] 20 | public void Should_mark_valid_IPv4_multicast_address_as_valid() 21 | { 22 | //arrange 23 | var validMulticastIp = "224.1.1.1"; 24 | 25 | //act 26 | var isValid = MulticastHelper.IsValidMulticastAddress(IPAddress.Parse(validMulticastIp)); 27 | 28 | //assert 29 | Assert.True(isValid); 30 | } 31 | 32 | [Fact] 33 | public void Should_mark_invalid_IPv4_multicast_address_as_invalid() 34 | { 35 | //arrange 36 | var invalidMulticastIp = "255.1.1.1"; 37 | 38 | //act 39 | var isValid = MulticastHelper.IsValidMulticastAddress(IPAddress.Parse(invalidMulticastIp)); 40 | 41 | //assert 42 | Assert.False(isValid); 43 | } 44 | 45 | #endregion 46 | } 47 | } -------------------------------------------------------------------------------- /src/Helios/Exceptions/HeliosNodeException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Topology; 7 | 8 | namespace Helios.Exceptions 9 | { 10 | public class HeliosNodeException : Exception 11 | { 12 | public HeliosNodeException(Exception innerException, INode affectedNode) 13 | : this(innerException.Message, innerException, affectedNode) 14 | { 15 | } 16 | 17 | public HeliosNodeException(string message) : base(message) 18 | { 19 | } 20 | 21 | public HeliosNodeException(string message, Exception innerException) : base(message, innerException) 22 | { 23 | } 24 | 25 | public HeliosNodeException(string message, INode affectedNode) : base(message) 26 | { 27 | AffectedNode = affectedNode; 28 | } 29 | 30 | public HeliosNodeException(string message, Exception innerException, INode affectedNode) 31 | : base(message, innerException) 32 | { 33 | AffectedNode = affectedNode; 34 | } 35 | 36 | public HeliosNodeException() 37 | { 38 | } 39 | 40 | public INode AffectedNode { get; protected set; } 41 | } 42 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Channels/Sockets/Models/ITcpServerSocketModel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | using System.Net; 7 | using Helios.Channels; 8 | 9 | namespace Helios.FsCheck.Tests.Channels.Sockets.Models 10 | { 11 | public interface ITcpServerSocketModel 12 | { 13 | IPEndPoint BoundAddress { get; } 14 | IChannel Self { get; } 15 | IReadOnlyList LocalChannels { get; } 16 | IReadOnlyList RemoteClients { get; } 17 | IReadOnlyList LastReceivedMessages { get; } 18 | 19 | IReadOnlyList WrittenMessages { get; } 20 | 21 | ITcpServerSocketModel SetSelf(IChannel self); 22 | ITcpServerSocketModel SetOwnAddress(IPEndPoint endpoint); 23 | ITcpServerSocketModel AddLocalChannel(IChannel channel); 24 | ITcpServerSocketModel RemoveLocalChannel(IChannel channel); 25 | ITcpServerSocketModel AddClient(IPEndPoint endpoint); 26 | ITcpServerSocketModel RemoveClient(IPEndPoint endpoint); 27 | ITcpServerSocketModel ClearMessages(); 28 | ITcpServerSocketModel WriteMessages(params int[] messages); 29 | ITcpServerSocketModel ReceiveMessages(params int[] messages); 30 | } 31 | } -------------------------------------------------------------------------------- /samples/Helios.RawSocket/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | //------------------------------------------------------------------------------ 6 | // 7 | // This code was generated by a tool. 8 | // Runtime Version:4.0.30319.34014 9 | // 10 | // Changes to this file may cause incorrect behavior and will be lost if 11 | // the code is regenerated. 12 | // 13 | //------------------------------------------------------------------------------ 14 | 15 | namespace Helios.RawSocket.Properties 16 | { 17 | 18 | 19 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 20 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 21 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 22 | { 23 | 24 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 25 | 26 | public static Settings Default 27 | { 28 | get 29 | { 30 | return defaultInstance; 31 | } 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /samples/Helios.RawUdpSocket/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | //------------------------------------------------------------------------------ 6 | // 7 | // This code was generated by a tool. 8 | // Runtime Version:4.0.30319.34014 9 | // 10 | // Changes to this file may cause incorrect behavior and will be lost if 11 | // the code is regenerated. 12 | // 13 | //------------------------------------------------------------------------------ 14 | 15 | namespace Helios.RawUdpSocket.Properties 16 | { 17 | 18 | 19 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 20 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 21 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 22 | { 23 | 24 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 25 | 26 | public static Settings Default 27 | { 28 | get 29 | { 30 | return defaultInstance; 31 | } 32 | } 33 | } 34 | } 35 | 36 | -------------------------------------------------------------------------------- /src/Helios/Channels/DefaultChannelId.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using Helios.Util; 7 | 8 | namespace Helios.Channels 9 | { 10 | [Serializable] 11 | internal sealed class DefaultChannelId : IChannelId 12 | { 13 | private readonly int _hashCode; 14 | 15 | private DefaultChannelId() 16 | { 17 | unchecked 18 | { 19 | _hashCode = (int) (MonotonicClock.GetTicks() & 0xFFFFFFFF); 20 | _hashCode *= _hashCode ^ ThreadLocalRandom.Current.Next(); 21 | } 22 | } 23 | 24 | public int CompareTo(IChannelId other) 25 | { 26 | return 0; 27 | } 28 | 29 | public override bool Equals(object obj) 30 | { 31 | if (!(obj is DefaultChannelId)) return false; 32 | return GetHashCode() == obj.GetHashCode(); 33 | } 34 | 35 | public override int GetHashCode() 36 | { 37 | return _hashCode; 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return $"ChannelId({_hashCode})"; 43 | } 44 | 45 | public static IChannelId NewInstance() 46 | { 47 | return new DefaultChannelId(); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Net/NodeUniquenessTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | using System.Net; 7 | using Helios.Topology; 8 | using Xunit; 9 | 10 | namespace Helios.Tests.Net 11 | { 12 | public class NodeUniquenessTests 13 | { 14 | #region Setup / Teardown 15 | 16 | #endregion 17 | 18 | #region Tests 19 | 20 | [Fact] 21 | public void Should_find_two_equivalent_nodes_as_equal() 22 | { 23 | var node1 = NodeBuilder.BuildNode().Host(IPAddress.Loopback).WithPort(1337); 24 | var node2 = NodeBuilder.FromEndpoint(new IPEndPoint(IPAddress.Loopback, 1337)); 25 | 26 | Assert.True(node1.Equals(node2)); 27 | } 28 | 29 | [Fact] 30 | public void Should_find_two_equivalent_INodes_in_dictionary_without_reference_equality() 31 | { 32 | var node1 = NodeBuilder.BuildNode().Host(IPAddress.Loopback).WithPort(1337); 33 | var node2 = NodeBuilder.FromEndpoint(new IPEndPoint(IPAddress.Loopback, 1337)); 34 | 35 | var nodeDict = new Dictionary(); 36 | nodeDict.Add(node1, "test!"); 37 | 38 | Assert.Equal("test!", nodeDict[node2]); 39 | } 40 | 41 | #endregion 42 | } 43 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Topology/NodeTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using Helios.Topology; 7 | using Xunit; 8 | 9 | namespace Helios.Tests.Topology 10 | { 11 | public class NodeTests 12 | { 13 | #region Setup / Teardown 14 | 15 | #endregion 16 | 17 | #region Tests 18 | 19 | [Fact] 20 | public void Should_resolve_localhost_hostname_to_IP() 21 | { 22 | //arrange 23 | var testNode = 24 | NodeBuilder.BuildNode().Host("localhost").WithPort(1337).WithTransportType(TransportType.Udp); 25 | 26 | var expectNode = 27 | NodeBuilder.BuildNode().Host(IPAddress.Loopback).WithPort(1337).WithTransportType(TransportType.Udp); 28 | 29 | //act 30 | 31 | //assert 32 | Assert.Equal(expectNode, testNode); 33 | } 34 | 35 | [Fact] 36 | public void Should_resolve_remote_hostname_to_IP() 37 | { 38 | //arrange 39 | var testNode = 40 | NodeBuilder.BuildNode().Host("yahoo.com").WithPort(80).WithTransportType(TransportType.Tcp); 41 | 42 | //act 43 | 44 | //assert 45 | Assert.NotNull(testNode.Host); 46 | } 47 | 48 | #endregion 49 | } 50 | } -------------------------------------------------------------------------------- /src/Helios/Buffers/Unpooled.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | namespace Helios.Buffers 6 | { 7 | /// 8 | /// Utility class for managing and creating unpooled buffers 9 | /// 10 | public static class Unpooled 11 | { 12 | private static readonly IByteBufAllocator Alloc = UnpooledByteBufAllocator.Default; 13 | 14 | public static readonly IByteBuf Empty = Alloc.Buffer(0, 0); 15 | 16 | public static IByteBuf Buffer() 17 | { 18 | return Alloc.Buffer(); 19 | } 20 | 21 | public static IByteBuf Buffer(int initialCapacity) 22 | { 23 | return Alloc.Buffer(initialCapacity); 24 | } 25 | 26 | public static IByteBuf Buffer(int initialCapacity, int maxCapacity) 27 | { 28 | return Alloc.Buffer(initialCapacity, maxCapacity); 29 | } 30 | 31 | public static IByteBuf WrappedBuffer(byte[] bytes) 32 | { 33 | return WrappedBuffer(bytes, 0, bytes.Length); 34 | } 35 | 36 | public static IByteBuf WrappedBuffer(byte[] bytes, int index, int length) 37 | { 38 | if (bytes.Length == 0) 39 | return Empty; 40 | return Alloc.Buffer(bytes.Length).WriteBytes(bytes, index, length); 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/ScheduledAsyncTask.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | using Helios.Util.TimedOps; 8 | 9 | namespace Helios.Concurrency 10 | { 11 | internal abstract class ScheduledAsyncTask : ScheduledTask 12 | { 13 | private static readonly Action CancellationAction = s => ((ScheduledAsyncTask) s).Cancel(); 14 | private readonly CancellationToken _cancellationToken; 15 | private CancellationTokenRegistration _cancellationTokenRegistration; 16 | 17 | protected ScheduledAsyncTask(AbstractScheduledEventExecutor executor, PreciseDeadline deadline, 18 | TaskCompletionSource promise, CancellationToken cancellationToken) 19 | : base(executor, deadline, promise) 20 | { 21 | _cancellationToken = cancellationToken; 22 | _cancellationTokenRegistration = cancellationToken.Register(CancellationAction, this); 23 | } 24 | 25 | public override void Run() 26 | { 27 | _cancellationTokenRegistration.Dispose(); 28 | if (_cancellationToken.IsCancellationRequested) 29 | { 30 | Promise.TrySetCanceled(); 31 | } 32 | else 33 | { 34 | base.Run(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Bootstrap/DefaultNameResolver.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Linq; 6 | using System.Net; 7 | using System.Net.Sockets; 8 | using System.Threading.Tasks; 9 | 10 | namespace Helios.Channels.Bootstrap 11 | { 12 | public class DefaultNameResolver : INameResolver 13 | { 14 | public bool IsResolved(EndPoint address) 15 | { 16 | return !(address is DnsEndPoint); 17 | } 18 | 19 | public async Task ResolveAsync(EndPoint address) 20 | { 21 | var asDns = address as DnsEndPoint; 22 | if (asDns != null) 23 | { 24 | var resolved = await Dns.GetHostEntryAsync(asDns.Host); 25 | return new IPEndPoint(resolved.AddressList[0], asDns.Port); 26 | } 27 | return address; 28 | } 29 | 30 | public async Task ResolveAsync(EndPoint address, AddressFamily preferredFamily) 31 | { 32 | var asDns = address as DnsEndPoint; 33 | if (asDns != null) 34 | { 35 | var resolved = await Dns.GetHostEntryAsync(asDns.Host); 36 | return new IPEndPoint(resolved.AddressList.First(x => x.AddressFamily == preferredFamily), asDns.Port); 37 | } 38 | return address; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Helios/Concurrency/TaskCompletionSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | 7 | namespace Helios.Concurrency 8 | { 9 | /// 10 | /// Non-generic implementation of a 11 | /// 12 | public sealed class TaskCompletionSource : TaskCompletionSource 13 | { 14 | public static readonly TaskCompletionSource Void = CreateVoidTcs(); 15 | 16 | public TaskCompletionSource() 17 | { 18 | } 19 | 20 | public TaskCompletionSource(object state) 21 | : base(state) 22 | { 23 | } 24 | 25 | public bool TryComplete() 26 | { 27 | return TrySetResult(0); 28 | } 29 | 30 | public void Complete() 31 | { 32 | SetResult(0); 33 | } 34 | 35 | public bool SetUncancellable() 36 | { 37 | return true; 38 | } 39 | 40 | public override string ToString() 41 | { 42 | return "TaskCompletionSource[status: " + Task.Status + "]"; 43 | } 44 | 45 | private static TaskCompletionSource CreateVoidTcs() 46 | { 47 | var tcs = new TaskCompletionSource(); 48 | tcs.TryComplete(); 49 | return tcs; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/Helios/Reactor/Response/ReactorProxyResponseChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using System.Net.Sockets; 7 | using Helios.Channels; 8 | using Helios.Net; 9 | 10 | namespace Helios.Reactor.Response 11 | { 12 | /// 13 | /// Response channel receives all of its events directly from the and doesn't maintain any 14 | /// internal buffers, 15 | /// nor does it directly interact with its socket in any way 16 | /// 17 | public class ReactorProxyResponseChannel : ReactorResponseChannel 18 | { 19 | public ReactorProxyResponseChannel(ReactorBase reactor, Socket outboundSocket, NetworkEventLoop eventLoop) 20 | : base(reactor, outboundSocket, eventLoop) 21 | { 22 | } 23 | 24 | public ReactorProxyResponseChannel(ReactorBase reactor, Socket outboundSocket, IPEndPoint endPoint, 25 | NetworkEventLoop eventLoop) 26 | : base(reactor, outboundSocket, endPoint, eventLoop) 27 | { 28 | } 29 | 30 | public override void Configure(IConnectionConfig config) 31 | { 32 | } 33 | 34 | protected override void BeginReceiveInternal() 35 | { 36 | } 37 | 38 | protected override void StopReceiveInternal() 39 | { 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Helios/Channels/SingleThreadEventLoop.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading.Tasks; 7 | using Helios.Concurrency; 8 | 9 | namespace Helios.Channels 10 | { 11 | /// 12 | /// Single threaded implementation built on top of 13 | /// 14 | public class SingleThreadEventLoop : SingleThreadEventExecutor, IEventLoop 15 | { 16 | private static readonly TimeSpan DefaultBreakoutInterval = TimeSpan.FromMilliseconds(100); 17 | 18 | public SingleThreadEventLoop() : this(null, DefaultBreakoutInterval) 19 | { 20 | } 21 | 22 | public SingleThreadEventLoop(string threadName) : this(threadName, DefaultBreakoutInterval) 23 | { 24 | } 25 | 26 | public SingleThreadEventLoop(string threadName, TimeSpan breakoutInterval) : base(threadName, breakoutInterval) 27 | { 28 | Invoker = new DefaultChannelHandlerInvoker(this); 29 | } 30 | 31 | public IChannelHandlerInvoker Invoker { get; } 32 | 33 | public Task RegisterAsync(IChannel channel) 34 | { 35 | return channel.Unsafe.RegisterAsync(this); 36 | } 37 | 38 | public new IEventLoop Unwrap() 39 | { 40 | return this; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /src/Helios/Net/MulticastHelper.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using System.Net.Sockets; 7 | using System.Text.RegularExpressions; 8 | 9 | namespace Helios.Net 10 | { 11 | /// 12 | /// Class used to help with some UDP-specific connection properties 13 | /// 14 | public static class MulticastHelper 15 | { 16 | public static readonly string MulticastIPv4AddressRangeRegex = 17 | @"\b(22[0-4]|23[0-9])\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b"; 18 | 19 | private static readonly Regex MRegex = new Regex(MulticastIPv4AddressRangeRegex); 20 | 21 | /* 22 | * IPv4 multicast address range: 224.0.0.0 to 239.255.255.255 23 | * IPv6 multicast address range: 24 | */ 25 | 26 | public static bool IsValidMulticastAddress(IPAddress address) 27 | { 28 | switch (address.AddressFamily) 29 | { 30 | case AddressFamily.InterNetwork: //IPv4 31 | return MRegex.IsMatch(address.ToString()); 32 | case AddressFamily.InterNetworkV6: //IPv6 33 | return address.IsIPv6Multicast; 34 | default: 35 | return false; 36 | } 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Helios/Channels/Sockets/SocketChannelAsyncOperation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics.Contracts; 8 | using System.Linq; 9 | using System.Net.Sockets; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | using Helios.Util; 13 | 14 | namespace Helios.Channels.Sockets 15 | { 16 | public class SocketChannelAsyncOperation : SocketAsyncEventArgs 17 | { 18 | public SocketChannelAsyncOperation(AbstractSocketChannel channel) 19 | : this(channel, true) 20 | { 21 | } 22 | 23 | public SocketChannelAsyncOperation(AbstractSocketChannel channel, bool setEmptyBuffer) 24 | { 25 | Contract.Requires(channel != null); 26 | 27 | this.Channel = channel; 28 | this.Completed += AbstractSocketChannel.IoCompletedCallback; 29 | if (setEmptyBuffer) 30 | { 31 | this.SetBuffer(ByteArrayExtensions.Empty, 0, 0); 32 | } 33 | } 34 | 35 | public void Validate() 36 | { 37 | SocketError socketError = this.SocketError; 38 | if (socketError != SocketError.Success) 39 | { 40 | throw new SocketException((int) socketError); 41 | } 42 | } 43 | 44 | public AbstractSocketChannel Channel { get; private set; } 45 | } 46 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Ops/NetworkEventLoopTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Threading; 7 | using System.Threading.Tasks; 8 | using Helios.Ops; 9 | using Helios.Util; 10 | using Xunit; 11 | 12 | namespace Helios.Tests.Ops 13 | { 14 | public class NetworkEventLoopTests 15 | { 16 | #region Tests 17 | 18 | [Fact] 19 | public void Should_be_able_to_change_NetworkEventLoop_error_handler_at_runtime() 20 | { 21 | var eventLoop = EventLoopFactory.CreateNetworkEventLoop(); 22 | var count = new AtomicCounter(0); 23 | var trappedException = false; 24 | var backgroundProducer = Task.Run(() => 25 | { 26 | for (var i = 0; i < 10; i++) 27 | { 28 | eventLoop.Execute(() => count.GetAndIncrement()); 29 | Thread.Sleep(10); 30 | } 31 | }); 32 | 33 | eventLoop.SetExceptionHandler((connection, exception) => trappedException = true, null); 34 | eventLoop.Execute(() => { throw new Exception("I'm an exception!"); }); 35 | 36 | backgroundProducer.Wait(); 37 | 38 | Assert.Equal(10, count.Current); 39 | Assert.True(trappedException); 40 | } 41 | 42 | #endregion 43 | 44 | #region Setup / Teardown 45 | 46 | #endregion 47 | } 48 | } -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/TestLogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Concurrent; 6 | using Helios.Logging; 7 | 8 | namespace Helios.FsCheck.Tests 9 | { 10 | /// 11 | /// implementation used for debugging and testing purposes. 12 | /// 13 | public class TestLogger : LoggingAdapter 14 | { 15 | public TestLogger(string logSource) : base(logSource) 16 | { 17 | } 18 | 19 | public TestLogger(string logSource, params LogLevel[] supportedLogLevels) : base(logSource, supportedLogLevels) 20 | { 21 | } 22 | 23 | public ConcurrentQueue Events { get; } = new ConcurrentQueue(); 24 | 25 | protected override void DebugInternal(Debug message) 26 | { 27 | QueueMessage(message); 28 | } 29 | 30 | protected override void InfoInternal(Info message) 31 | { 32 | QueueMessage(message); 33 | } 34 | 35 | protected override void WarningInternal(Warning message) 36 | { 37 | QueueMessage(message); 38 | } 39 | 40 | protected override void ErrorInternal(Error message) 41 | { 42 | QueueMessage(message); 43 | } 44 | 45 | private void QueueMessage(LogEvent message) 46 | { 47 | Events.Enqueue(message); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /src/Helios/Channels/DefaultConnectionConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using Helios.Net; 8 | using Helios.Util.Collections; 9 | 10 | namespace Helios.Channels 11 | { 12 | /// 13 | /// Configuration class for objects 14 | /// 15 | public class DefaultConnectionConfig : IConnectionConfig 16 | { 17 | private readonly Dictionary _options = new Dictionary(); 18 | 19 | public IConnectionConfig SetOption(string optionKey, object optionValue) 20 | { 21 | _options[optionKey] = optionValue; 22 | return this; 23 | } 24 | 25 | public bool HasOption(string optionKey) 26 | { 27 | return _options.ContainsKey(optionKey); 28 | } 29 | 30 | public bool HasOption(string optionKey) 31 | { 32 | return _options.ContainsKey(optionKey) && _options[optionKey] is T; 33 | } 34 | 35 | public object GetOption(string optionKey) 36 | { 37 | return _options.GetOrDefault(optionKey); 38 | } 39 | 40 | public T GetOption(string optionKey) 41 | { 42 | return _options.GetOrDefault(optionKey); 43 | } 44 | 45 | public IList> Options => _options.ToList(); 46 | } 47 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Channels/IntCodec.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading.Tasks; 6 | using Helios.Buffers; 7 | using Helios.Channels; 8 | using Helios.Util; 9 | 10 | namespace Helios.Tests.Channels 11 | { 12 | public class IntCodec : ChannelHandlerAdapter 13 | { 14 | public IntCodec(bool releaseMessages = false) 15 | { 16 | ReleaseMessages = releaseMessages; 17 | } 18 | 19 | public bool ReleaseMessages { get; } 20 | 21 | public override void ChannelRead(IChannelHandlerContext context, object message) 22 | { 23 | if (message is IByteBuf) 24 | { 25 | var buf = (IByteBuf) message; 26 | var integer = buf.ReadInt(); 27 | if (ReleaseMessages) 28 | ReferenceCountUtil.SafeRelease(message); 29 | context.FireChannelRead(integer); 30 | } 31 | else 32 | { 33 | context.FireChannelRead(message); 34 | } 35 | } 36 | 37 | public override Task WriteAsync(IChannelHandlerContext context, object message) 38 | { 39 | if (message is int) 40 | { 41 | var buf = Unpooled.Buffer(4).WriteInt((int) message); 42 | return context.WriteAsync(buf); 43 | } 44 | return context.WriteAsync(message); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /src/Helios/Util/NullGuard.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace Helios.Util 9 | { 10 | /// 11 | /// A static helper class for protecting against pesky null reference errors 12 | /// 13 | public static class NullGuard 14 | { 15 | public static void NotNull(this object obj) 16 | { 17 | if (obj == null) 18 | throw new ArgumentNullException("obj"); 19 | } 20 | 21 | public static TOut NotNull(this TIn obj, Func nextOp) 22 | where TOut : class 23 | where TIn : class 24 | { 25 | if (obj == null) 26 | return default(TOut); 27 | return nextOp.Invoke(obj); 28 | } 29 | 30 | public static void NotNull(this TIn obj, Action nextOp) where TIn : class 31 | { 32 | if (obj == null) 33 | return; 34 | nextOp.Invoke(obj); 35 | } 36 | 37 | public static void InitializeIfNull(this IEnumerable obj, int initialSize = 10) 38 | { 39 | if (obj == null) obj = new List(initialSize); 40 | } 41 | 42 | public static void InitializeIfNull(this TIn obj, TIn defaultValue) where TIn : class 43 | { 44 | if (obj == null) obj = defaultValue; 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Util/Collections/CircularBufferTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Linq; 6 | using System.Text; 7 | using Helios.Util.Collections; 8 | using Xunit; 9 | 10 | namespace Helios.Tests.Util.Collections 11 | { 12 | public class CircularBufferTests 13 | { 14 | protected virtual ICircularBuffer GetBuffer(int capacity) 15 | { 16 | return new CircularBuffer(capacity); 17 | } 18 | 19 | 20 | /// 21 | /// If a circular buffer is defined with a fixed maximum capacity, it should 22 | /// simply overwrite the old elements even if they haven't been dequed 23 | /// 24 | [Fact] 25 | public void CircularBuffer_should_not_expand() 26 | { 27 | var byteArrayOne = Encoding.Unicode.GetBytes("ONE STRING"); 28 | var byteArrayTwo = Encoding.Unicode.GetBytes("TWO STRING"); 29 | var buffer = GetBuffer(byteArrayOne.Length); 30 | buffer.Enqueue(byteArrayOne); 31 | Assert.Equal(buffer.Size, buffer.Capacity); 32 | buffer.Enqueue(byteArrayTwo); 33 | Assert.Equal(buffer.Size, buffer.Capacity); 34 | var availableBytes = buffer.DequeueAll().ToArray(); 35 | Assert.False(byteArrayOne.SequenceEqual(availableBytes)); 36 | Assert.True(byteArrayTwo.SequenceEqual(availableBytes)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Helios/Ops/OperationResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace Helios.Ops 9 | { 10 | public class OperationResult : IOperationResult 11 | { 12 | protected OperationResult() 13 | { 14 | Errors = new Dictionary(); 15 | Generated = DateTimeOffset.UtcNow; 16 | } 17 | 18 | public int StatusCode { get; private set; } 19 | public bool IsSuccess { get; private set; } 20 | public string Message { get; private set; } 21 | public DateTimeOffset Generated { get; } 22 | public IDictionary Errors { get; } 23 | 24 | public static OperationResult Create(int statusCode, bool isSuccess, string message) 25 | { 26 | return new OperationResult {StatusCode = statusCode, IsSuccess = isSuccess, Message = message}; 27 | } 28 | 29 | public static OperationResult Create(int statusCode, bool isSuccess, string message, T payload) 30 | { 31 | return new OperationResult 32 | { 33 | StatusCode = statusCode, 34 | IsSuccess = isSuccess, 35 | Message = message, 36 | Payload = payload 37 | }; 38 | } 39 | } 40 | 41 | public class OperationResult : OperationResult, IOperationResult 42 | { 43 | public T Payload { get; set; } 44 | } 45 | } -------------------------------------------------------------------------------- /src/Helios/Topology/INode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Net; 7 | 8 | namespace Helios.Topology 9 | { 10 | public interface INode : ICloneable 11 | { 12 | /// 13 | /// The IP address of this seed 14 | /// 15 | IPAddress Host { get; set; } 16 | 17 | /// 18 | /// The port number of this node's capability 19 | /// 20 | int Port { get; set; } 21 | 22 | /// 23 | /// The connection type used by this node 24 | /// 25 | TransportType TransportType { get; set; } 26 | 27 | /// 28 | /// The name of this machine 29 | /// 30 | string MachineName { get; set; } 31 | 32 | /// 33 | /// OS name and version of this machine 34 | /// 35 | string OS { get; set; } 36 | 37 | /// 38 | /// version of the service running on this node 39 | /// 40 | string ServiceVersion { get; set; } 41 | 42 | /// 43 | /// A JSON blob representing arbitrary data about this node 44 | /// 45 | string CustomData { get; set; } 46 | 47 | /// 48 | /// Converts the node to an 49 | /// 50 | IPEndPoint ToEndPoint(); 51 | } 52 | } -------------------------------------------------------------------------------- /src/Helios/Tracing/HeliosTrace.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Tracing.Impl; 6 | using Helios.Util; 7 | 8 | namespace Helios.Tracing 9 | { 10 | /// 11 | /// Static class that acts as a container for all built-in tracing 12 | /// that can occur inside Helios core. 13 | /// Does not expose definitions for user-defined tracing (yet.) 14 | /// 15 | public static class HeliosTrace 16 | { 17 | /// 18 | /// The default . 19 | /// 20 | public static readonly IHeliosTraceWriter Default = new NoOpHeliosTraceWriter(); 21 | 22 | /// 23 | /// The global instance of the helios will use for internal tracing. 24 | /// 25 | public static IHeliosTraceWriter Instance { get; private set; } = Default; 26 | 27 | /// 28 | /// Set the that will be used across all built-in Helios calls. 29 | /// Not synchronized, and not intended to be called in concurrent code. 30 | /// 31 | /// The implementation that will be used internally 32 | public static void SetWriter(IHeliosTraceWriter writer) 33 | { 34 | Guard.True(writer != null); 35 | Instance = writer; 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Helios/Ops/IOperationResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace Helios.Ops 9 | { 10 | /// 11 | /// Returns meta-data used to process the results of critical operations, such 12 | /// as working with a service repository 13 | /// 14 | public interface IOperationResult 15 | { 16 | /// 17 | /// A status code representing the outcome of an operation 18 | /// 19 | int StatusCode { get; } 20 | 21 | /// 22 | /// true if the operation was successful, false otherwise 23 | /// 24 | bool IsSuccess { get; } 25 | 26 | /// 27 | /// A human-readable message describing the outcome of the operation 28 | /// 29 | string Message { get; } 30 | 31 | /// 32 | /// The time this operation was generated (in UTC) 33 | /// 34 | DateTimeOffset Generated { get; } 35 | 36 | /// 37 | /// A list of errors that occurred during the operation 38 | /// 39 | IDictionary Errors { get; } 40 | } 41 | 42 | public interface IOperationResult : IOperationResult 43 | { 44 | /// 45 | /// An object payload to return to the caller 46 | /// 47 | T Payload { get; set; } 48 | } 49 | } -------------------------------------------------------------------------------- /src/Helios/Eventing/IEventBroker.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System; 6 | 7 | namespace Helios.Eventing 8 | { 9 | /// 10 | /// An interface for notifying classes inside a single process about 11 | /// available events. 12 | /// Truth be told - this class can be used over sockets and inter-process communication; it's 13 | /// a configuration detail. 14 | /// 15 | /// The type used to identify the topic 16 | /// The type used to identify the subscriber 17 | public interface IEventBroker 18 | { 19 | event EventHandler> SubscriptionAdded; 20 | event EventHandler> SubscriptionRemoved; 21 | 22 | void Subscribe(TTopic id, TSubscriber subscriber, ITopicSubscription normalTopicSubscription); 23 | 24 | void Unsubscribe(TTopic id, TSubscriber subscriber); 25 | 26 | /// 27 | /// Fire the event with the topic specified by the identifier 28 | /// with its associated sender and parameters 29 | /// 30 | /// The id of the event to fire 31 | /// The object responsible for firing the event 32 | /// The arguments for this event 33 | void InvokeEvent(TTopic id, object sender, EventArgs e); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Helios/Util/Collections/IFixedSizeStack.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | 8 | namespace Helios.Util.Collections 9 | { 10 | public interface IFixedSizeStack : IEnumerable, ICollection 11 | { 12 | int Capacity { get; } 13 | T Peek(); 14 | T Pop(); 15 | void Push(T item); 16 | T[] ToArray(); 17 | void Clear(); 18 | 19 | /// 20 | /// Copies the contents of the FixedSizeStack into a new array 21 | /// 22 | /// The destination array for the copy 23 | /// The starting index for copying in the destination array 24 | /// The number of items to copy from the current buffer (max value = current Size of buffer) 25 | void CopyTo(T[] array, int index, int count); 26 | 27 | /// 28 | /// Copies the contents of the FixedSizeStack into a new array 29 | /// 30 | /// The destination array for the copy 31 | void CopyTo(T[] array); 32 | 33 | /// 34 | /// Copies the contents of the FixedSizeStack into a new array 35 | /// 36 | /// The destination array for the copy 37 | /// The starting index for copying in the destination array 38 | void CopyTo(T[] array, int index); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Helios/Channels/IChannel.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Net; 6 | using System.Threading.Tasks; 7 | using Helios.Buffers; 8 | using Helios.Concurrency; 9 | 10 | namespace Helios.Channels 11 | { 12 | public interface IChannel 13 | { 14 | IChannelId Id { get; } 15 | 16 | IByteBufAllocator Allocator { get; } 17 | 18 | IEventLoop EventLoop { get; } 19 | 20 | IChannel Parent { get; } 21 | 22 | bool DisconnectSupported { get; } 23 | 24 | bool IsOpen { get; } 25 | 26 | bool IsActive { get; } 27 | 28 | bool Registered { get; } 29 | 30 | EndPoint LocalAddress { get; } 31 | 32 | EndPoint RemoteAddress { get; } 33 | 34 | bool IsWritable { get; } 35 | 36 | IChannelUnsafe Unsafe { get; } 37 | 38 | IChannelPipeline Pipeline { get; } 39 | 40 | IChannelConfiguration Configuration { get; } 41 | 42 | Task CloseCompletion { get; } 43 | 44 | Task DeregisterAsync(); 45 | 46 | Task BindAsync(EndPoint localAddress); 47 | 48 | Task ConnectAsync(EndPoint remoteAddress); 49 | 50 | Task ConnectAsync(EndPoint remoteAddress, EndPoint localAddress); 51 | 52 | Task DisconnectAsync(); 53 | 54 | Task CloseAsync(); 55 | 56 | // todo: make these available through separate interface to hide them from public API on channel 57 | 58 | IChannel Read(); 59 | 60 | Task WriteAsync(object message); 61 | 62 | IChannel Flush(); 63 | 64 | Task WriteAndFlushAsync(object message); 65 | } 66 | } -------------------------------------------------------------------------------- /src/Helios/Net/Transports/ITransport.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading; 6 | using System.Threading.Tasks; 7 | 8 | namespace Helios.Net.Transports 9 | { 10 | /// 11 | /// Interface used to place an I/O interface 12 | /// on top of a connection 13 | /// 14 | public interface ITransport 15 | { 16 | bool Peek(); 17 | 18 | int Read(byte[] buffer, int offset, int length); 19 | 20 | int ReadAll(byte[] buffer, int offset, int length); 21 | 22 | void Write(byte[] buffer); 23 | 24 | void Write(byte[] buffer, int offset, int length); 25 | 26 | void Flush(); 27 | 28 | #if !NET35 && !NET40 29 | 30 | Task ReadAsync(byte[] buffer, int offset, int length); 31 | 32 | Task ReadAsync(byte[] buffer, int offset, int length, CancellationToken token); 33 | #endif 34 | 35 | #if !NET35 && !NET40 36 | Task ReadAllAsync(byte[] buffer, int offset, int length); 37 | 38 | Task ReadAllAsync(byte[] buffer, int offset, int length, CancellationToken token); 39 | #endif 40 | 41 | #if !NET35 && !NET40 42 | Task WriteAsync(byte[] buffer); 43 | 44 | Task WriteAsync(byte[] buffer, CancellationToken token); 45 | 46 | Task WriteAsync(byte[] buffer, int offset, int length); 47 | 48 | Task WriteAsync(byte[] buffer, int offset, int length, CancellationToken token); 49 | #endif 50 | 51 | #if !NET35 && !NET40 52 | Task FlushAsync(); 53 | 54 | Task FlushAsync(CancellationToken token); 55 | #endif 56 | } 57 | } -------------------------------------------------------------------------------- /tests/Helios.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.Tests.Core")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.Tests.Core")] 17 | [assembly: AssemblyCopyright("Copyright © 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("11c47b21-6174-4ab2-bdd9-45cb48b6ec8f")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /samples/Helios.RawSocket/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.RawSocket")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.RawSocket")] 17 | [assembly: AssemblyCopyright("Copyright © 2014")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("9d2a488a-6344-402c-a810-5dd0c5482ad0")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /samples/Helios.RawUdpSocket/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.RawUdpSocket")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.RawUdpSocket")] 17 | [assembly: AssemblyCopyright("Copyright © 2014")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("c81c6edc-2c66-4501-9e6b-875591e3b16c")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /tests/Helios.FsCheck.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.FsCheck.Tests")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.FsCheck.Tests")] 17 | [assembly: AssemblyCopyright("Copyright © 2016")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("8ed071c0-55c7-4b47-89b2-f68bc58d9590")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /tests/Helios.MultiNodeTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.MultiNodeTests")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.MultiNodeTests")] 17 | [assembly: AssemblyCopyright("Copyright © 2014")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("bb55c8ad-6d7d-4b68-bf55-795f0a095116")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /samples/TimeService/TimeServiceClient/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("TimeServiceClient")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("TimeServiceClient")] 17 | [assembly: AssemblyCopyright("Copyright © 2014")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("931bf64e-2cf9-4f34-b8bf-c9cd17b35d3e")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /samples/TimeService/TimeServiceServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("TimeServiceServer")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("TimeServiceServer")] 17 | [assembly: AssemblyCopyright("Copyright © 2014")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("46dc387c-96e2-46d0-8cae-c4dd39b1e4c6")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /src/Helios/Channels/FixedRecvByteBufAllocator.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using Helios.Buffers; 6 | 7 | namespace Helios.Channels 8 | { 9 | /// 10 | /// A that always yields the same buffer size prediction; 11 | /// ignores feedback from the I/O thread. 12 | /// 13 | public sealed class FixedRecvByteBufAllocator : IRecvByteBufAllocator 14 | { 15 | public static readonly FixedRecvByteBufAllocator Default = new FixedRecvByteBufAllocator(4*1024); 16 | 17 | private readonly IRecvByteBufferAllocatorHandle _handle; 18 | 19 | public FixedRecvByteBufAllocator(int bufferSize) 20 | { 21 | _handle = new Handle(bufferSize); 22 | } 23 | 24 | public IRecvByteBufferAllocatorHandle NewHandle() 25 | { 26 | return _handle; 27 | } 28 | 29 | private sealed class Handle : IRecvByteBufferAllocatorHandle 30 | { 31 | private readonly int _bufferSize; 32 | 33 | public Handle(int bufferSize) 34 | { 35 | _bufferSize = bufferSize; 36 | } 37 | 38 | public IByteBuf Allocate(IByteBufAllocator allocator) 39 | { 40 | return allocator.Buffer(_bufferSize); 41 | } 42 | 43 | public int Guess() 44 | { 45 | return _bufferSize; 46 | } 47 | 48 | public void Record(int actualReadBytes) 49 | { 50 | // no-op 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Channels/IReadFinishedSignal.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Threading; 6 | using Helios.Concurrency; 7 | 8 | namespace Helios.Tests.Performance.Channels 9 | { 10 | public interface IReadFinishedSignal 11 | { 12 | bool Finished { get; } 13 | void Signal(); 14 | } 15 | 16 | public class ManualResetEventSlimReadFinishedSignal : IReadFinishedSignal 17 | { 18 | private readonly ManualResetEventSlim _manualResetEventSlim; 19 | 20 | public ManualResetEventSlimReadFinishedSignal(ManualResetEventSlim manualResetEventSlim) 21 | { 22 | _manualResetEventSlim = manualResetEventSlim; 23 | } 24 | 25 | public void Signal() 26 | { 27 | _manualResetEventSlim.Set(); 28 | } 29 | 30 | public bool Finished => _manualResetEventSlim.IsSet; 31 | } 32 | 33 | public class TaskCompletionSourceFinishedSignal : IReadFinishedSignal 34 | { 35 | private readonly TaskCompletionSource _tcs; 36 | 37 | public TaskCompletionSourceFinishedSignal(TaskCompletionSource tcs) 38 | { 39 | _tcs = tcs; 40 | } 41 | 42 | public void Signal() 43 | { 44 | _tcs.TryComplete(); 45 | } 46 | 47 | public bool Finished => _tcs.Task.IsCompleted; 48 | } 49 | 50 | public class SimpleReadFinishedSignal : IReadFinishedSignal 51 | { 52 | public void Signal() 53 | { 54 | Finished = true; 55 | } 56 | 57 | public bool Finished { get; private set; } 58 | } 59 | } -------------------------------------------------------------------------------- /benchmark/Helios.Tests.Performance/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.Tests.Performance")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.Tests.Performance")] 17 | [assembly: AssemblyCopyright("Copyright © 2016")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("86fea7af-a3bc-46fe-9492-8f4bde8f1a1b")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /tests/Helios.BackwardsCompat.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.BackwardsCompat.Tests")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.BackwardsCompat.Tests")] 17 | [assembly: AssemblyCopyright("Copyright © 2016")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("38a9e142-ba8b-46d2-a333-39eb405ed6eb")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /benchmark/Helios.Benchmark.SocketReliability/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.Benchmark.TCPThroughput")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.Benchmark.TCPThroughput")] 17 | [assembly: AssemblyCopyright("Copyright © 2015")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("f45b5507-2df5-4d5f-a37d-9fb29c26f10b")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /benchmark/Helios.Benchmark.TCPThroughput/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.Benchmark.TCPThroughput")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.Benchmark.TCPThroughput")] 17 | [assembly: AssemblyCopyright("Copyright © 2015")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("fb4ccb2b-3b78-47c7-afbf-010e92a3f934")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] -------------------------------------------------------------------------------- /samples/Helios.Samples.TcpDownloadServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Petabridge . All rights reserved. 2 | // Licensed under the Apache 2.0 license. See LICENSE file in the project root for full license information. 3 | // See ThirdPartyNotices.txt for references to third party code used inside Helios. 4 | 5 | using System.Reflection; 6 | using System.Runtime.InteropServices; 7 | 8 | // General Information about an assembly is controlled through the following 9 | // set of attributes. Change these attribute values to modify the information 10 | // associated with an assembly. 11 | 12 | [assembly: AssemblyTitle("Helios.Samples.TcpDownloadServer")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("Helios.Samples.TcpDownloadServer")] 17 | [assembly: AssemblyCopyright("Copyright © 2013")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // Setting ComVisible to false makes the types in this assembly not visible 22 | // to COM components. If you need to access a type in this assembly from 23 | // COM, set the ComVisible attribute to true on that type. 24 | 25 | [assembly: ComVisible(false)] 26 | 27 | // The following GUID is for the ID of the typelib if this project is exposed to COM 28 | 29 | [assembly: Guid("864e5581-91af-4e8a-8f19-9b19cd4b5022")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | 42 | [assembly: AssemblyVersion("1.0.0.0")] 43 | [assembly: AssemblyFileVersion("1.0.0.0")] --------------------------------------------------------------------------------