├── .github └── workflows │ └── dotnet.yml ├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Directory.Build.props ├── LICENSE ├── README.md ├── appveyor.yml ├── src ├── Vlingo.Xoom.Actors.Tests │ ├── ActorEnvironmentTest.cs │ ├── ActorFactoryTest.cs │ ├── ActorLifecycleTest.cs │ ├── ActorMessageSendingSpeedTest.cs │ ├── ActorProxyBaseTest.cs │ ├── ActorProxyTest.cs │ ├── ActorStopTest.cs │ ├── ActorStowDisperseTest.cs │ ├── ActorSuspendResumeTest.cs │ ├── ActorsTest.cs │ ├── AddressTest.cs │ ├── AnswerEventuallyTest.cs │ ├── BroadcastRouterTest.cs │ ├── CharactersTest.cs │ ├── CompletesActorProtocolTest.cs │ ├── ConfigurationTest.cs │ ├── ContentBasedRouterTest.cs │ ├── Converter.cs │ ├── DeadLettersTest.cs │ ├── DefinitionTest.cs │ ├── DirectoryTest.cs │ ├── DispatcherTest.cs │ ├── GenericWithConstraints__Proxy.cs │ ├── GuidAddressTest.cs │ ├── InterruptableActorTest.cs │ ├── LocalMessageTest.cs │ ├── MailboxConfigurationTest.cs │ ├── MockCompletes.cs │ ├── Plugin │ │ ├── Completes │ │ │ ├── MockCompletesEventually.cs │ │ │ ├── MockCompletesEventuallyProvider.cs │ │ │ ├── MockCompletesPlugin.cs │ │ │ ├── MockRegistrar.cs │ │ │ ├── PooledCompletesPluginTest.cs │ │ │ └── PooledCompletesProviderTest.cs │ │ ├── Logging │ │ │ └── ConsoleLoggerTest.cs │ │ ├── Mailbox │ │ │ ├── AgronaMPSCArrayQueue │ │ │ │ ├── ManyToOneConcurrentArrayQueueDispatcherTest.cs │ │ │ │ └── ManyToOneConcurrentArrayQueueMailboxActorTest.cs │ │ │ ├── ConcurrentQueue │ │ │ │ ├── ConcurrentQueueMailboxTest.cs │ │ │ │ └── ExecutorDispatcherTest.cs │ │ │ ├── DefaultMailboxProviderKeeperPluginTest.cs │ │ │ ├── DefaultMailboxProviderKeeperTest.cs │ │ │ ├── ICountTaker.cs │ │ │ ├── MailboxTypeTest.cs │ │ │ └── SharedRingBuffer │ │ │ │ ├── PropertiesFileConfigRingBufferMailboxActorTest.cs │ │ │ │ ├── RingBufferDispatcherTest.cs │ │ │ │ └── RingBufferMailboxActorTest.cs │ │ └── PluginPropertiesTest.cs │ ├── ProtocolsTest.cs │ ├── ProxyGeneratorTests.cs │ ├── ProxyLookupTest.cs │ ├── RandomRouterTest.cs │ ├── ReusableQueueMailboxTest.cs │ ├── RoundRobinRouterTest.cs │ ├── SchedulerTest.cs │ ├── SmallestMailboxRouterTest.cs │ ├── StageNamedTest.cs │ ├── StageSupervisedActorTest.cs │ ├── StageTest.cs │ ├── StowageTest.cs │ ├── Supervision │ │ ├── BasicSupervisionTest.cs │ │ ├── CommonSupervisionTest.cs │ │ ├── DefaultSupervisorOverrideTest.cs │ │ ├── EscalateSupervisorActor.cs │ │ ├── FailureControlActor.cs │ │ ├── IFailureControl.cs │ │ ├── IFailureControlSender.cs │ │ ├── IPing.cs │ │ ├── IPong.cs │ │ ├── PingActor.cs │ │ ├── PingSupervisorActor.cs │ │ ├── PongActor.cs │ │ ├── PongSupervisorActor.cs │ │ ├── RestartFiveInOneSupervisorActor.cs │ │ ├── RestartForeverSupervisorActor.cs │ │ ├── ResumeForeverSupervisorActor.cs │ │ ├── StopAllSupervisorActor.cs │ │ ├── SupervisionStrategyTest.cs │ │ └── SuspendedSenderSupervisorActor.cs │ ├── TaskActorProtocolTest.cs │ ├── TaskExtensionsTest.cs │ ├── TestActorInterfaces.cs │ ├── TestKit │ │ └── TestkitTest.cs │ ├── Vlingo.Xoom.Actors.Tests.csproj │ ├── WorldDefaultConfigurationTest.cs │ ├── WorldTest.cs │ └── vlingo-actors.json ├── Vlingo.Xoom.Actors.sln ├── Vlingo.Xoom.Actors.sln.licenseheader └── Vlingo.Xoom.Actors │ ├── Actor.cs │ ├── ActorAddressAlreadyRegisteredException.cs │ ├── ActorFactory.cs │ ├── ActorLoggerAdapter.cs │ ├── ActorProxy.cs │ ├── ActorProxyBase.cs │ ├── ActorProxyStub.cs │ ├── Addressable__Proxy.cs │ ├── Backoff.cs │ ├── BasicAddress.cs │ ├── BasicAddressFactory.cs │ ├── BroadcastRouter.cs │ ├── Cancellable__Proxy.cs │ ├── Characters.cs │ ├── CommonSupervisor.cs │ ├── CompletesEventuallyActor.cs │ ├── CompletesEventually__Proxy.cs │ ├── CompletionSupplier.cs │ ├── CompletionTranslator.cs │ ├── Configuration.cs │ ├── ContentBasedRouter.cs │ ├── DeadLetter.cs │ ├── DeadLettersActor.cs │ ├── DeadLettersListener__Proxy.cs │ ├── DeadLetters__Proxy.cs │ ├── DefaultSupervisionStrategyImpl.cs │ ├── DefaultSupervisor.cs │ ├── DefaultSupervisorImpl.cs │ ├── Definition.cs │ ├── Directory.cs │ ├── DirectoryEvictor.cs │ ├── DirectoryScannerActor.cs │ ├── DirectoryScanner__Proxy.cs │ ├── Environment.cs │ ├── Evictable.cs │ ├── ExecutorDispatcherAsync.cs │ ├── ExpressionExtensions.cs │ ├── FailureMark.cs │ ├── GuidAddress.cs │ ├── GuidAddressFactory.cs │ ├── IAddress.cs │ ├── IAddressFactory.cs │ ├── IAddressable.cs │ ├── ICompletesEventually.cs │ ├── ICompletesEventuallyProvider.cs │ ├── ICompletesEventuallyProviderKeeper.cs │ ├── IDeadLetters.cs │ ├── IDeadLettersListener.cs │ ├── IDirectoryScanner.cs │ ├── IDispatcher.cs │ ├── ILogger.cs │ ├── ILoggerProvider.cs │ ├── ILoggerProviderKeeper.cs │ ├── IMailbox.cs │ ├── IMailboxConfiguration.cs │ ├── IMailboxProvider.cs │ ├── IMailboxProviderKeeper.cs │ ├── IMessage.cs │ ├── INoProtocol.cs │ ├── IProxy.cs │ ├── IRegistrar.cs │ ├── IRelocatable.cs │ ├── ISafeProxyGenerable.cs │ ├── IStartable.cs │ ├── IStoppable.cs │ ├── ISupervised.cs │ ├── ISupervisionStrategy.cs │ ├── ISupervisor.cs │ ├── InvalidProtocolException.cs │ ├── LifeCycle.cs │ ├── LocalMessage.cs │ ├── LocalMessageAsync.cs │ ├── Logger__Proxy.cs │ ├── NoProtocol__Proxy.cs │ ├── Plugin │ ├── AbstractPlugin.cs │ ├── Completes │ │ ├── CompletesEventuallyPool.cs │ │ ├── DefaultCompletesEventuallyProviderKeeper.cs │ │ ├── PooledCompletesPlugin.cs │ │ └── PooledCompletesPluginConfiguration.cs │ ├── DynamicTypeLoader.cs │ ├── Eviction │ │ ├── DirectoryEvictionConfiguration.cs │ │ └── DirectoryEvictionPlugin.cs │ ├── IPlugin.cs │ ├── IPluginConfiguration.cs │ ├── IPluginTypeLoader.cs │ ├── Logging │ │ ├── Console │ │ │ ├── ConsoleLogger.cs │ │ │ ├── ConsoleLoggerActor.cs │ │ │ ├── ConsoleLoggerPlugin.cs │ │ │ └── ConsoleLoggerPluginConfiguration.cs │ │ ├── DefaultLoggerProviderKeeper.cs │ │ ├── LogEvent.cs │ │ └── NoOp │ │ │ ├── NoOpLogger.cs │ │ │ └── NoOpLoggerProvider.cs │ ├── Mailbox │ │ ├── AgronaMPSCArrayQueue │ │ │ ├── ManyToOneConcurrentArrayQueueDispatcher.cs │ │ │ ├── ManyToOneConcurrentArrayQueueMailbox.cs │ │ │ ├── ManyToOneConcurrentArrayQueuePlugin.cs │ │ │ └── ManyToOneConcurrentArrayQueuePluginConfiguration.cs │ │ ├── ConcurrentQueue │ │ │ ├── ConcurrentQueueMailbox.cs │ │ │ ├── ConcurrentQueueMailboxPlugin.cs │ │ │ ├── ConcurrentQueueMailboxPluginConfiguration.cs │ │ │ ├── ExecutorDispatcher.cs │ │ │ └── ThreadPoolExecutor.cs │ │ ├── DefaultMailboxProviderKeeper.cs │ │ ├── DefaultMailboxProviderKeeperPlugin.cs │ │ ├── DefaultMailboxProviderKeeperPluginConfiguration.cs │ │ ├── SharedRingBuffer │ │ │ ├── RingBufferDispatcher.cs │ │ │ ├── SharedRingBufferMailbox.cs │ │ │ ├── SharedRingBufferMailboxPlugin.cs │ │ │ └── SharedRingBufferMailboxPluginConfiguration.cs │ │ ├── SuspendedDeliveryOverrides.cs │ │ └── TestKit │ │ │ ├── TestMailbox.cs │ │ │ ├── TestMailboxPlugin.cs │ │ │ └── TestRuntimeDiscoverer.cs │ ├── PluginLoader.cs │ ├── PluginProperties.cs │ ├── PluginScanner.cs │ ├── StaticPluginTypeLoader.cs │ └── Supervision │ │ ├── CommonSupervisorsPlugin.cs │ │ ├── CommonSupervisorsPluginConfiguration.cs │ │ ├── ConfiguredSupervisor.cs │ │ ├── DefaultSupervisorOverride.cs │ │ ├── DefaultSupervisorOverridePlugin.cs │ │ ├── DefaultSupervisorOverridePluginConfiguration.cs │ │ └── DefinitionValues.cs │ ├── PooledCompletes.cs │ ├── PrivateRootActor.cs │ ├── Properties.cs │ ├── Protocols.cs │ ├── ProxyGenerator.cs │ ├── PubSub │ ├── AffectedSubscriptions.cs │ ├── Condition.cs │ ├── DefaultPublisher.cs │ ├── IMessage.cs │ ├── IPublisher.cs │ ├── ISubscriber.cs │ ├── Operation.cs │ ├── Subscriptions.cs │ └── Topic.cs │ ├── PublicRootActor.cs │ ├── RandomRouter.cs │ ├── ResultCompletes.cs │ ├── ResumingMailbox.cs │ ├── RoundRobinRouter.cs │ ├── Routee.cs │ ├── Router.cs │ ├── RouterSpecification.cs │ ├── Routing.cs │ ├── Scheduled__Proxy.cs │ ├── SmallestMailboxRouter.cs │ ├── Stage.cs │ ├── StageSupervisedActor.cs │ ├── Startable__Proxy.cs │ ├── Stoppable__Proxy.cs │ ├── Stowage.cs │ ├── StowedLocalMessage.cs │ ├── SupervisionStrategyConstants.cs │ ├── Supervisor__Proxy.cs │ ├── TaskExtensions.cs │ ├── TestAddressableActor.cs │ ├── TestKit │ ├── AccessSafely.cs │ ├── ITestStateView.cs │ ├── TestActor.cs │ ├── TestContext.cs │ ├── TestEnvironment.cs │ ├── TestState.cs │ ├── TestUntil.cs │ └── TestWorld.cs │ ├── Vlingo.Xoom.Actors.csproj │ ├── World.cs │ └── vlingo-actors.json └── vlingo-64x64.png /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: .NET 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ${{ matrix.os }} 13 | strategy: 14 | matrix: 15 | os: [ ubuntu-latest, windows-latest, macOS-latest ] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Setup .NET 6.0.x 20 | id: setup-dotnet6 21 | uses: actions/setup-dotnet@v1 22 | with: 23 | dotnet-version: 6.0.x 24 | - name: Restore dependencies 25 | id: restore-deps 26 | run: dotnet restore ./src/Vlingo.Xoom.Actors.sln 27 | - name: Build 28 | id: build 29 | run: dotnet build ./src/Vlingo.Xoom.Actors.sln --no-restore 30 | - name: Test 31 | id: test 32 | run: dotnet test ./src/Vlingo.Xoom.Actors.Tests/Vlingo.Xoom.Actors.Tests.csproj --no-build --verbosity normal 33 | - name: slack - GitHub Actions Slack integration 34 | uses: act10ns/slack@v1.2.2 35 | env: 36 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 37 | with: 38 | status: ${{ job.status }} 39 | steps: ${{ toJson(steps) }} 40 | if: always() -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## How to contribute to the vlingo/common 2 | 3 | #### **Did you find a bug?** 4 | 5 | * Make sure the bug was not already reported here: [Issues](https://github.com/vlingo-net/vlingo-net-actors/issues). 6 | 7 | * If nonexisting, open a new issue for the problem: [Open New Issue](https://github.com/vlingo-net/vlingo-net-actors/issues/new). Always provide a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. 8 | 9 | #### **Patches and bug fixes** 10 | 11 | * Open a new GitHub pull request with the patch. 12 | 13 | * Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. 14 | 15 | * It would be really nice if your followed the basic code format used prevelently. 16 | 17 | #### **Please don't reformat existing code** 18 | 19 | * Just because you don't like a given code style doesn't mean you have the authority to change it. Cosmeic changes add zero to little value. 20 | 21 | #### **New features and enhancements** 22 | 23 | * Email your post your suggestion and provide an example implementation. 24 | 25 | * After agreement open a PR or issue. 26 | 27 | #### **Direct questions to...** 28 | 29 | * Vaughn Vernon: vaughn at kalele dot io 30 | 31 | #### **Contribute to documentation** 32 | 33 | * Vaughn Vernon: vaughn at kalele dot io 34 | 35 | Thanks for your kind assistance! :smile: 36 | 37 | Vaughn Vernon and the Vlingo .NET team 38 | -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 1.10.1 4 | 5 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # xoom-net-actors 2 | 3 | [![Build status](https://ci.appveyor.com/api/projects/status/o1ajhxlf9i2q6gs7/branch/master?svg=true)](https://ci.appveyor.com/project/VlingoNetOwner/xoom-net-actors/branch/master) 4 | ![Build master](https://github.com/vlingo-net/xoom-net-actors/workflows/.NET/badge.svg) 5 | [![NuGet](https://img.shields.io/nuget/v/Vlingo.Xoom.Actors.svg)](https://www.nuget.org/packages/Vlingo.Xoom.Actors) 6 | [![Gitter](https://badges.gitter.im/vlingo-platform-net/community.svg)](https://gitter.im/vlingo-platform-net/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) 7 | 8 | Type safe Actor Model toolkit for reactive concurrency and resiliency using C# and other .NET languages. 9 | 10 | The xoom-net-actors toolkit is nearly full featured, so don't be fooled by the seemingly low version number. 11 | 12 | 13 | License (See LICENSE file for full license) 14 | ------------------------------------------- 15 | Copyright © 2012-2021 VLINGO LABS. All rights reserved. 16 | 17 | This Source Code Form is subject to the terms of the 18 | Mozilla Public License, v. 2.0. If a copy of the MPL 19 | was not distributed with this file, You can obtain 20 | one at https://mozilla.org/MPL/2.0/. 21 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.10.1.{build} 2 | image: 3 | - Visual Studio 2022 4 | - Ubuntu 5 | - macOS 6 | - macOS-Monterey 7 | - macOS-Bigsur 8 | configuration: Release 9 | skip_commits: 10 | message: /.*\[ci\-skip\].*/ 11 | before_build: 12 | - dotnet restore src/Vlingo.Xoom.Actors.sln 13 | build: 14 | project: src/Vlingo.Xoom.Actors.sln 15 | verbosity: minimal 16 | publish_nuget: true 17 | test_script: 18 | - dotnet test src/Vlingo.Xoom.Actors.Tests 19 | deploy: 20 | - provider: NuGet 21 | api_key: 22 | secure: 4VJZEFZNaDrk3FJmRSmBW+wQugDoPi6DtVlsLZ+26IOo+wb0u9JlnTOTQF+NXs2s 23 | skip_symbols: true 24 | artifact: /.*\.nupkg/ 25 | on: 26 | branch: master 27 | notifications: 28 | - provider: Webhook 29 | url: https://webhooks.gitter.im/e/37621a855e91c31ab1da 30 | method: POST 31 | on_build_success: true 32 | on_build_failure: true 33 | on_build_status_changed: true -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/ActorProxyTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Threading; 9 | using Vlingo.Xoom.Actors.Plugin.Mailbox.TestKit; 10 | using Vlingo.Xoom.Common; 11 | using Xunit; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests; 14 | 15 | public class ActorProxyTest 16 | { 17 | private static readonly AtomicReference UnderTest = new("UNKNOWN"); 18 | private static readonly CountdownEvent Latch = new(1); 19 | 20 | private readonly Thread _runtimeStartWorldThread = new(() => 21 | { 22 | TestRuntimeDiscoverer.IsTestDetectionDeactivated = true; 23 | var world = World.StartWithDefaults("StartForMain"); 24 | UnderTest.Set(world.ResolveDynamic(ActorProxy.InternalActorProxyForTestId) ? "TRUE" : "FALSE"); 25 | Latch.Signal(); 26 | }); 27 | 28 | [Fact] 29 | public void TestThatActorProxyInitializesForMain() 30 | { 31 | //Assert.False(ActorProxy.IsInitializingForTest()); // state before initializing 32 | 33 | // use a separate Thread since it will not be on this stack 34 | _runtimeStartWorldThread.Start(); 35 | 36 | Latch.Wait(); 37 | 38 | Assert.Equal("FALSE", UnderTest.Get()); 39 | } 40 | 41 | [Fact] 42 | public void TestThatActorProxyInitializesForTest() 43 | { 44 | //Assert.False(ActorProxy.IsInitializingForTest()); // state before initializing 45 | 46 | TestRuntimeDiscoverer.IsTestDetectionDeactivated = false; 47 | ActorProxy.InitializeForTest(); 48 | var world = World.StartWithDefaults("StartForTest"); 49 | 50 | Assert.True(world.ResolveDynamic(ActorProxy.InternalActorProxyForTestId)); 51 | } 52 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/ActorSuspendResumeTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Tests.Supervision; 9 | using Xunit; 10 | using SuspendedSenderSupervisorResults = Vlingo.Xoom.Actors.Tests.Supervision.SuspendedSenderSupervisorActor.SuspendedSenderSupervisorResults; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests 13 | { 14 | public class ActorSuspendResumeTest : ActorsTest 15 | { 16 | [Fact] 17 | public void TestSuspendResume() 18 | { 19 | var testResults = new SuspendedSenderSupervisorResults(); 20 | 21 | var failureControlSender = World.ActorFor( 22 | Definition.Has(Definition.Parameters(testResults), "suspended-sender-supervisor")); 23 | 24 | var failureControlTestResults = new FailureControlActor.FailureControlTestResults(); 25 | var failure = World.ActorFor( 26 | Definition.Has( 27 | Definition.Parameters(failureControlTestResults), 28 | SuspendedSenderSupervisorActor.Instance.Value, 29 | "queueArray", 30 | "failure")); 31 | var times = 25; 32 | var failureAccess = failureControlTestResults.AfterCompleting(times); 33 | var supervisorAccess = testResults.AfterCompleting(1); 34 | failureControlSender.SendUsing(failure, times); 35 | 36 | failure.FailNow(); 37 | 38 | Assert.Equal(1, supervisorAccess.ReadFromExpecting("informedCount", 1)); 39 | Assert.Equal(times, failureAccess.ReadFromExpecting("afterFailureCountCount", times)); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/ActorsTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.Plugin.Logging.Console; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests 13 | { 14 | public class ActorsTest : IDisposable 15 | { 16 | protected ActorsTest() 17 | { 18 | var configuration = Configuration 19 | .Define() 20 | .With(ConsoleLoggerPluginConfiguration 21 | .Define() 22 | .WithDefaultLogger() 23 | .WithName("vlingo-net/actors")); 24 | 25 | TestWorld = TestWorld.Start($"{GetType().Name}-world", configuration); 26 | World = TestWorld.World; 27 | } 28 | 29 | protected World World { get; set; } 30 | 31 | protected TestWorld TestWorld { get; set; } 32 | 33 | public TestUntil Until(int times) => TestUntil.Happenings(times); 34 | 35 | public virtual void Dispose() => TestWorld.Terminate(); 36 | 37 | protected internal bool IsSuspended(Actor actor) => actor.LifeCycle.IsSuspended; 38 | } 39 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/AddressTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Xunit; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests 11 | { 12 | public class AddressTest : ActorsTest 13 | { 14 | [Fact] 15 | public void TestNameGiven() 16 | { 17 | var address = World.AddressFactory.UniqueWith("test-address"); 18 | var id = World.AddressFactory.TestNextIdValue() - 1; 19 | 20 | Assert.NotNull(address); 21 | Assert.Equal(id, address.Id); 22 | Assert.Equal("test-address", address.Name); 23 | 24 | var another = World.AddressFactory.UniqueWith("another-address"); 25 | 26 | Assert.NotEqual(another, address); 27 | Assert.NotEqual(0, address.CompareTo(another)); 28 | Assert.Equal(id, address.GetHashCode()); 29 | } 30 | 31 | [Fact] 32 | public void TestNameAndIdGiven() 33 | { 34 | const long id = 123; 35 | 36 | var address = World.AddressFactory.From(id, "test-address"); 37 | 38 | Assert.NotNull(address); 39 | Assert.Equal(id, address.Id); 40 | Assert.Equal("test-address", address.Name); 41 | 42 | var another = World.AddressFactory.From(456, "test-address"); 43 | 44 | Assert.NotEqual(another, address); 45 | Assert.NotEqual(0, address.CompareTo(another)); 46 | Assert.Equal(address, World.AddressFactory.From(123, "test-address")); 47 | Assert.Equal(0, address.CompareTo(World.AddressFactory.From(123, "test-address"))); 48 | Assert.Equal(id, address.GetHashCode()); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Converter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.IO; 10 | using System.Text; 11 | using Xunit.Abstractions; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests 14 | { 15 | public class Converter : TextWriter 16 | { 17 | private readonly ITestOutputHelper _output; 18 | 19 | public Converter(ITestOutputHelper output) => _output = output; 20 | 21 | public override Encoding Encoding => Encoding.UTF8; 22 | 23 | public override void WriteLine(string message) 24 | { 25 | try 26 | { 27 | _output.WriteLine(message); 28 | } 29 | catch (InvalidOperationException e) 30 | { 31 | if (e.Message != "There is no currently active test.") 32 | { 33 | throw; 34 | } 35 | } 36 | } 37 | 38 | public override void WriteLine(string format, params object[] args) => _output.WriteLine(format, args); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/DispatcherTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.TestKit; 9 | using Xunit; 10 | 11 | namespace Vlingo.Xoom.Actors.Tests 12 | { 13 | public class DispatcherTest : ActorsTest 14 | { 15 | private const int Total100Thousand = 100_000; 16 | 17 | [Fact] 18 | public void Test100MillionTells() 19 | { 20 | var test = TestWorld.ActorFor(Definition.Has(Definition.NoParameters, "test")); 21 | for (var i = 0; i < Total100Thousand; ++i) 22 | { 23 | test.Actor.TellMeSomething("Hello!", i); 24 | } 25 | 26 | Assert.Equal(Total100Thousand, TestWorld.AllMessagesFor(test.Address).Count); 27 | Assert.Equal(Total100Thousand, test.ViewTestState().ValueOf("times")); 28 | } 29 | 30 | [Fact] 31 | public void Test100MillionTellWhatITellYou() 32 | { 33 | var test = TestWorld.ActorFor(Definition.Has(Definition.NoParameters, "test")); 34 | for (var i = 0; i < Total100Thousand; ++i) 35 | { 36 | test.Actor.TellWhatITellYou(i); 37 | } 38 | 39 | Assert.Equal(Total100Thousand, TestWorld.AllMessagesFor(test.Address).Count); 40 | Assert.Equal(Total100Thousand - 1, test.ViewTestState().ValueOf("lastValue")); 41 | } 42 | 43 | 44 | private class TellAllActor : Actor, ITellAll 45 | { 46 | private int lastValue; 47 | public void TellWhatITellYou(int value) => lastValue = value; 48 | public override TestState ViewTestState() => new TestState().PutValue("lastValue", lastValue); 49 | } 50 | 51 | private class TellSomethingActor : Actor, ITellSomething 52 | { 53 | private int times = 0; 54 | public void TellMeSomething(string something, int value) => ++times; 55 | public override TestState ViewTestState() => new TestState().PutValue("times", times); 56 | } 57 | } 58 | 59 | public interface ITellAll 60 | { 61 | void TellWhatITellYou(int value); 62 | } 63 | 64 | public interface ITellSomething 65 | { 66 | void TellMeSomething(string something, int value); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/GenericWithConstraints__Proxy.cs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vlingo-net/xoom-net-actors/3ae2171ba4d05dc9a47d98177ca93c376767ad41/src/Vlingo.Xoom.Actors.Tests/GenericWithConstraints__Proxy.cs -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/InterruptableActorTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.TestKit; 9 | using Xunit; 10 | 11 | namespace Vlingo.Xoom.Actors.Tests 12 | { 13 | public class InterruptableActorTest : ActorsTest 14 | { 15 | [Fact] 16 | public void TestInterruptionWithStop() 17 | { 18 | var interruptable = TestWorld.ActorFor( 19 | Definition.Has( 20 | Definition.NoParameters, "testStoppable")); 21 | for(var idx = 0; idx < 10; ++idx) 22 | { 23 | if(idx == 5) 24 | { 25 | interruptable.Actor.Stop(); 26 | } 27 | interruptable.Actor.DoThisOrThat(); 28 | } 29 | 30 | Assert.Equal(6, TestWorld.AllMessagesFor(interruptable.Address).Count); 31 | Assert.Equal(5, interruptable.ViewTestState().ValueOf("totalReceived")); 32 | } 33 | 34 | private class InterruptableActor : Actor, IInterruptable 35 | { 36 | private int totalReceived = 0; 37 | public void DoThisOrThat() 38 | { 39 | if (!IsStopped) 40 | { 41 | ++totalReceived; 42 | } 43 | } 44 | public override TestState ViewTestState() => new TestState().PutValue("totalReceived", totalReceived); 45 | } 46 | } 47 | 48 | public interface IInterruptable : IStoppable 49 | { 50 | void DoThisOrThat(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/MockCompletes.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.TestKit; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors.Tests 12 | { 13 | public class MockCompletes : BasicCompletes where T:class 14 | { 15 | private readonly AtomicReference _outcome = new AtomicReference(default(T)); 16 | private readonly AtomicInteger _withCount = new AtomicInteger(0); 17 | private readonly AccessSafely _safely; 18 | 19 | public MockCompletes(int times) 20 | : base((Scheduler)null) 21 | { 22 | _safely = AccessSafely.AfterCompleting(times) 23 | .WritingWith("outcome", val => 24 | { 25 | _outcome.Set(val); 26 | _withCount.IncrementAndGet(); 27 | }) 28 | .ReadingWith("outcome", _outcome.Get) 29 | .ReadingWith("count", _withCount.Get); 30 | } 31 | 32 | public int WithCount => _safely.ReadFrom("count"); 33 | 34 | public override T Outcome => _safely.ReadFrom("outcome"); 35 | 36 | public override ICompletes With(TOutcome outcome) 37 | { 38 | _safely.WriteUsing("outcome", (T)(object)outcome); 39 | return (ICompletes)this; 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Completes/MockCompletesEventually.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Completes 11 | { 12 | public class MockCompletesEventually : ICompletesEventually 13 | { 14 | public readonly CompletesResults completesResults; 15 | 16 | public MockCompletesEventually(CompletesResults completesResults) 17 | { 18 | this.completesResults = completesResults; 19 | } 20 | 21 | public bool IsStopped => false; 22 | 23 | public IAddress Address => null; 24 | 25 | public void Conclude() 26 | { 27 | } 28 | 29 | public void Stop() 30 | { 31 | } 32 | 33 | public void With(object outcome) 34 | { 35 | completesResults.Outcome.Set(outcome); 36 | completesResults.WithCount.IncrementAndGet(); 37 | } 38 | 39 | public class CompletesResults 40 | { 41 | public AtomicReference Outcome { get; } = new AtomicReference(); 42 | public AtomicInteger WithCount { get; } = new AtomicInteger(0); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Completes/MockCompletesEventuallyProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Completes 11 | { 12 | public class MockCompletesEventuallyProvider : ICompletesEventuallyProvider 13 | { 14 | private readonly MockCompletesEventually.CompletesResults completesResults; 15 | public int initializeUsing; 16 | public int provideCompletesForCount; 17 | 18 | public MockCompletesEventually completesEventually; 19 | public MockCompletes completes; 20 | 21 | public MockCompletesEventuallyProvider(MockCompletesEventually.CompletesResults completesResults) 22 | { 23 | this.completesResults = completesResults; 24 | } 25 | 26 | public ICompletesEventually CompletesEventually => completesEventually; 27 | 28 | public void Close() 29 | { 30 | } 31 | 32 | public void InitializeUsing(Stage stage) 33 | { 34 | completesEventually = new MockCompletesEventually(completesResults); 35 | ++initializeUsing; 36 | } 37 | 38 | public ICompletesEventually ProvideCompletesFor(ICompletes clientCompletes) 39 | { 40 | ++provideCompletesForCount; 41 | return completesEventually; 42 | } 43 | 44 | public ICompletesEventually ProvideCompletesFor(IAddress address, ICompletes clientCompletes) 45 | { 46 | ++provideCompletesForCount; 47 | return completesEventually; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Completes/MockCompletesPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Plugin; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Completes 11 | { 12 | public class MockCompletesPlugin : IPlugin 13 | { 14 | public MockCompletesEventuallyProvider CompletesEventuallyProvider; 15 | private readonly MockCompletesEventually.CompletesResults _completesResults; 16 | public MockCompletesPlugin(MockCompletesEventually.CompletesResults completesResults) => _completesResults = completesResults; 17 | 18 | public string Name => null; 19 | 20 | public int Pass => 0; 21 | 22 | public IPluginConfiguration Configuration => null; 23 | 24 | public void Close() 25 | { 26 | } 27 | 28 | public void Start(IRegistrar registrar) 29 | { 30 | CompletesEventuallyProvider = new MockCompletesEventuallyProvider(_completesResults); 31 | registrar.Register("mock-completes-eventually", CompletesEventuallyProvider); 32 | } 33 | 34 | public IPlugin With(IPluginConfiguration overrideConfiguration) => null; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Completes/MockRegistrar.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Completes 11 | { 12 | public class MockRegistrar : IRegistrar 13 | { 14 | public int RegisterCount; 15 | 16 | public World World => null; 17 | 18 | public void Register(string name, ICompletesEventuallyProvider completesEventuallyProvider) 19 | { 20 | completesEventuallyProvider.InitializeUsing(null); 21 | ++RegisterCount; 22 | } 23 | 24 | public void Register(string name, bool isDefault, ILoggerProvider loggerProvider) 25 | { 26 | } 27 | 28 | public void Register(string name, bool isDefault, IMailboxProvider mailboxProvider) 29 | { 30 | } 31 | 32 | public void RegisterCommonSupervisor(string stageName, string name, Type supervisedProtocol, Type supervisorClass) 33 | { 34 | } 35 | 36 | public void RegisterCompletesEventuallyProviderKeeper(ICompletesEventuallyProviderKeeper keeper) 37 | { 38 | } 39 | 40 | public void RegisterDefaultSupervisor(string stageName, string name, Type supervisorClass) 41 | { 42 | } 43 | 44 | public void RegisterLoggerProviderKeeper(ILoggerProviderKeeper keeper) 45 | { 46 | } 47 | 48 | public void RegisterMailboxProviderKeeper(IMailboxProviderKeeper keeper) 49 | { 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Completes/PooledCompletesPluginTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Xunit; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Completes 11 | { 12 | public class PooledCompletesPluginTest 13 | { 14 | [Fact] 15 | public void TestStart() 16 | { 17 | var completesResults = new MockCompletesEventually.CompletesResults(); 18 | var plugin = new MockCompletesPlugin(completesResults); 19 | var registrar = new MockRegistrar(); 20 | plugin.Start(registrar); 21 | plugin.CompletesEventuallyProvider.completesEventually.With(new object()); 22 | var completes = (MockCompletesEventually)plugin.CompletesEventuallyProvider.ProvideCompletesFor(null); 23 | 24 | completes.With(7); 25 | 26 | Assert.Equal(1, registrar.RegisterCount); 27 | Assert.Equal(1, plugin.CompletesEventuallyProvider.initializeUsing); 28 | Assert.Equal(1, plugin.CompletesEventuallyProvider.provideCompletesForCount); 29 | Assert.Equal(2, completesResults.WithCount.Get()); 30 | Assert.Equal(2, completes.completesResults.WithCount.Get()); 31 | Assert.Equal(7, completes.completesResults.Outcome.Get()); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Logging/ConsoleLoggerTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Plugin.Logging.Console; 9 | using Xunit; 10 | 11 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Logging 12 | { 13 | public class ConsoleLoggerTest 14 | { 15 | [Fact] 16 | public void ConsoleLoggerCreateSuccessfull() 17 | { 18 | var consoleLogger = ConsoleLogger.TestInstance(); 19 | 20 | Assert.Equal("vlingo-net/actors", consoleLogger.Name); 21 | Assert.True(consoleLogger.IsEnabled); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Mailbox/DefaultMailboxProviderKeeperPluginTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using NSubstitute; 9 | using Vlingo.Xoom.Actors.Plugin; 10 | using Vlingo.Xoom.Actors.Plugin.Mailbox; 11 | using Xunit; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Mailbox 14 | { 15 | public class DefaultMailboxProviderKeeperPluginTest : ActorsTest 16 | { 17 | private readonly IPlugin _plugin; 18 | private readonly IRegistrar _registrar; 19 | private readonly IMailboxProviderKeeper _keeper; 20 | 21 | public DefaultMailboxProviderKeeperPluginTest() 22 | : base() 23 | { 24 | _registrar = Substitute.For(); 25 | _keeper = Substitute.For(); 26 | _plugin = new DefaultMailboxProviderKeeperPlugin(_keeper, new DefaultMailboxProviderKeeperPluginConfiguration()); 27 | } 28 | 29 | [Fact] 30 | public void TestThatItUsesTheCorrectName() 31 | { 32 | Assert.Equal("defaultMailboxProviderKeeper", _plugin.Name); 33 | } 34 | 35 | [Fact] 36 | public void TestThatItsTheFirstPass() 37 | { 38 | Assert.Equal(0, _plugin.Pass); 39 | } 40 | 41 | [Fact] 42 | public void TestThatStartRegistersTheProvidedKeeper() 43 | { 44 | _plugin.Start(_registrar); 45 | 46 | _registrar.Received(1) 47 | .RegisterMailboxProviderKeeper(Arg.Is(x => x == _keeper)); 48 | } 49 | 50 | [Fact] 51 | public void TestThatReturnsTheCorrectConfiguration() 52 | { 53 | var configuration = _plugin.Configuration; 54 | Assert.Equal(typeof(DefaultMailboxProviderKeeperPluginConfiguration), configuration.GetType()); 55 | } 56 | 57 | [Fact] 58 | public void TestThatRegistersTheProvidedKeeperInARealWorld() 59 | { 60 | var properties = new Properties(); 61 | properties.SetProperty("plugin.name.defaultMailboxProviderKeeper", "true"); 62 | var pluginProperties = new PluginProperties("defaultMailboxProviderKeeper", properties); 63 | _plugin.Configuration.BuildWith(World.Configuration, pluginProperties); 64 | _plugin.Start(World); 65 | World.Terminate(); 66 | 67 | _keeper.Received(1) 68 | .Close(); 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Mailbox/ICountTaker.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Mailbox 9 | { 10 | public interface ICountTaker 11 | { 12 | void Take(int count); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/Mailbox/SharedRingBuffer/PropertiesFileConfigRingBufferMailboxActorTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.TestKit; 9 | using Vlingo.Xoom.Common; 10 | using Xunit; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests.Plugin.Mailbox.SharedRingBuffer 13 | { 14 | public class PropertiesFileConfigRingBufferMailboxActorTest : ActorsTest 15 | { 16 | [Fact] 17 | public void TestThatRingBufferIsUsed() 18 | { 19 | var results = new TestResults(1); 20 | var one = World.ActorFor( 21 | Definition.Has(Definition.Parameters(results), "ringMailbox", "one-behavior")); 22 | 23 | one.DoSomething(); 24 | 25 | Assert.Equal(1, results.Times); 26 | } 27 | 28 | public class OneBehaviorActor : Actor, IOneBehavior 29 | { 30 | private readonly TestResults _results; 31 | 32 | public OneBehaviorActor(TestResults results) => _results = results; 33 | 34 | public void DoSomething() => _results.Invoked(); 35 | } 36 | 37 | public class TestResults 38 | { 39 | private readonly AccessSafely _safely; 40 | 41 | public TestResults(int happenings) 42 | { 43 | var times = new AtomicInteger(0); 44 | _safely = AccessSafely 45 | .AfterCompleting(happenings) 46 | .WritingWith("times", _ => times.IncrementAndGet()) 47 | .ReadingWith("times", times.Get); 48 | } 49 | 50 | public int Times 51 | { 52 | get => _safely.ReadFrom("times"); 53 | } 54 | 55 | public void Invoked() => _safely.WriteUsing("times", 1); 56 | } 57 | } 58 | 59 | public interface IOneBehavior 60 | { 61 | void DoSomething(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Plugin/PluginPropertiesTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Plugin; 9 | using Xunit; 10 | 11 | namespace Vlingo.Xoom.Actors.Tests.Plugin 12 | { 13 | public class PluginPropertiesTest 14 | { 15 | [Fact] 16 | public void TestPropertyTypes() 17 | { 18 | var properties = new Properties(); 19 | 20 | properties.SetProperty("plugin.test.boolean", "true"); 21 | properties.SetProperty("plugin.test.float", "123.5"); 22 | properties.SetProperty("plugin.test.int", "456"); 23 | properties.SetProperty("plugin.test.string", "text"); 24 | 25 | var pluginProperties = new PluginProperties("test", properties); 26 | 27 | Assert.True(pluginProperties.GetBoolean("boolean", false)); 28 | Assert.Equal(123.5f, pluginProperties.GetFloat("float", 0.0f)); 29 | Assert.Equal(456, pluginProperties.GetInteger("int", 0)); 30 | Assert.Equal("text", pluginProperties.GetString("string", "")); 31 | } 32 | 33 | [Fact] 34 | public void TestPropertyDefaults() 35 | { 36 | var pluginProperties = new PluginProperties("test", new Properties()); 37 | 38 | Assert.True(pluginProperties.GetBoolean("boolean", true)); 39 | Assert.Equal(123.5f, pluginProperties.GetFloat("float", 123.5f)); 40 | Assert.Equal(456, pluginProperties.GetInteger("int", 456)); 41 | Assert.Equal("text", pluginProperties.GetString("string", "text")); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/ReusableQueueMailboxTest.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | namespace Vlingo.Xoom.Actors.Tests 4 | { 5 | public class ReusableQueueMailboxTest 6 | { 7 | private static string QueueMailbox = "queueMailbox"; 8 | private static string ReuseQueueMailbox = "reuseQueueMailbox"; 9 | 10 | private readonly World _world; 11 | 12 | [Fact] 13 | public void TestThatBothMailboxTypesExist() 14 | { 15 | var queueMailboxName = _world.MailboxNameFrom(QueueMailbox); 16 | Assert.Equal(QueueMailbox, queueMailboxName); 17 | var queueMailbox = _world.AssignMailbox(queueMailboxName, 1234567); 18 | Assert.NotNull(queueMailbox); 19 | 20 | var reuseQueueMailboxName = _world.MailboxNameFrom(ReuseQueueMailbox); 21 | Assert.Equal(ReuseQueueMailbox, reuseQueueMailboxName); 22 | var reuseQueueMailbox = _world.AssignMailbox(reuseQueueMailboxName, 123456789); 23 | Assert.NotNull(reuseQueueMailbox); 24 | } 25 | 26 | public ReusableQueueMailboxTest() => _world = World.Start("test-reuse-concurrentqueue"); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/SmallestMailboxRouterTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests 9 | { 10 | public class SmallestMailboxRouterTest : ActorsTest 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/StageNamedTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.TestKit; 10 | using Xunit; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests 13 | { 14 | public class StageNamedTest : ActorsTest 15 | { 16 | [Fact] 17 | public void TestWorldStageNamedOnce() 18 | { 19 | var defaultStage = World.Stage; 20 | var uniqueName = Guid.NewGuid().ToString("N"); 21 | var uniqueStage = World.StageNamed(uniqueName); 22 | 23 | Assert.NotSame(defaultStage, uniqueStage); 24 | Assert.Equal(uniqueName, uniqueStage.Name); 25 | Assert.Same(uniqueStage, World.StageNamed(uniqueName)); 26 | } 27 | 28 | [Fact] 29 | public void TestActorStageNamed() 30 | { 31 | var defaultStage = TestWorld.Stage; 32 | var query = TestWorld.ActorFor(Definition.Has(Definition.NoParameters)); 33 | var result = TestWorld.ActorFor(Definition.Has(Definition.NoParameters)); 34 | var uniqueName = Guid.NewGuid().ToString("N"); 35 | 36 | query.Actor.StageNamed(uniqueName, result.Actor); 37 | var stageHolder = result.ViewTestState().ValueOf("stageHolder"); 38 | 39 | Assert.Equal(1, TestWorld.AllMessagesFor(query.Address).Count); 40 | Assert.Equal(1, TestWorld.AllMessagesFor(result.Address).Count); 41 | Assert.NotSame(defaultStage, stageHolder); 42 | Assert.Same(stageHolder, TestWorld.StageNamed(uniqueName)); 43 | } 44 | 45 | private class StageNamedWithResultActor : Actor, IStageNameQuery, IStageNameQueryResult 46 | { 47 | private Stage stageHolder; 48 | public void StageNamed(string name, IStageNameQueryResult result) => result.StageWithNameResult(StageNamed(name), name); 49 | public void StageWithNameResult(Stage stage, string name) => stageHolder = stage; 50 | public override TestState ViewTestState() => new TestState().PutValue("stageHolder", stageHolder); 51 | } 52 | } 53 | 54 | public interface IStageNameQueryResult 55 | { 56 | void StageWithNameResult(Stage stage, string name); 57 | } 58 | 59 | public interface IStageNameQuery 60 | { 61 | void StageNamed(string name, IStageNameQueryResult result); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/EscalateSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.TestKit; 10 | using Vlingo.Xoom.Common; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests.Supervision 13 | { 14 | public class EscalateSupervisorActor : Actor, ISupervisor 15 | { 16 | private readonly EscalateSupervisorTestResults _testResults; 17 | 18 | public EscalateSupervisorActor(EscalateSupervisorTestResults testResults) => _testResults = testResults; 19 | 20 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 21 | 22 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 23 | 24 | public void Inform(Exception error, ISupervised supervised) 25 | { 26 | supervised.Escalate(); 27 | _testResults.Access.WriteUsing("informedCount", 1); 28 | } 29 | 30 | private class SupervisionStrategyImpl : ISupervisionStrategy 31 | { 32 | public int Intensity => 5; 33 | 34 | public long Period => 1000; 35 | 36 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 37 | } 38 | 39 | public class EscalateSupervisorTestResults 40 | { 41 | public AtomicInteger InformedCount { get; } = new AtomicInteger(0); 42 | public AccessSafely Access { get; private set; } 43 | 44 | public EscalateSupervisorTestResults() 45 | { 46 | Access = AfterCompleting(0); 47 | } 48 | 49 | public AccessSafely AfterCompleting(int times) 50 | { 51 | Access = AccessSafely 52 | .AfterCompleting(times) 53 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 54 | .ReadingWith("informedCount", () => InformedCount.Get()); 55 | 56 | return Access; 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/IFailureControl.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests.Supervision 9 | { 10 | public interface IFailureControl 11 | { 12 | void FailNow(); 13 | void AfterFailure(); 14 | void AfterFailureCount(int count); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/IFailureControlSender.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests.Supervision 9 | { 10 | public interface IFailureControlSender 11 | { 12 | void SendUsing(IFailureControl failureControl, int times); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/IPing.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests.Supervision 9 | { 10 | public interface IPing 11 | { 12 | void Ping(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/IPong.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests.Supervision 9 | { 10 | public interface IPong 11 | { 12 | void Pong(); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/PingActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Supervision 14 | { 15 | public class PingActor : Actor, IPing 16 | { 17 | public static ThreadLocal Instance = new ThreadLocal(); 18 | 19 | private readonly PingTestResults _testResults; 20 | 21 | public PingActor(PingTestResults testResults) 22 | { 23 | _testResults = testResults; 24 | Instance.Value = this; 25 | } 26 | 27 | public void Ping() 28 | { 29 | _testResults.Access.WriteUsing("pingCount", 1); 30 | throw new ApplicationException("Intended Ping failure."); 31 | } 32 | 33 | public override void Stop() 34 | { 35 | base.Stop(); 36 | _testResults.Access.WriteUsing("stopCount", 1); 37 | } 38 | 39 | public class PingTestResults 40 | { 41 | public readonly AtomicInteger PingCount = new AtomicInteger(0); 42 | public readonly AtomicInteger StopCount = new AtomicInteger(0); 43 | 44 | public AccessSafely Access { get; private set; } 45 | 46 | public PingTestResults() 47 | { 48 | Access = AfterCompleting(0); 49 | } 50 | 51 | public AccessSafely AfterCompleting(int times) 52 | { 53 | Access = AccessSafely 54 | .AfterCompleting(times) 55 | .WritingWith("pingCount", (int increment) => PingCount.Set(PingCount.Get() + increment)) 56 | .ReadingWith("pingCount", () => PingCount.Get()) 57 | .WritingWith("stopCount", (int increment) => StopCount.Set(StopCount.Get() + increment)) 58 | .ReadingWith("stopCount", () => StopCount.Get()); 59 | return Access; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/PingSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Supervision 14 | { 15 | public class PingSupervisorActor : Actor, ISupervisor 16 | { 17 | public static readonly ThreadLocal Instance = new ThreadLocal(); 18 | 19 | internal readonly AtomicReference TestResults; 20 | 21 | public PingSupervisorActor() 22 | { 23 | TestResults = new AtomicReference(new PingSupervisorTestResults()); 24 | Instance.Value = this; 25 | } 26 | 27 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 28 | 29 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 30 | 31 | public void Inform(Exception error, ISupervised supervised) 32 | { 33 | supervised.RestartWithin(SupervisionStrategy.Period, SupervisionStrategy.Intensity, SupervisionStrategy.Scope); 34 | TestResults.Get()?.Access.WriteUsing("informedCount", 1); 35 | } 36 | 37 | internal class PingSupervisorTestResults 38 | { 39 | public AtomicInteger InformedCount { get; set; } = new AtomicInteger(0); 40 | public AccessSafely Access { get; private set; } 41 | 42 | public PingSupervisorTestResults() 43 | { 44 | Access = AfterCompleting(0); 45 | } 46 | 47 | public AccessSafely AfterCompleting(int times) 48 | { 49 | Access = AccessSafely 50 | .AfterCompleting(times) 51 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 52 | .ReadingWith("informedCount", () => InformedCount.Get()); 53 | 54 | return Access; 55 | } 56 | } 57 | 58 | private class SupervisionStrategyImpl : ISupervisionStrategy 59 | { 60 | public int Intensity => 5; 61 | 62 | public long Period => 1000; 63 | 64 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/PongActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Supervision 14 | { 15 | public class PongActor : Actor, IPong 16 | { 17 | public static readonly ThreadLocal Instance = new ThreadLocal(); 18 | 19 | private readonly PongTestResults _testResults; 20 | 21 | public PongActor(PongTestResults testResults) 22 | { 23 | _testResults = testResults; 24 | Instance.Value = this; 25 | } 26 | 27 | public void Pong() 28 | { 29 | _testResults.Access.WriteUsing("pongCount", 1); 30 | throw new ApplicationException("Intended Pong failure."); 31 | } 32 | 33 | public override void Stop() 34 | { 35 | base.Stop(); 36 | _testResults.Access.WriteUsing("stopCount", 1); 37 | } 38 | 39 | public class PongTestResults 40 | { 41 | public readonly AtomicInteger PongCount = new AtomicInteger(0); 42 | public readonly AtomicInteger StopCount = new AtomicInteger(0); 43 | 44 | public AccessSafely Access { get; private set; } 45 | 46 | public PongTestResults() 47 | { 48 | Access = AfterCompleting(0); 49 | } 50 | 51 | public AccessSafely AfterCompleting(int times) 52 | { 53 | Access = AccessSafely 54 | .AfterCompleting(times) 55 | .WritingWith("pongCount", (int increment) => PongCount.Set(PongCount.Get() + increment)) 56 | .ReadingWith("pongCount", () => PongCount.Get()) 57 | .WritingWith("stopCount", (int increment) => StopCount.Set(StopCount.Get() + increment)) 58 | .ReadingWith("stopCount", () => StopCount.Get()); 59 | return Access; 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/PongSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Supervision 14 | { 15 | public class PongSupervisorActor : Actor, ISupervisor 16 | { 17 | public static readonly ThreadLocal Instance = new ThreadLocal(); 18 | 19 | internal readonly PongSupervisorTestResults TestResults; 20 | 21 | public PongSupervisorActor() 22 | { 23 | TestResults = new PongSupervisorTestResults(); 24 | Instance.Value = this; 25 | } 26 | 27 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 28 | 29 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 30 | 31 | public void Inform(Exception error, ISupervised supervised) 32 | { 33 | supervised.RestartWithin(SupervisionStrategy.Period, SupervisionStrategy.Intensity, SupervisionStrategy.Scope); 34 | TestResults.Access.WriteUsing("informedCount", 1); 35 | } 36 | 37 | internal class PongSupervisorTestResults 38 | { 39 | public AtomicInteger InformedCount { get; set; } = new AtomicInteger(0); 40 | public AccessSafely Access { get; private set; } 41 | 42 | public PongSupervisorTestResults() 43 | { 44 | Access = AfterCompleting(0); 45 | } 46 | 47 | public AccessSafely AfterCompleting(int times) 48 | { 49 | Access = AccessSafely 50 | .AfterCompleting(times) 51 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 52 | .ReadingWith("informedCount", () => InformedCount.Get()); 53 | 54 | return Access; 55 | } 56 | } 57 | 58 | private class SupervisionStrategyImpl : ISupervisionStrategy 59 | { 60 | public int Intensity => 10; 61 | 62 | public long Period => 1000; 63 | 64 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/RestartFiveInOneSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.TestKit; 10 | using Vlingo.Xoom.Common; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests.Supervision 13 | { 14 | public class RestartFiveInOneSupervisorActor : Actor, ISupervisor 15 | { 16 | private readonly RestartFiveInOneSupervisorTestResults _testResults; 17 | 18 | public RestartFiveInOneSupervisorActor(RestartFiveInOneSupervisorTestResults testResults) => _testResults = testResults; 19 | 20 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 21 | 22 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 23 | 24 | public void Inform(Exception error, ISupervised supervised) 25 | { 26 | supervised.RestartWithin(SupervisionStrategy.Period, SupervisionStrategy.Intensity, SupervisionStrategy.Scope); 27 | _testResults.Access.WriteUsing("informedCount", 1); 28 | } 29 | 30 | private class SupervisionStrategyImpl : ISupervisionStrategy 31 | { 32 | public int Intensity => 5; 33 | 34 | public long Period => 1000; 35 | 36 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 37 | } 38 | 39 | public class RestartFiveInOneSupervisorTestResults 40 | { 41 | public AtomicInteger InformedCount { get; set; } = new AtomicInteger(0); 42 | public AccessSafely Access { get; private set; } 43 | 44 | public RestartFiveInOneSupervisorTestResults() 45 | { 46 | Access = AfterCompleting(0); 47 | } 48 | 49 | public AccessSafely AfterCompleting(int times) 50 | { 51 | Access = AccessSafely 52 | .AfterCompleting(times) 53 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 54 | .ReadingWith("informedCount", () => InformedCount.Get()); 55 | 56 | return Access; 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/RestartForeverSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.TestKit; 10 | using Vlingo.Xoom.Common; 11 | 12 | namespace Vlingo.Xoom.Actors.Tests.Supervision 13 | { 14 | public class RestartForeverSupervisorActor : Actor, ISupervisor 15 | { 16 | private readonly RestartForeverSupervisorTestResults _testResults; 17 | 18 | public RestartForeverSupervisorActor(RestartForeverSupervisorTestResults testResults) => _testResults = testResults; 19 | 20 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 21 | 22 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 23 | 24 | public void Inform(Exception error, ISupervised supervised) 25 | { 26 | supervised.RestartWithin(SupervisionStrategy.Period, SupervisionStrategy.Intensity, SupervisionStrategy.Scope); 27 | _testResults.Access.WriteUsing("informedCount", 1); 28 | } 29 | 30 | private class SupervisionStrategyImpl : ISupervisionStrategy 31 | { 32 | public int Intensity => SupervisionStrategyConstants.ForeverIntensity; 33 | 34 | public long Period => SupervisionStrategyConstants.ForeverPeriod; 35 | 36 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 37 | } 38 | 39 | public class RestartForeverSupervisorTestResults 40 | { 41 | public AtomicInteger InformedCount { get; set; } = new AtomicInteger(0); 42 | public AccessSafely Access { get; private set; } 43 | public RestartForeverSupervisorTestResults() 44 | { 45 | Access = AfterCompleting(0); 46 | } 47 | 48 | public AccessSafely AfterCompleting(int times) 49 | { 50 | Access = AccessSafely 51 | .AfterCompleting(times) 52 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 53 | .ReadingWith("informedCount", () => InformedCount.Get()); 54 | 55 | return Access; 56 | } 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Supervision/StopAllSupervisorActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using Vlingo.Xoom.Actors.TestKit; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors.Tests.Supervision 14 | { 15 | public class StopAllSupervisorActor : Actor, ISupervisor 16 | { 17 | public static readonly ThreadLocal Instance = new ThreadLocal(); 18 | private readonly StopAllSupervisorResult _result; 19 | 20 | public StopAllSupervisorActor(StopAllSupervisorResult result) 21 | { 22 | Instance.Value = this; 23 | _result = result; 24 | } 25 | 26 | public ISupervisionStrategy SupervisionStrategy { get; } = new SupervisionStrategyImpl(); 27 | 28 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 29 | 30 | public void Inform(Exception error, ISupervised supervised) 31 | { 32 | supervised.Stop(SupervisionStrategy.Scope); 33 | _result.Access.WriteUsing("informedCount", 1); 34 | } 35 | 36 | private class SupervisionStrategyImpl : ISupervisionStrategy 37 | { 38 | public int Intensity => 5; 39 | 40 | public long Period => 1000; 41 | 42 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.All; 43 | } 44 | 45 | public class StopAllSupervisorResult 46 | { 47 | public AtomicInteger InformedCount { get; set; } = new AtomicInteger(0); 48 | public AccessSafely Access { get; private set; } 49 | public StopAllSupervisorResult() 50 | { 51 | Access = AfterCompleting(0); 52 | } 53 | 54 | public AccessSafely AfterCompleting(int times) 55 | { 56 | Access = AccessSafely 57 | .AfterCompleting(times) 58 | .WritingWith("informedCount", (int increment) => InformedCount.Set(InformedCount.Get() + increment)) 59 | .ReadingWith("informedCount", () => InformedCount.Get()); 60 | 61 | return Access; 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/TestActorInterfaces.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Tests 9 | { 10 | public interface IParentInterface { } 11 | } 12 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/Vlingo.Xoom.Actors.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net6.0 5 | Debug;Release;Debug With Project References 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | all 15 | runtime; build; native; contentfiles; analyzers; buildtransitive 16 | 17 | 18 | all 19 | runtime; build; native; contentfiles; analyzers; buildtransitive 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | Always 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.Tests/WorldDefaultConfigurationTest.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Xunit; 9 | 10 | namespace Vlingo.Xoom.Actors.Tests 11 | { 12 | public class WorldDefaultConfigurationTest 13 | { 14 | [Fact] 15 | public void TestStartWorldWithDefaultConfiguration() 16 | { 17 | var worldDefaultConfig = World.Start("defaults"); 18 | var testResults = new WorldTest.TestResults(1); 19 | var simple = worldDefaultConfig.ActorFor( 20 | Definition.Has( 21 | Definition.Parameters(testResults))); 22 | 23 | simple.SimplySay(); 24 | 25 | Assert.True(testResults.Invoked); 26 | } 27 | 28 | private class SimpleActor : Actor, ISimpleWorldForDefaultConfig 29 | { 30 | private readonly WorldTest.TestResults _testResults; 31 | 32 | public SimpleActor(WorldTest.TestResults testResults) 33 | { 34 | _testResults = testResults; 35 | } 36 | 37 | public void SimplySay() => _testResults.SetInvoked(true); 38 | } 39 | } 40 | 41 | public interface ISimpleWorldForDefaultConfig 42 | { 43 | void SimplySay(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2037 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vlingo.Xoom.Actors", "Vlingo.Xoom.Actors\Vlingo.Xoom.Actors.csproj", "{854B3089-2737-4F96-930D-8812DE851903}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vlingo.Xoom.Actors.Tests", "Vlingo.Xoom.Actors.Tests\Vlingo.Xoom.Actors.Tests.csproj", "{1E906E6D-19E3-4943-B3D8-F4E024AE3A03}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {854B3089-2737-4F96-930D-8812DE851903}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {854B3089-2737-4F96-930D-8812DE851903}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {854B3089-2737-4F96-930D-8812DE851903}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {854B3089-2737-4F96-930D-8812DE851903}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {1E906E6D-19E3-4943-B3D8-F4E024AE3A03}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {1E906E6D-19E3-4943-B3D8-F4E024AE3A03}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {1E906E6D-19E3-4943-B3D8-F4E024AE3A03}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {1E906E6D-19E3-4943-B3D8-F4E024AE3A03}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {47F8D8E5-00A9-4484-A985-1E0FF772B43D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors.sln.licenseheader: -------------------------------------------------------------------------------- 1 | extensions: .cs 2 | // Copyright (c) 2012-2021 VLINGO LABS. All rights reserved. 3 | // 4 | // This Source Code Form is subject to the terms of the 5 | // Mozilla Public License, v. 2.0. If a copy of the MPL 6 | // was not distributed with this file, You can obtain 7 | // one at https://mozilla.org/MPL/2.0/. 8 | -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ActorAddressAlreadyRegisteredException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | internal class ActorAddressAlreadyRegisteredException : Exception 13 | { 14 | public ActorAddressAlreadyRegisteredException(Actor actor, IAddress address) : this(actor.GetType(), address) 15 | { 16 | } 17 | 18 | public ActorAddressAlreadyRegisteredException(Type? type, IAddress address) 19 | : base($"Failed to register Actor of type {type?.FullName}. Address is already registered: {address}") 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ActorProxyBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public abstract class ActorProxyBase 13 | { 14 | public static TNew Thunk(ActorProxyBase proxy, Actor actor, TNew arg) => 15 | proxy.IsDistributable ? Thunk(actor.LifeCycle.Environment.Stage, arg) : arg; 16 | 17 | public static TNew Thunk(Stage stage, TNew arg) 18 | { 19 | if (typeof(ActorProxyBase).IsAssignableFrom(typeof(TNew))) 20 | { 21 | var b = (ActorProxyBase) (object) arg!; 22 | return stage.LookupOrStartThunk(Actors.Definition.From(stage, b?.Definition, stage.World.DefaultLogger), b?.Address); 23 | } 24 | 25 | return arg; 26 | } 27 | 28 | public ActorProxyBase() 29 | { 30 | } 31 | 32 | public ActorProxyBase(Type? protocol, Definition.SerializationProxy definition, IAddress address) 33 | { 34 | Protocol = protocol; 35 | Definition = definition; 36 | Address = address; 37 | } 38 | 39 | public Type? Protocol { get; } 40 | public Definition.SerializationProxy? Definition { get; } 41 | public IAddress? Address { get; } 42 | 43 | public bool IsDistributable => Address?.IsDistributable ?? false; 44 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ActorProxyStub.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public class ActorProxyStub : ActorProxyBase 11 | { 12 | public ActorProxyStub(Actor actor) : base(null, Actors.Definition.SerializationProxy.From(actor.Definition), actor.Address) 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Addressable__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | internal class Addressable__Proxy : IAddressable 11 | { 12 | private readonly Actor actor; 13 | 14 | public Addressable__Proxy(Actor actor, IMailbox mailbox) 15 | { 16 | this.actor = actor; 17 | } 18 | 19 | public IAddress Address => actor.Address; 20 | 21 | public LifeCycle LifeCycle => actor.LifeCycle; 22 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Backoff.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public sealed class Backoff 15 | { 16 | private const long BackoffCap = 4096; 17 | private const long BackoffReset = 0L; 18 | private const long BackoffStart = 1L; 19 | 20 | private long _backoff; 21 | private readonly bool _isFixed; 22 | 23 | public Backoff() 24 | { 25 | _backoff = BackoffReset; 26 | _isFixed = false; 27 | } 28 | 29 | public Backoff(long fixedBackoff) 30 | { 31 | _backoff = fixedBackoff; 32 | _isFixed = true; 33 | } 34 | 35 | public async Task Now(CancellationToken token) 36 | { 37 | if (!_isFixed) 38 | { 39 | if (_backoff == BackoffReset) 40 | { 41 | _backoff = BackoffStart; 42 | } 43 | else if (_backoff < BackoffCap) 44 | { 45 | _backoff = _backoff * 2; 46 | } 47 | } 48 | await YieldFor(_backoff, token); 49 | } 50 | 51 | public async Task Now() 52 | { 53 | await Now(CancellationToken.None); 54 | } 55 | 56 | public void Reset() => _backoff = BackoffReset; 57 | 58 | private async Task YieldFor(long aMillis, CancellationToken token) 59 | { 60 | try 61 | { 62 | await Task.Delay(TimeSpan.FromMilliseconds(aMillis), token); 63 | } 64 | catch (OperationCanceledException) 65 | { 66 | // TODO: should ne logged 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/BasicAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public sealed class BasicAddress : IAddress 13 | { 14 | private readonly long _id; 15 | private readonly string? _name; 16 | 17 | public long Id => _id; 18 | 19 | public long IdSequence => Id; 20 | 21 | public string IdSequenceString => IdString; 22 | 23 | public string IdString => $"{_id}"; 24 | 25 | public string Name => _name ?? _id.ToString(); 26 | 27 | public bool IsDistributable => false; 28 | 29 | public int CompareTo(IAddress? other) 30 | { 31 | if (other == null || other.GetType() != typeof(BasicAddress)) 32 | { 33 | return 1; 34 | } 35 | return _id.CompareTo(((BasicAddress)other)._id); 36 | } 37 | 38 | public T IdTyped(Func typeConverter) => typeConverter(IdString); 39 | 40 | public override bool Equals(object? obj) 41 | { 42 | if (obj == null || obj.GetType() != typeof(BasicAddress)) 43 | { 44 | return false; 45 | } 46 | 47 | return _id.Equals(((BasicAddress)obj)._id); 48 | } 49 | 50 | public override int GetHashCode() => _id.GetHashCode(); 51 | 52 | public override string ToString() => $"Address[Id={_id}, Name={_name ?? "(none)"}]"; 53 | 54 | internal BasicAddress(long reservedId) : this(reservedId, null) 55 | { 56 | } 57 | 58 | internal BasicAddress(long reservedId, string? name) : this(reservedId, name, false) 59 | { 60 | } 61 | 62 | internal BasicAddress(long reservedId, string? name, bool prefixName) 63 | { 64 | _id = reservedId; 65 | _name = name == null ? null : prefixName ? name + _id : name; 66 | } 67 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/BasicAddressFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | internal sealed class BasicAddressFactory : IAddressFactory 13 | { 14 | private static readonly IAddress None = new BasicAddress(0, "(none)"); 15 | private readonly AtomicLong _highId; 16 | private readonly AtomicLong _nextId; 17 | 18 | internal BasicAddressFactory() 19 | { 20 | _highId = new AtomicLong(World.HighRootId); 21 | _nextId = new AtomicLong(1); 22 | } 23 | 24 | public IAddress FindableBy(T id) => new BasicAddress(long.Parse(id?.ToString()!)); 25 | 26 | public IAddress From(long reservedId, string name) => new BasicAddress(reservedId, name); 27 | 28 | public IAddress From(string idString) => new BasicAddress(long.Parse(idString)); 29 | 30 | public IAddress From(string idString, string name) => new BasicAddress(long.Parse(idString), name); 31 | 32 | public long TestNextIdValue() => _nextId.Get(); // for test only 33 | 34 | public IAddress Unique() => new BasicAddress(_nextId.GetAndIncrement()); 35 | 36 | public IAddress UniquePrefixedWith(string prefixedWith) => new BasicAddress(_nextId.GetAndIncrement(), prefixedWith, true); 37 | 38 | public IAddress UniqueWith(string? name) => new BasicAddress(_nextId.GetAndIncrement(), name); 39 | 40 | public IAddress WithHighId() => WithHighId(null); 41 | 42 | public IAddress WithHighId(string? name) => new BasicAddress(_highId.DecrementAndGet(), name); 43 | 44 | IAddress IAddressFactory.None() => None; 45 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/BroadcastRouter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | /// 14 | /// BrodcastRouter 15 | /// 16 | /// 17 | public abstract class BroadcastRouter : Router 18 | { 19 | protected internal BroadcastRouter(RouterSpecification specification) : base(specification) 20 | { 21 | } 22 | 23 | /// 24 | /// See 25 | /// 26 | protected internal override Routing ComputeRouting() => Routing.With(Routees); 27 | 28 | /// 29 | /// See 30 | /// 31 | protected internal override ICompletes DispatchQuery(Func> query, T1 routable1) 32 | => throw new InvalidOperationException("query protocols are not supported by this router by default"); 33 | 34 | /// 35 | /// See 36 | /// 37 | protected internal override ICompletes DispatchQuery(Func> query, T1 routable1, T2 routable2) 38 | => throw new InvalidOperationException("query protocols are not supported by this router by default"); 39 | 40 | /// 41 | /// See 42 | /// 43 | protected internal override ICompletes DispatchQuery(Func> query, T1 routable1, T2 routable2, T3 routable3) 44 | => throw new InvalidOperationException("query protocols are not supported by this router by default"); 45 | 46 | /// 47 | /// See 48 | /// 49 | protected internal override ICompletes DispatchQuery(Func> query, T1 routable1, T2 routable2, T3 routable3, T4 routable4) 50 | => throw new InvalidOperationException("query protocols are not supported by this router by default"); 51 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Cancellable__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public class Cancellable__Proxy : ICancellable 14 | { 15 | private readonly Actor _actor; 16 | private readonly IMailbox _mailbox; 17 | 18 | public Cancellable__Proxy(Actor actor, IMailbox mailbox) 19 | { 20 | _actor = actor; 21 | _mailbox = mailbox; 22 | } 23 | public bool Cancel() 24 | { 25 | if (!_actor.IsStopped) 26 | { 27 | Action consumer = x => x.Cancel(); 28 | if (_mailbox.IsPreallocated) 29 | { 30 | _mailbox.Send(_actor, consumer, null, "Cancel()"); 31 | } 32 | else 33 | { 34 | _mailbox.Send(new LocalMessage(_actor, consumer, "Cancel()")); 35 | } 36 | 37 | return true; 38 | } 39 | 40 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, "Cancel()")); 41 | return false; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Characters.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public class Characters 15 | { 16 | private int _current; 17 | private readonly T[] _states; 18 | 19 | public Characters(IList states) 20 | { 21 | _states = states.ToArray(); 22 | _current = 0; 23 | } 24 | 25 | public int Become(int which) 26 | { 27 | if (which < 0 || which >= _states.Length) 28 | { 29 | throw new ArgumentOutOfRangeException(nameof(which), "Invalid state"); 30 | } 31 | if (_states[which] == null) 32 | { 33 | throw new ArgumentOutOfRangeException($"The state {which} is null."); 34 | } 35 | var previous = _current; 36 | _current = which; 37 | return previous; 38 | } 39 | 40 | public T Current => _states[_current]; 41 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/CommonSupervisor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | internal abstract class CommonSupervisor : DefaultSupervisor 11 | { 12 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/CompletesEventuallyActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class CompletesEventuallyActor : Actor, ICompletesEventually 13 | { 14 | public virtual void With(object? outcome) 15 | { 16 | try 17 | { 18 | var pooled = (PooledCompletes)outcome!; 19 | pooled.ClientCompletes!.With(pooled.Outcome!); 20 | } 21 | catch (Exception ex) 22 | { 23 | Logger.Error($"The eventually completed outcome '{outcome}' failed in the client because: {ex.Message}", ex); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ContentBasedRouter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | /// 13 | /// ContentBasedRouter is a kind of that considers the 14 | /// content of messages in computing a . 15 | /// 16 | /// 17 | public abstract class ContentBasedRouter

: Router

18 | { 19 | protected ContentBasedRouter(RouterSpecification

specification) : base(specification) 20 | { 21 | } 22 | 23 | protected internal override Routing

ComputeRouting() 24 | { 25 | throw new InvalidOperationException("This router does not have a default routing. Please re-implement the routingFor method(s)"); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DeadLetter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public sealed class DeadLetter 11 | { 12 | private readonly Actor _actor; 13 | private readonly string _representation; 14 | 15 | public DeadLetter(Actor actor, string representation) 16 | { 17 | _actor = actor; 18 | _representation = representation; 19 | } 20 | 21 | public string Representation => _representation; 22 | 23 | public override string ToString() => $"DeadLetter[{_actor}.{_representation}]"; 24 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DeadLettersActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public sealed class DeadLettersActor : Actor, IDeadLetters 14 | { 15 | private readonly IList _listeners; 16 | 17 | public DeadLettersActor() => _listeners = new List(); 18 | 19 | public void FailedDelivery(DeadLetter deadLetter) 20 | { 21 | Logger.Debug(deadLetter.ToString()); 22 | 23 | foreach (var listener in _listeners) 24 | { 25 | try 26 | { 27 | listener.Handle(deadLetter); 28 | } 29 | catch (Exception ex) 30 | { 31 | // ignore, but log 32 | Logger.Warn($"DeadLetters listener failed to handle: {deadLetter}", ex); 33 | } 34 | } 35 | } 36 | 37 | public void RegisterListener(IDeadLettersListener listener) => _listeners.Add(listener); 38 | 39 | protected internal override void BeforeStart() 40 | { 41 | base.BeforeStart(); 42 | Stage.World.SetDeadLetters(SelfAs()); 43 | } 44 | 45 | protected internal override void AfterStop() 46 | { 47 | Stage.World.SetDeadLetters(null); 48 | base.AfterStop(); 49 | } 50 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DeadLettersListener__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class DeadLettersListener__Proxy : IDeadLettersListener 13 | { 14 | private readonly Actor _actor; 15 | private readonly IMailbox _mailbox; 16 | 17 | public DeadLettersListener__Proxy(Actor actor, IMailbox mailbox) 18 | { 19 | _actor = actor; 20 | _mailbox = mailbox; 21 | } 22 | 23 | public void Handle(DeadLetter deadLetter) 24 | { 25 | if (!_actor.IsStopped) 26 | { 27 | Action consumer = x => x.Handle(deadLetter); 28 | if (_mailbox.IsPreallocated) 29 | { 30 | _mailbox.Send(_actor, consumer, null, "Handle(DeadLetter)"); 31 | } 32 | else 33 | { 34 | _mailbox.Send(new LocalMessage(_actor, consumer, "Handle(DeadLetter)")); 35 | } 36 | } 37 | else 38 | { 39 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, "Handle(DeadLetter)")); 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DefaultSupervisionStrategyImpl.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | internal sealed class DefaultSupervisionStrategyImpl : ISupervisionStrategy 11 | { 12 | public int Intensity => SupervisionStrategyConstants.DefaultIntensity; 13 | 14 | public long Period => SupervisionStrategyConstants.DefaultPeriod; 15 | 16 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DefaultSupervisor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public abstract class DefaultSupervisor : Actor, ISupervisor 13 | { 14 | internal static readonly ISupervisionStrategy DefaultSupervisionStrategy = new DefaultSupervisionStrategyImpl(); 15 | 16 | internal DefaultSupervisor() { } 17 | 18 | public ISupervisionStrategy SupervisionStrategy => DefaultSupervisionStrategy; 19 | 20 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 21 | 22 | public void Inform(Exception error, ISupervised supervised) 23 | { 24 | Logger.Error( 25 | $"DefaultSupervisor: Failure of: {supervised.Address} because: {error.Message} Action: Possibly restarting.", 26 | error); 27 | 28 | supervised.RestartWithin( 29 | DefaultSupervisionStrategy.Period, 30 | DefaultSupervisionStrategy.Intensity, 31 | DefaultSupervisionStrategy.Scope); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DefaultSupervisorImpl.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | internal sealed class DefaultSupervisorImpl : ISupervisor 13 | { 14 | public ISupervisionStrategy SupervisionStrategy => DefaultSupervisor.DefaultSupervisionStrategy; 15 | 16 | public ISupervisor Supervisor => new DefaultSupervisorImpl(); 17 | 18 | public void Inform(Exception error, ISupervised supervised) 19 | { 20 | var strategy = DefaultSupervisor.DefaultSupervisionStrategy; 21 | supervised.RestartWithin(strategy.Period, strategy.Intensity, strategy.Scope); 22 | } 23 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DirectoryEvictor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Diagnostics; 10 | using System.Linq; 11 | using Vlingo.Xoom.Actors.Plugin.Eviction; 12 | using Vlingo.Xoom.Common; 13 | 14 | namespace Vlingo.Xoom.Actors; 15 | 16 | internal class DirectoryEvictor : Actor, IScheduled 17 | { 18 | private readonly DirectoryEvictionConfiguration _config; 19 | private readonly Directory _directory; 20 | 21 | public DirectoryEvictor(Directory directory) : this(new DirectoryEvictionConfiguration(), directory) 22 | { 23 | } 24 | 25 | public DirectoryEvictor(DirectoryEvictionConfiguration? config, Directory directory) 26 | { 27 | if (config == null) 28 | { 29 | throw new ArgumentNullException(nameof(config), "The passed in configuration is null. Cannot proceed"); 30 | } 31 | 32 | _config = config; 33 | _directory = directory; 34 | Logger.Debug("Created with config: {}", config); 35 | } 36 | 37 | public void IntervalSignal(IScheduled scheduled, object data) 38 | { 39 | Logger.Debug("Started eviction routine"); 40 | var currentProcess = Process.GetCurrentProcess(); 41 | var fillRatio = currentProcess.PrivateMemorySize64 / (float) currentProcess.WorkingSet64; 42 | if (fillRatio >= _config.FullRatioHighMark) 43 | { 44 | Logger.Debug($"Memory fill ratio {fillRatio} exceeding watermark ({_config.FullRatioHighMark})"); 45 | var evicted = _directory.EvictionCandidates(_config.LruThreshold) 46 | .Where(actor => actor.LifeCycle.Evictable.Stop(_config.LruThreshold)) 47 | .Select(actor => actor.Address) 48 | .ToArray(); 49 | Logger.Debug($"Evicted {evicted.Length} actors :: {evicted}"); 50 | } 51 | else 52 | { 53 | Logger.Debug($"Memory fill ratio {fillRatio} was below watermark ({_config.FullRatioHighMark})"); 54 | } 55 | } 56 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/DirectoryScannerActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | internal class DirectoryScannerActor : Actor, IDirectoryScanner 14 | { 15 | private readonly Directory _directory; 16 | 17 | public DirectoryScannerActor(Directory directory) => _directory = directory; 18 | 19 | public ICompletes ActorOf(IAddress address) 20 | => Completes().With(InternalActorOf(address)); 21 | 22 | public ICompletes ActorOf(IAddress address, Definition definition) 23 | { 24 | var typed = InternalActorOf(address); 25 | 26 | if (typed == null) 27 | { 28 | typed = Stage.ActorFor(definition, address); 29 | } 30 | 31 | return Completes().With(typed); 32 | } 33 | 34 | public ICompletes> MaybeActorOf(IAddress address) 35 | { 36 | var typed = InternalActorOf(address); 37 | var maybe = typed == null ? Optional.Empty() : Optional.Of(typed); 38 | return Completes().With(maybe); 39 | } 40 | 41 | private T InternalActorOf(IAddress address) 42 | { 43 | var actor = _directory.ActorOf(address); 44 | try 45 | { 46 | if (actor != null) 47 | { 48 | return Stage.ActorAs(actor); 49 | } 50 | 51 | Logger.Debug($"Actor with address: {address} not found; protocol is: {typeof(T).Name}"); 52 | } 53 | catch(Exception ex) 54 | { 55 | Logger.Error($"Error providing protocol: {typeof(T).Name} for actor with address: {address}", ex); 56 | } 57 | 58 | return default!; 59 | } 60 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Evictable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | sealed class Evictable 13 | { 14 | private readonly Actor _actor; 15 | private long _activeOn; 16 | 17 | internal Evictable(Actor actor) 18 | { 19 | _actor = actor; 20 | _activeOn = DateTimeHelper.CurrentTimeMillis(); 21 | } 22 | 23 | internal void ReceivedMessage() => ActiveOn(DateTimeHelper.CurrentTimeMillis()); 24 | 25 | void ActiveOn(long activeOn) => _activeOn = activeOn; 26 | 27 | internal bool Stop(long thresholdMillis) => Stop(DateTimeHelper.CurrentTimeMillis(), thresholdMillis); 28 | 29 | bool Stop(long referenceMillis, long thresholdMillis) 30 | { 31 | if (!_actor.Definition.Evictable) 32 | { 33 | return false; 34 | } 35 | 36 | var pendingMessageCount = _actor.LifeCycle.Environment.Mailbox.PendingMessages; 37 | if (IsStale(referenceMillis, thresholdMillis)) 38 | { 39 | if (pendingMessageCount == 0) 40 | { 41 | _actor.SelfAs().Stop(); 42 | return true; 43 | } 44 | 45 | _actor.Logger.Warn( 46 | "Inactive Actor at {} failed to evict because it has {} undelivered messages in its mailbox", 47 | _actor.Address, pendingMessageCount); 48 | } 49 | return false; 50 | } 51 | 52 | internal bool IsStale(long thresholdMillis) => IsStale(DateTimeHelper.CurrentTimeMillis(), thresholdMillis); 53 | 54 | internal bool IsStale(long referenceMillis, long thresholdMillis) => _activeOn < referenceMillis - thresholdMillis; 55 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ExpressionExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq.Expressions; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public static class ExpressionExtensions 15 | { 16 | public static IEnumerable GetArguments(this NewExpression newExpression) 17 | { 18 | var arguments = new List(); 19 | foreach (var argumentExpression in newExpression.Arguments) 20 | { 21 | var conversion = Expression.Convert(argumentExpression, typeof (object)); 22 | var l = Expression.Lambda>(conversion); 23 | var f = l.Compile(); 24 | var res = f(); 25 | 26 | arguments.Add(res); 27 | } 28 | 29 | return arguments; 30 | } 31 | 32 | public static Expression> ToSerializableExpression(this Action internalConsumer) 33 | => x => internalConsumer(x); 34 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/FailureMark.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public sealed class FailureMark 13 | { 14 | private long _startOfPeriod; 15 | private int _timedIntensity; 16 | 17 | public FailureMark() => Reset(); 18 | 19 | internal bool FailedWithExcessiveFailures(long period, int intensity) 20 | { 21 | if (intensity == SupervisionStrategyConstants.ForeverIntensity) 22 | { 23 | return false; 24 | } 25 | 26 | if (intensity == 1) 27 | { 28 | return true; 29 | } 30 | 31 | var currentTime = DateTimeHelper.CurrentTimeMillis(); 32 | 33 | if (_startOfPeriod == 0) 34 | { 35 | _startOfPeriod = currentTime; 36 | _timedIntensity = 1; 37 | } 38 | else 39 | { 40 | ++_timedIntensity; 41 | } 42 | 43 | var periodExceeded = _startOfPeriod - currentTime >= period; 44 | 45 | if (_timedIntensity > intensity && !periodExceeded) 46 | { 47 | return true; 48 | } 49 | 50 | if (periodExceeded) 51 | { 52 | Reset(); 53 | return FailedWithExcessiveFailures(period, intensity); 54 | } 55 | 56 | return false; 57 | } 58 | 59 | private void Reset() 60 | { 61 | _startOfPeriod = 0; 62 | _timedIntensity = 0; 63 | } 64 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/GuidAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.UUID; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public class GuidAddress : IAddress 14 | { 15 | private readonly Guid _id; 16 | private readonly string? _name; 17 | 18 | public long Id => _id.ToLeastSignificantBits(); 19 | 20 | public Guid ReservedId => _id; 21 | 22 | public long IdSequence => _id.ToLeastSignificantBits(); 23 | 24 | public string IdSequenceString => _id.ToLeastSignificantBits().ToString(); 25 | 26 | public string IdString => _id.ToString(); 27 | 28 | public T IdTyped(Func typeConverter) => typeConverter(IdString); 29 | 30 | public string Name => string.IsNullOrEmpty(_name) ? IdString : _name!; 31 | 32 | public virtual bool IsDistributable => false; 33 | 34 | public int CompareTo(IAddress? other) => Id.CompareTo(other?.Id); 35 | 36 | public override bool Equals(object? obj) 37 | { 38 | if (obj == null || obj.GetType() != GetType()) 39 | { 40 | return false; 41 | } 42 | 43 | return _id.Equals(((GuidAddress) obj)._id); 44 | } 45 | 46 | public override int GetHashCode() => _id.GetHashCode(); 47 | 48 | public override string ToString() => $"{GetType().Name}[id={_id}, name={(string.IsNullOrEmpty(_name) ? "(none)" : _name)}]"; 49 | 50 | protected internal GuidAddress(Guid reservedId) : this(reservedId, null, false) 51 | { 52 | } 53 | 54 | protected internal GuidAddress(Guid reservedId, string? name) : this(reservedId, name, false) 55 | { 56 | } 57 | 58 | protected internal GuidAddress(Guid reservedId, string? name, bool prefixName) 59 | { 60 | _id = reservedId; 61 | _name = name == null ? null : prefixName ? $"{name}{_id}" : name; 62 | } 63 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IAddress.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface IAddress : IComparable 13 | { 14 | long Id { get; } 15 | long IdSequence { get; } 16 | string IdSequenceString { get; } 17 | string IdString { get; } 18 | T IdTyped(Func typeConverter); 19 | string Name { get; } 20 | bool IsDistributable { get; } 21 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IAddressFactory.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IAddressFactory 11 | { 12 | IAddress FindableBy(T id); 13 | IAddress From(long reservedId, string name); 14 | IAddress From(string idString); 15 | IAddress From(string idString, string name); 16 | IAddress None(); 17 | IAddress Unique(); 18 | IAddress UniquePrefixedWith(string prefixedWith); 19 | IAddress UniqueWith(string? name); 20 | IAddress WithHighId(); 21 | IAddress WithHighId(string name); 22 | long TestNextIdValue(); 23 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IAddressable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | internal interface IAddressable 11 | { 12 | IAddress Address { get; } 13 | LifeCycle LifeCycle { get; } 14 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ICompletesEventually.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface ICompletesEventually : IStoppable 11 | { 12 | IAddress Address { get; } 13 | void With(object? outcome); 14 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ICompletesEventuallyProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface ICompletesEventuallyProvider 13 | { 14 | void Close(); 15 | ICompletesEventually CompletesEventually { get; } 16 | void InitializeUsing(Stage stage); 17 | ICompletesEventually ProvideCompletesFor(ICompletes? clientCompletes); 18 | ICompletesEventually ProvideCompletesFor(IAddress address, ICompletes? clientCompletes); 19 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ICompletesEventuallyProviderKeeper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface ICompletesEventuallyProviderKeeper 11 | { 12 | ICompletesEventuallyProvider ProviderFor(string name); 13 | void Close(); 14 | ICompletesEventuallyProvider FindDefault(); 15 | void Keep(string name, ICompletesEventuallyProvider completesEventuallyProvider); 16 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IDeadLetters.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IDeadLetters : IStoppable 11 | { 12 | void FailedDelivery(DeadLetter deadLetter); 13 | void RegisterListener(IDeadLettersListener listener); 14 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IDeadLettersListener.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IDeadLettersListener 11 | { 12 | void Handle(DeadLetter deadLetter); 13 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IDirectoryScanner.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface IDirectoryScanner 13 | { 14 | ICompletes ActorOf(IAddress address); 15 | ICompletes ActorOf(IAddress address, Definition definition); 16 | ICompletes> MaybeActorOf(IAddress address); 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IDispatcher.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IDispatcher 11 | { 12 | bool IsClosed { get; } 13 | void Close(); 14 | bool RequiresExecutionNotification { get; } 15 | 16 | /// 17 | /// Gets the total capacity for concurrent operations. 18 | /// 19 | int ConcurrencyCapacity { get; } 20 | void Execute(IMailbox mailbox); 21 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ILogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Actors.Plugin.Logging; 10 | using Vlingo.Xoom.Actors.Plugin.Logging.Console; 11 | using Vlingo.Xoom.Actors.Plugin.Logging.NoOp; 12 | 13 | namespace Vlingo.Xoom.Actors; 14 | 15 | public interface ILogger 16 | { 17 | bool IsEnabled { get; } 18 | string Name { get; } 19 | void Close(); 20 | 21 | void Trace(string message); 22 | void Trace(string message, params object[] args); 23 | void Trace(string message, Exception exception); 24 | 25 | void Debug(string message); 26 | void Debug(string message, params object[] args); 27 | void Debug(string message, Exception exception); 28 | 29 | void Info(string message); 30 | void Info(string message, params object[] args); 31 | void Info(string message, Exception exception); 32 | 33 | void Warn(string message); 34 | void Warn(string message, params object[] args); 35 | void Warn(string message, Exception exception); 36 | 37 | void Error(string message); 38 | void Error(string message, params object[] args); 39 | void Error(string message, Exception exception); 40 | 41 | void Trace(LogEvent logEvent); 42 | void Debug(LogEvent logEvent); 43 | void Info(LogEvent logEvent); 44 | void Warn(LogEvent logEvent); 45 | void Error(LogEvent logEvent); 46 | } 47 | 48 | internal static class Logger 49 | { 50 | public static ILogger NoOpLogger => new NoOpLogger(); 51 | 52 | public static ILogger BasicLogger => ConsoleLogger.BasicInstance(); 53 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ILoggerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Plugin.Logging.Console; 9 | using Vlingo.Xoom.Actors.Plugin.Logging.NoOp; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public interface ILoggerProvider 14 | { 15 | void Close(); 16 | ILogger? Logger { get; } 17 | } 18 | 19 | internal static class LoggerProvider 20 | { 21 | internal static ILoggerProvider NoOpLoggerProvider() 22 | => new NoOpLoggerProvider(); 23 | 24 | internal static ILoggerProvider StandardLoggerProvider(World world, string name) 25 | => ConsoleLoggerPlugin.RegisterStandardLogger(name, world); 26 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ILoggerProviderKeeper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface ILoggerProviderKeeper 11 | { 12 | void Close(); 13 | ILoggerProvider? FindDefault(); 14 | ILoggerProvider FindNamed(string name); 15 | void Keep(string name, bool isDefault, ILoggerProvider loggerProvider); 16 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IMailboxProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IMailboxProvider 11 | { 12 | void Close(); 13 | IMailbox ProvideMailboxFor(int? hashCode); 14 | IMailbox ProvideMailboxFor(int? hashCode, IDispatcher dispatcher); 15 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IMailboxProviderKeeper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IMailboxProviderKeeper 11 | { 12 | IMailbox AssignMailbox(string name, int? hashCode); 13 | void Close(); 14 | string FindDefault(); 15 | void Keep(string name, bool isDefault, IMailboxProvider mailboxProvider); 16 | bool IsValidMailboxName(string candidateMailboxName); 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Linq.Expressions; 10 | using Vlingo.Xoom.Common; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public interface IMessage 15 | { 16 | Actor Actor { get; } 17 | ICompletes? Completes { get; } 18 | void Deliver(); 19 | Type Protocol { get; } 20 | string Representation { get; } 21 | bool IsStowed { get; } 22 | LambdaExpression? SerializableConsumer { get; } 23 | void Set(Actor actor, Action consumer, ICompletes? completes, string representation); 24 | void Set(Actor actor, Type protocol, LambdaExpression? consumer, ICompletes? completes, string representation); 25 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/INoProtocol.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface INoProtocol 11 | { 12 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IProxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | /// 11 | /// Defines the interface for all proxies. The Actor's is 12 | /// available as well as Equals(), GetHashCode(), and ToString(). 13 | /// 14 | public interface IProxy 15 | { 16 | /// 17 | /// Gets the underlying 18 | /// 19 | IAddress Address { get; } 20 | } 21 | 22 | public static class ProxyExtensions 23 | { 24 | public static IProxy FromRaw(this object proxy) => (IProxy) proxy; 25 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IRegistrar.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface IRegistrar 13 | { 14 | void Register(string name, ICompletesEventuallyProvider completesEventuallyProvider); 15 | void Register(string name, bool isDefault, ILoggerProvider loggerProvider); 16 | void Register(string name, bool isDefault, IMailboxProvider mailboxProvider); 17 | void RegisterCommonSupervisor(string stageName, string name, Type? supervisedProtocol, Type? supervisorClass); 18 | void RegisterDefaultSupervisor(string stageName, string name, Type? supervisorClass); 19 | void RegisterCompletesEventuallyProviderKeeper(ICompletesEventuallyProviderKeeper keeper); 20 | void RegisterLoggerProviderKeeper(ILoggerProviderKeeper keeper); 21 | void RegisterMailboxProviderKeeper(IMailboxProviderKeeper keeper); 22 | World World { get; } 23 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IRelocatable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IRelocatable 11 | { 12 | /// 13 | /// Sets my typed state snapshot, which by default does nothing. 14 | /// Override to set a snapshot state. 15 | /// 16 | /// The typed state snapshot to set 17 | /// The type of the state snapshot 18 | void StateSnapshot(S stateSnapshot); 19 | 20 | /// 21 | /// Answer my typed state snapshot, which is null by default. 22 | /// Override to set a snapshot state. 23 | /// 24 | /// The type of the state snapshot 25 | S StateSnapshot(); 26 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ISafeProxyGenerable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface ISafeProxyGenerable 11 | { 12 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IStartable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public interface IStartable 11 | { 12 | void Start(); 13 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/IStoppable.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | /// 11 | /// Arranges for stopping the receiver. 12 | /// 13 | /// Note that the contract of stop() is to suspend the receivers mailbox 14 | /// deliveries, which will prevent further processing. To arrange for 15 | /// eventually stopping the receiver send Conclude(), which will then 16 | /// cause Stop(). In essence the Conclude() marks the mailbox for ending 17 | /// operations, but allows messages already queued to first be delivered. 18 | /// 19 | /// 20 | public interface IStoppable 21 | { 22 | /// 23 | /// Concludes the receiver, eventually causing 24 | /// it to receive a Stop() message. 25 | /// 26 | void Conclude(); 27 | 28 | /// 29 | /// Answer whether or not the receiver is stopped. 30 | /// 31 | bool IsStopped { get; } 32 | 33 | /// 34 | /// Causes the receiver to stop reacting to messages and to eventually 35 | /// be garbage collected. 36 | /// 37 | /// Note that the contract of Stop() is to suspend the receivers mailbox 38 | /// deliveries, which will prevent further processing. To arrange for 39 | /// eventually stopping the receiver send Conclude(), which will then 40 | /// cause Stop(). In essence the Conclude() marks the mailbox for ending 41 | /// operations, but allows messages already queued to first be delivered. 42 | /// 43 | /// 44 | void Stop(); 45 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ISupervised.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using static Vlingo.Xoom.Actors.SupervisionStrategyConstants; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public interface ISupervised 14 | { 15 | IAddress Address { get; } 16 | void Escalate(); 17 | void RestartWithin(long period, int intensity, Scope scope); 18 | void Resume(); 19 | void Stop(Scope scope); 20 | ISupervisor Supervisor { get; } 21 | void Suspend(); 22 | Exception Error { get; } 23 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ISupervisionStrategy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using static Vlingo.Xoom.Actors.SupervisionStrategyConstants; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface ISupervisionStrategy 13 | { 14 | int Intensity { get; } 15 | long Period { get; } 16 | Scope Scope { get; } 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ISupervisor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public interface ISupervisor 13 | { 14 | void Inform(Exception error, ISupervised supervised); 15 | ISupervisionStrategy SupervisionStrategy { get; } 16 | ISupervisor Supervisor { get; } 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/InvalidProtocolException.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public class InvalidProtocolException : Exception 15 | { 16 | private const long SerialVersionId = 1L; 17 | 18 | public InvalidProtocolException(string protocolName, IList failures) 19 | : base(ToReadableMessage(protocolName, failures)) 20 | { 21 | } 22 | 23 | private static string ToReadableMessage(string protocolName, IList failures) 24 | => string.Format( 25 | "For protocol {0}\n{1}", 26 | protocolName, 27 | string.Join("\n", failures.Select(f => $"\t{f.ToString()}"))); 28 | 29 | public class Failure 30 | { 31 | private readonly string _method; 32 | private readonly string _cause; 33 | 34 | public Failure(string method, string cause) 35 | { 36 | _method = method; 37 | _cause = cause; 38 | } 39 | 40 | public override string ToString() 41 | => $"In method `{_method}`: \n\t\t{_cause}"; 42 | } 43 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/LocalMessageAsync.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Threading.Tasks; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class LocalMessageAsync : LocalMessage 13 | { 14 | private readonly ExecutorDispatcherAsync _executor; 15 | private readonly Task _task; 16 | 17 | public LocalMessageAsync(ExecutorDispatcherAsync executor, Task task) 18 | { 19 | _executor = executor; 20 | _task = task; 21 | } 22 | 23 | public override void Deliver() => _executor.ExecuteTask(_task); 24 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/NoProtocol__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public class NoProtocol__Proxy : INoProtocol 11 | { 12 | public NoProtocol__Proxy(Actor actor, IMailbox mailbox) 13 | { 14 | } 15 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/AbstractPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin; 9 | 10 | public abstract class AbstractPlugin : IPlugin 11 | { 12 | public abstract string Name { get; } 13 | public abstract int Pass { get; } 14 | public abstract IPluginConfiguration Configuration { get; } 15 | 16 | public abstract void Close(); 17 | public abstract void Start(IRegistrar registrar); 18 | public abstract IPlugin With(IPluginConfiguration? overrideConfiguration); 19 | 20 | public override bool Equals(object? obj) 21 | { 22 | if (obj == null || obj.GetType() != GetType()) 23 | { 24 | return false; 25 | } 26 | 27 | return string.Equals(Name, ((IPlugin)obj).Name); 28 | } 29 | 30 | public override int GetHashCode() => 31 | $"{GetType().FullName}::{Name}".GetHashCode(); 32 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Completes/DefaultCompletesEventuallyProviderKeeper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Completes; 11 | 12 | public sealed class DefaultCompletesEventuallyProviderKeeper : ICompletesEventuallyProviderKeeper 13 | { 14 | private CompletesEventuallyProviderInfo? _completesEventuallyProviderInfo; 15 | 16 | public void Close() => _completesEventuallyProviderInfo?.CompletesEventuallyProvider.Close(); 17 | 18 | public ICompletesEventuallyProvider FindDefault() 19 | { 20 | if (_completesEventuallyProviderInfo == null) 21 | { 22 | throw new InvalidOperationException("No registered default CompletesEventuallyProvider."); 23 | } 24 | 25 | return _completesEventuallyProviderInfo.CompletesEventuallyProvider; 26 | } 27 | 28 | public void Keep(string name, ICompletesEventuallyProvider completesEventuallyProvider) => _completesEventuallyProviderInfo = new CompletesEventuallyProviderInfo(name, completesEventuallyProvider, true); 29 | 30 | public ICompletesEventuallyProvider ProviderFor(string name) 31 | { 32 | if (_completesEventuallyProviderInfo == null) 33 | { 34 | throw new InvalidOperationException($"No registered CompletesEventuallyProvider named: {name}"); 35 | } 36 | 37 | return _completesEventuallyProviderInfo.CompletesEventuallyProvider; 38 | } 39 | 40 | private class CompletesEventuallyProviderInfo 41 | { 42 | public bool IsDefault; 43 | public readonly ICompletesEventuallyProvider CompletesEventuallyProvider; 44 | public string Name; 45 | public CompletesEventuallyProviderInfo(string name, ICompletesEventuallyProvider completesEventuallyProvider, bool isDefault) 46 | { 47 | Name = name; 48 | CompletesEventuallyProvider = completesEventuallyProvider; 49 | IsDefault = isDefault; 50 | } 51 | } 52 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Completes/PooledCompletesPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Completes; 9 | 10 | public class PooledCompletesPlugin : AbstractPlugin 11 | { 12 | private readonly PooledCompletesPluginConfiguration _pooledCompletesPluginConfiguration; 13 | 14 | private ICompletesEventuallyProvider? _completesEventuallyProvider; 15 | 16 | public PooledCompletesPlugin(string? name = null) => _pooledCompletesPluginConfiguration = PooledCompletesPluginConfiguration.Define(); 17 | 18 | private PooledCompletesPlugin(IPluginConfiguration configuration) => _pooledCompletesPluginConfiguration = (PooledCompletesPluginConfiguration)configuration; 19 | 20 | public override string Name => Configuration.Name; 21 | 22 | public override int Pass => 2; 23 | 24 | public override IPluginConfiguration Configuration => _pooledCompletesPluginConfiguration; 25 | 26 | public override void Close() => _completesEventuallyProvider!.Close(); 27 | 28 | public override void Start(IRegistrar registrar) 29 | { 30 | _completesEventuallyProvider = new CompletesEventuallyPool(_pooledCompletesPluginConfiguration.PoolSize, _pooledCompletesPluginConfiguration.Mailbox!); 31 | registrar.Register(_pooledCompletesPluginConfiguration.Name, _completesEventuallyProvider!); 32 | } 33 | 34 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 35 | => overrideConfiguration == null ? this : new PooledCompletesPlugin(overrideConfiguration); 36 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Completes/PooledCompletesPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Completes; 9 | 10 | public class PooledCompletesPluginConfiguration : IPluginConfiguration 11 | { 12 | private PooledCompletesPluginConfiguration() => Name = "pooledCompletes"; 13 | 14 | public static PooledCompletesPluginConfiguration Define() => new PooledCompletesPluginConfiguration(); 15 | 16 | public PooledCompletesPluginConfiguration WithMailbox(string mailbox) 17 | { 18 | Mailbox = mailbox; 19 | return this; 20 | } 21 | 22 | public PooledCompletesPluginConfiguration WithPoolSize(int poolSize) 23 | { 24 | PoolSize = poolSize; 25 | return this; 26 | } 27 | 28 | public string? Mailbox { get; private set; } 29 | 30 | public int PoolSize { get; private set; } 31 | 32 | public string Name { get; private set; } 33 | 34 | public void Build(Configuration configuration) 35 | { 36 | configuration.With( 37 | WithMailbox("queueMailbox") 38 | .WithPoolSize(10) 39 | ); 40 | } 41 | 42 | public void BuildWith(Configuration configuration, PluginProperties properties) 43 | { 44 | Name = properties.Name; 45 | Mailbox = properties.GetString("mailbox", null); 46 | PoolSize = properties.GetInteger("pool", 10); 47 | configuration.With(this); 48 | } 49 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/DynamicTypeLoader.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.IO; 10 | using System.Reflection; 11 | 12 | namespace Vlingo.Xoom.Actors.Plugin; 13 | 14 | public class DynamicTypeLoader : IPluginTypeLoader 15 | { 16 | private readonly string[] _assemblyPaths; 17 | 18 | public DynamicTypeLoader(string[] assemblyPaths) => _assemblyPaths = assemblyPaths; 19 | 20 | public Type LoadType(string name) 21 | { 22 | foreach (var assemblyPath in _assemblyPaths) 23 | { 24 | try 25 | { 26 | var assembly = Assembly.LoadFile(assemblyPath); 27 | var type = assembly.GetType(name); 28 | if (type != null) 29 | { 30 | return type; 31 | } 32 | } 33 | catch (Exception) 34 | { 35 | // nothing to do 36 | } 37 | } 38 | 39 | throw new FileNotFoundException($"Could not load assembly for given paths '{string.Join(",", _assemblyPaths)}'"); 40 | } 41 | 42 | public Stream? LoadResource(string resourceName) 43 | { 44 | foreach (var assemblyPath in _assemblyPaths) 45 | { 46 | try 47 | { 48 | var assembly = Assembly.LoadFile(assemblyPath); 49 | var path = $"{resourceName.Replace("/", ".").Replace(" ", "_")}"; 50 | var stream = assembly.GetManifestResourceStream(path); 51 | return stream; 52 | } 53 | catch (Exception) 54 | { 55 | // nothing to do 56 | } 57 | } 58 | 59 | throw new FileNotFoundException($"Could not load assembly for given paths '{string.Join(",", _assemblyPaths)}'"); 60 | } 61 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Eviction/DirectoryEvictionPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Eviction; 9 | 10 | public class DirectoryEvictionPlugin : AbstractPlugin 11 | { 12 | private readonly DirectoryEvictionConfiguration _configuration; 13 | 14 | public DirectoryEvictionPlugin(string? name = null) : this(DirectoryEvictionConfiguration.Define()) 15 | { 16 | } 17 | 18 | private DirectoryEvictionPlugin(DirectoryEvictionConfiguration configuration) => _configuration = configuration; 19 | 20 | public override void Close() 21 | { 22 | } 23 | 24 | public override void Start(IRegistrar registrar) 25 | { 26 | } 27 | 28 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 29 | { 30 | if (overrideConfiguration == null) 31 | { 32 | return this; 33 | } 34 | 35 | return new DirectoryEvictionPlugin((DirectoryEvictionConfiguration) overrideConfiguration); 36 | } 37 | 38 | public override string Name => _configuration.Name; 39 | public override int Pass { get; } = 2; 40 | public override IPluginConfiguration Configuration => _configuration; 41 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/IPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin; 9 | 10 | public interface IPlugin 11 | { 12 | void Close(); 13 | string Name { get; } 14 | int Pass { get; } 15 | IPluginConfiguration Configuration { get; } 16 | void Start(IRegistrar registrar); 17 | IPlugin With(IPluginConfiguration? overrideConfiguration); 18 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/IPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin; 9 | 10 | public interface IPluginConfiguration 11 | { 12 | void Build(Configuration configuration); 13 | 14 | void BuildWith(Configuration configuration, PluginProperties properties); 15 | 16 | string Name { get; } 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/IPluginTypeLoader.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.IO; 10 | 11 | namespace Vlingo.Xoom.Actors.Plugin; 12 | 13 | public interface IPluginTypeLoader 14 | { 15 | Type? LoadType(string name); 16 | Stream? LoadResource(string resourceName); 17 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Logging/Console/ConsoleLoggerPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Logging.Console; 9 | 10 | public class ConsoleLoggerPluginConfiguration : IPluginConfiguration 11 | { 12 | private ConsoleLoggerPluginConfiguration() 13 | { 14 | Name = "consoleLogger"; 15 | } 16 | 17 | public static ConsoleLoggerPluginConfiguration Define() => new ConsoleLoggerPluginConfiguration(); 18 | 19 | public ConsoleLoggerPluginConfiguration WithDefaultLogger() 20 | { 21 | IsDefaultLogger = true; 22 | return this; 23 | } 24 | 25 | public ConsoleLoggerPluginConfiguration WithName(string name) 26 | { 27 | Name = name; 28 | return this; 29 | } 30 | 31 | public bool IsDefaultLogger { get; private set; } 32 | 33 | public string Name { get; private set; } 34 | 35 | public void Build(Configuration configuration) 36 | { 37 | configuration.With( 38 | WithDefaultLogger() 39 | .WithName("vlingo-net/actors") 40 | ); 41 | } 42 | 43 | public void BuildWith(Configuration configuration, PluginProperties properties) 44 | { 45 | Name = properties.Name; 46 | IsDefaultLogger = properties.GetBoolean("defaultLogger", true); 47 | } 48 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Logging/NoOp/NoOpLogger.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Logging.NoOp; 11 | 12 | public class NoOpLogger : ILogger 13 | { 14 | public bool IsEnabled => false; 15 | 16 | public string Name => "no-op"; 17 | 18 | public void Close() 19 | { 20 | } 21 | 22 | public void Debug(string message) 23 | { 24 | } 25 | 26 | public void Debug(string message, params object[] args) 27 | { 28 | } 29 | 30 | public void Debug(string message, Exception exception) 31 | { 32 | } 33 | 34 | public void Error(string message) 35 | { 36 | } 37 | 38 | public void Error(string message, params object[] args) 39 | { 40 | } 41 | 42 | public void Error(string message, Exception exception) 43 | { 44 | } 45 | 46 | public void Trace(LogEvent logEvent) 47 | { 48 | } 49 | 50 | public void Debug(LogEvent logEvent) 51 | { 52 | } 53 | 54 | public void Info(LogEvent logEvent) 55 | { 56 | } 57 | 58 | public void Warn(LogEvent logEvent) 59 | { 60 | } 61 | 62 | public void Error(LogEvent logEvent) 63 | { 64 | } 65 | 66 | public void Info(string message) 67 | { 68 | } 69 | 70 | public void Info(string message, params object[] args) 71 | { 72 | } 73 | 74 | public void Info(string message, Exception exception) 75 | { 76 | } 77 | 78 | public void Trace(string message) 79 | { 80 | } 81 | 82 | public void Trace(string message, params object[] args) 83 | { 84 | } 85 | 86 | public void Trace(string message, Exception exception) 87 | { 88 | } 89 | 90 | public void Warn(string message) 91 | { 92 | } 93 | 94 | public void Warn(string message, params object[] args) 95 | { 96 | } 97 | 98 | public void Warn(string message, Exception exception) 99 | { 100 | } 101 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Logging/NoOp/NoOpLoggerProvider.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Logging.NoOp; 9 | 10 | public class NoOpLoggerProvider : ILoggerProvider 11 | { 12 | public NoOpLoggerProvider() => Logger = new NoOpLogger(); 13 | 14 | public ILogger Logger { get; } 15 | 16 | public void Close() 17 | { 18 | } 19 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/AgronaMPSCArrayQueue/ManyToOneConcurrentArrayQueuePlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.AgronaMPSCArrayQueue; 11 | 12 | public class ManyToOneConcurrentArrayQueuePlugin : AbstractPlugin, IMailboxProvider 13 | { 14 | private readonly ManyToOneConcurrentArrayQueuePluginConfiguration _configuration; 15 | 16 | public ManyToOneConcurrentArrayQueuePlugin(string? name = null) => 17 | _configuration = ManyToOneConcurrentArrayQueuePluginConfiguration.Define(); 18 | 19 | internal ManyToOneConcurrentArrayQueuePlugin(IPluginConfiguration configuration) => 20 | _configuration = (ManyToOneConcurrentArrayQueuePluginConfiguration)configuration; 21 | 22 | public override void Close() 23 | { 24 | // mailbox closes its dispatcher 25 | } 26 | 27 | public override string Name => _configuration.Name; 28 | 29 | public override int Pass => 1; 30 | 31 | public override IPluginConfiguration Configuration => _configuration; 32 | 33 | public override void Start(IRegistrar registrar) 34 | => registrar.Register(_configuration.Name, _configuration.IsDefaultMailbox, this); 35 | 36 | public IMailbox ProvideMailboxFor(int? hashCode) 37 | { 38 | var newDispatcher = new ManyToOneConcurrentArrayQueueDispatcher( 39 | _configuration.RingSize, 40 | _configuration.FixedBackoff, 41 | _configuration.NotifyOnSend, 42 | _configuration.DispatcherThrottlingCount, 43 | _configuration.SendRetires); 44 | 45 | newDispatcher.Start(); 46 | 47 | return newDispatcher.Mailbox; 48 | } 49 | 50 | public IMailbox ProvideMailboxFor(int? hashCode, IDispatcher? dispatcher) => 51 | throw new InvalidOperationException("Does not support dispatcher reuse."); 52 | 53 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 54 | => overrideConfiguration == null ? this : new ManyToOneConcurrentArrayQueuePlugin(overrideConfiguration); 55 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/ConcurrentQueue/ConcurrentQueueMailboxPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.ConcurrentQueue; 11 | 12 | public class ConcurrentQueueMailboxPlugin : AbstractPlugin, IMailboxProvider 13 | { 14 | private readonly ConcurrentQueueMailboxPluginConfiguration _configuration; 15 | private IDispatcher? _executorDispatcher; 16 | 17 | public ConcurrentQueueMailboxPlugin(string name) => _configuration = ConcurrentQueueMailboxPluginConfiguration.Define(name); 18 | 19 | internal ConcurrentQueueMailboxPlugin(IPluginConfiguration configuration) => _configuration = (ConcurrentQueueMailboxPluginConfiguration)configuration; 20 | 21 | public override string Name => _configuration.Name; 22 | 23 | public override int Pass => 1; 24 | 25 | public override IPluginConfiguration Configuration => _configuration; 26 | 27 | public override void Start(IRegistrar registrar) 28 | { 29 | _executorDispatcher = new ExecutorDispatcher( 30 | System.Environment.ProcessorCount, 31 | _configuration.NumberOfDispatchers, 32 | _configuration.NumberOfDispatchersFactor); 33 | registrar.Register(_configuration.Name, _configuration.IsDefaultMailbox, this); 34 | } 35 | 36 | public IMailbox ProvideMailboxFor(int? hashCode) 37 | => new ConcurrentQueueMailbox(_executorDispatcher!, _configuration.DispatcherThrottlingCount); 38 | 39 | public IMailbox ProvideMailboxFor(int? hashCode, IDispatcher dispatcher) 40 | { 41 | if(dispatcher == null) 42 | { 43 | throw new ArgumentNullException(nameof(dispatcher)); 44 | } 45 | 46 | return new ConcurrentQueueMailbox(dispatcher, _configuration.DispatcherThrottlingCount); 47 | } 48 | 49 | public override void Close() => _executorDispatcher!.Close(); 50 | 51 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 52 | => overrideConfiguration == null ? this : new ConcurrentQueueMailboxPlugin(overrideConfiguration); 53 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/ConcurrentQueue/ConcurrentQueueMailboxPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.ConcurrentQueue; 9 | 10 | public class ConcurrentQueueMailboxPluginConfiguration : IPluginConfiguration 11 | { 12 | private ConcurrentQueueMailboxPluginConfiguration(string? name = null) => Name = name ?? "queueMailbox"; 13 | 14 | public static ConcurrentQueueMailboxPluginConfiguration Define(string? name = null) => new ConcurrentQueueMailboxPluginConfiguration(name); 15 | 16 | public ConcurrentQueueMailboxPluginConfiguration WithDefaultMailbox() 17 | { 18 | IsDefaultMailbox = true; 19 | return this; 20 | } 21 | 22 | public bool IsDefaultMailbox { get; private set; } 23 | 24 | public ConcurrentQueueMailboxPluginConfiguration WithDispatcherThrottlingCount(int dispatcherThrottlingCount) 25 | { 26 | DispatcherThrottlingCount = dispatcherThrottlingCount; 27 | return this; 28 | } 29 | 30 | public int DispatcherThrottlingCount { get; private set; } 31 | 32 | public ConcurrentQueueMailboxPluginConfiguration WithNumberOfDispatchersFactor(float numberOfDispatchersFactor) 33 | { 34 | NumberOfDispatchersFactor = numberOfDispatchersFactor; 35 | return this; 36 | } 37 | 38 | public ConcurrentQueueMailboxPluginConfiguration WithNumberOfDispatchers(int numberOfDispatchers) 39 | { 40 | NumberOfDispatchers = numberOfDispatchers; 41 | return this; 42 | } 43 | 44 | public float NumberOfDispatchersFactor { get; private set; } 45 | 46 | public int NumberOfDispatchers { get; private set; } 47 | 48 | public string Name { get; private set; } 49 | 50 | public void Build(Configuration configuration) 51 | { 52 | configuration.With( 53 | WithDefaultMailbox() 54 | .WithNumberOfDispatchersFactor(1.5f) 55 | .WithDispatcherThrottlingCount(1)); 56 | } 57 | 58 | public void BuildWith(Configuration configuration, PluginProperties properties) 59 | { 60 | Name = properties.Name; 61 | IsDefaultMailbox = properties.GetBoolean("defaultMailbox", true); 62 | DispatcherThrottlingCount = properties.GetInteger("dispatcherThrottlingCount", 1); 63 | NumberOfDispatchersFactor = properties.GetFloat("numberOfDispatchersFactor", 1.5f); 64 | } 65 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/ConcurrentQueue/ExecutorDispatcher.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.ConcurrentQueue; 12 | 13 | public class ExecutorDispatcher : IDispatcher 14 | { 15 | private readonly AtomicBoolean _closed; 16 | private readonly ThreadPoolExecutor _executor; 17 | private readonly int _maxAllowedConcurrentThreads; 18 | 19 | internal ExecutorDispatcher(int availableThreads, int numberOfDispatchers, float numberOfDispatchersFactor) 20 | { 21 | _maxAllowedConcurrentThreads = numberOfDispatchers > 0 ? 22 | numberOfDispatchers : (int)(availableThreads * numberOfDispatchersFactor); 23 | _closed = new AtomicBoolean(false); 24 | _executor = new ThreadPoolExecutor(_maxAllowedConcurrentThreads, HandleRejection); 25 | } 26 | 27 | public void Close() 28 | { 29 | _closed.Set(true); 30 | _executor.Shutdown(); 31 | } 32 | 33 | public bool IsClosed => _closed.Get(); 34 | 35 | public bool RequiresExecutionNotification => false; 36 | 37 | public int ConcurrencyCapacity => _maxAllowedConcurrentThreads; 38 | 39 | public void Execute(IMailbox mailbox) 40 | { 41 | if (!IsClosed) 42 | { 43 | _executor.Execute(mailbox); 44 | } 45 | } 46 | 47 | private void HandleRejection(IRunnable task) 48 | { 49 | if (!IsClosed) 50 | { 51 | throw new InvalidOperationException("Message cannot be sent due to current system resource limitations."); 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/DefaultMailboxProviderKeeper.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox; 12 | 13 | public sealed class DefaultMailboxProviderKeeper : IMailboxProviderKeeper 14 | { 15 | private readonly IDictionary _mailboxProviderInfos; 16 | private MailboxProviderInfo? _defaultProvider; 17 | 18 | public DefaultMailboxProviderKeeper() 19 | { 20 | _mailboxProviderInfos = new Dictionary(); 21 | _defaultProvider = null; 22 | } 23 | 24 | public IMailbox AssignMailbox(string name, int? hashCode) 25 | { 26 | if (!_mailboxProviderInfos.ContainsKey(name)) 27 | { 28 | throw new InvalidOperationException($"No registered MailboxProvider named: {name}"); 29 | } 30 | 31 | return _mailboxProviderInfos[name].MailboxProvider.ProvideMailboxFor(hashCode); 32 | } 33 | 34 | public void Close() 35 | { 36 | foreach(var info in _mailboxProviderInfos.Values) 37 | { 38 | info.MailboxProvider.Close(); 39 | } 40 | } 41 | 42 | public string FindDefault() 43 | { 44 | if (_defaultProvider == null) 45 | { 46 | throw new InvalidOperationException("No registered default MailboxProvider."); 47 | } 48 | 49 | return _defaultProvider.Name; 50 | } 51 | 52 | public bool IsValidMailboxName(string candidateMailboxName) 53 | => _mailboxProviderInfos.ContainsKey(candidateMailboxName); 54 | 55 | public void Keep(string name, bool isDefault, IMailboxProvider mailboxProvider) 56 | { 57 | var info = new MailboxProviderInfo(name, mailboxProvider); 58 | _mailboxProviderInfos[name] = info; 59 | 60 | if (_defaultProvider == null || isDefault) 61 | { 62 | _defaultProvider = info; 63 | } 64 | } 65 | 66 | private sealed class MailboxProviderInfo 67 | { 68 | public readonly IMailboxProvider MailboxProvider; 69 | public readonly string Name; 70 | 71 | public MailboxProviderInfo(string name, IMailboxProvider mailboxProvider) 72 | { 73 | Name = name; 74 | MailboxProvider = mailboxProvider; 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/DefaultMailboxProviderKeeperPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox; 9 | 10 | public class DefaultMailboxProviderKeeperPlugin : IPlugin 11 | { 12 | private readonly IMailboxProviderKeeper _keeper; 13 | private readonly DefaultMailboxProviderKeeperPluginConfiguration _configuration; 14 | 15 | public DefaultMailboxProviderKeeperPlugin( 16 | IMailboxProviderKeeper keeper, 17 | DefaultMailboxProviderKeeperPluginConfiguration configuration) 18 | { 19 | _keeper = keeper; 20 | _configuration = configuration; 21 | } 22 | 23 | private DefaultMailboxProviderKeeperPlugin(IPluginConfiguration configuration, DefaultMailboxProviderKeeperPlugin plugin) 24 | { 25 | _keeper = plugin._keeper; 26 | _configuration = (DefaultMailboxProviderKeeperPluginConfiguration)configuration; 27 | } 28 | 29 | public string Name => _configuration.Name; 30 | 31 | public int Pass => 0; 32 | 33 | public IPluginConfiguration Configuration => _configuration; 34 | 35 | public void Close() 36 | { 37 | } 38 | 39 | public void Start(IRegistrar registrar) => registrar.RegisterMailboxProviderKeeper(_keeper); 40 | 41 | public IPlugin With(IPluginConfiguration? overrideConfiguration) 42 | => overrideConfiguration == null ? this : new DefaultMailboxProviderKeeperPlugin(overrideConfiguration, this); 43 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/DefaultMailboxProviderKeeperPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox; 9 | 10 | public class DefaultMailboxProviderKeeperPluginConfiguration : IPluginConfiguration 11 | { 12 | public string Name => "defaultMailboxProviderKeeper"; 13 | 14 | public void Build(Configuration configuration) 15 | { 16 | } 17 | 18 | public void BuildWith(Configuration configuration, PluginProperties properties) 19 | { 20 | } 21 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/TestKit/TestMailboxPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.TestKit; 9 | 10 | public sealed class TestMailboxPlugin : AbstractPlugin, IMailboxProvider 11 | { 12 | public TestMailboxPlugin(IRegistrar registrar) => Start(registrar); 13 | 14 | public override string Name => TestMailbox.Name; 15 | 16 | public override int Pass => 1; 17 | 18 | public override IPluginConfiguration Configuration => null!; 19 | 20 | public override void Close() 21 | { 22 | } 23 | 24 | public IMailbox ProvideMailboxFor(int? hashCode) => new TestMailbox(); 25 | 26 | public IMailbox ProvideMailboxFor(int? hashCode, IDispatcher dispatcher) => new TestMailbox(); 27 | 28 | public override void Start(IRegistrar registrar) => registrar.Register(Name, false, this); 29 | 30 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) => null!; 31 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Mailbox/TestKit/TestRuntimeDiscoverer.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Mailbox.TestKit; 11 | 12 | /// 13 | /// Discover whether the runtime is currently under test. 14 | /// 15 | public class TestRuntimeDiscoverer 16 | { 17 | private static bool _runningFromXunit; 18 | 19 | public static bool IsTestDetectionDeactivated { get; set; } 20 | 21 | public static bool IsUnderTest() 22 | { 23 | if (IsTestDetectionDeactivated) 24 | { 25 | return false; 26 | } 27 | 28 | foreach (var assem in AppDomain.CurrentDomain.GetAssemblies()) 29 | { 30 | // Can't do something like this as it will load the xunit assembly 31 | // if (assem == typeof(Xunit.Assert)) 32 | 33 | if (assem.FullName!.ToLowerInvariant().StartsWith("xunit")) 34 | { 35 | _runningFromXunit = true; 36 | break; 37 | } 38 | } 39 | 40 | return _runningFromXunit; 41 | } 42 | 43 | public static bool IsUnderTestWith(string className, string methodName) => 44 | throw new NotSupportedException("Currently not implemented"); 45 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/PluginProperties.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Globalization; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin; 11 | 12 | public class PluginProperties 13 | { 14 | private readonly Properties _properties; 15 | 16 | public PluginProperties(string name, Properties properties) 17 | { 18 | Name = name; 19 | _properties = properties; 20 | } 21 | 22 | public string Name { get; } 23 | 24 | public bool GetBoolean(string key, bool defaultValue) 25 | { 26 | var value = GetString(key, defaultValue.ToString()); 27 | return value == null ? defaultValue : bool.Parse(value); 28 | } 29 | 30 | public float GetFloat(string key, float defaultValue) 31 | { 32 | var value = GetString(key, defaultValue.ToString(CultureInfo.InvariantCulture)); 33 | return value == null ? defaultValue : float.Parse(value, CultureInfo.InvariantCulture); 34 | } 35 | 36 | public int GetInteger(string key, int defaultValue) 37 | { 38 | var value = GetString(key, defaultValue.ToString()); 39 | return value == null ? defaultValue : int.Parse(value); 40 | } 41 | 42 | public long GetLong(string key, long defaultValue) 43 | { 44 | var value = GetString(key, defaultValue.ToString()); 45 | return value == null ? defaultValue : long.Parse(value); 46 | } 47 | 48 | public string? GetString(string key, string? defaultValue) => _properties.GetProperty(Key(key), defaultValue); 49 | 50 | private string Key(string key) => $"plugin.{Name}.{key}"; 51 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/StaticPluginTypeLoader.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.IO; 10 | using System.Reflection; 11 | 12 | namespace Vlingo.Xoom.Actors.Plugin; 13 | 14 | public class StaticPluginTypeLoader : IPluginTypeLoader 15 | { 16 | public Type? LoadType(string name) => Type.GetType(name); 17 | 18 | public Stream? LoadResource(string resourceName) 19 | { 20 | var assembly = Assembly.GetExecutingAssembly(); 21 | var path = $"{resourceName.Replace("/", ".").Replace(" ", "_")}"; 22 | var stream = assembly.GetManifestResourceStream(path); 23 | return stream; 24 | } 25 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Supervision/CommonSupervisorsPlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Supervision; 9 | 10 | public class CommonSupervisorsPlugin : AbstractPlugin 11 | { 12 | private readonly CommonSupervisorsPluginConfiguration _configuration; 13 | 14 | public CommonSupervisorsPlugin(string? name = null) => _configuration = CommonSupervisorsPluginConfiguration.Define(); 15 | 16 | private CommonSupervisorsPlugin(IPluginConfiguration configuration) => _configuration = (CommonSupervisorsPluginConfiguration)configuration; 17 | 18 | public override string Name => "common_supervisors"; 19 | 20 | public override int Pass => 2; 21 | 22 | public override IPluginConfiguration Configuration => _configuration; 23 | 24 | public override void Close() 25 | { 26 | } 27 | 28 | public override void Start(IRegistrar registrar) 29 | { 30 | foreach(var supervisor in _configuration.Supervisors) 31 | { 32 | registrar.RegisterCommonSupervisor( 33 | supervisor.StageName, 34 | supervisor.SupervisorName, 35 | supervisor.SupervisedProtocol, 36 | supervisor.SupervisorClass); 37 | } 38 | } 39 | 40 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 41 | => overrideConfiguration == null ? this : new CommonSupervisorsPlugin(overrideConfiguration); 42 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Supervision/CommonSupervisorsPluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace Vlingo.Xoom.Actors.Plugin.Supervision; 12 | 13 | public class CommonSupervisorsPluginConfiguration : IPluginConfiguration 14 | { 15 | private CommonSupervisorsPluginConfiguration() 16 | { 17 | Supervisors = new List(); 18 | } 19 | 20 | public static CommonSupervisorsPluginConfiguration Define() => new CommonSupervisorsPluginConfiguration(); 21 | 22 | public CommonSupervisorsPluginConfiguration WithSupervisor( 23 | string stageName, 24 | string supervisorName, 25 | Type supervisedProtocol, 26 | Type supervisorClass) 27 | { 28 | Supervisors.Add(new ConfiguredSupervisor(stageName, supervisorName, supervisedProtocol, supervisorClass)); 29 | return this; 30 | } 31 | 32 | public int Count => Supervisors.Count; 33 | 34 | public string SupervisorName(int index) => Supervisors[index].SupervisorName; 35 | 36 | public string StageName(int index) => Supervisors[index].StageName; 37 | 38 | public Type? SupervisedProtocol(int index) => Supervisors[index].SupervisedProtocol; 39 | 40 | public Type? SupervisorClass(int index) => Supervisors[index].SupervisorClass; 41 | 42 | public string Name => SupervisorName(0); 43 | 44 | internal IList Supervisors { get; } 45 | 46 | public void Build(Configuration configuration) 47 | { 48 | } 49 | 50 | public void BuildWith(Configuration configuration, PluginProperties properties) 51 | { 52 | foreach (var values in DefinitionValues.AllDefinitionValues(properties)) 53 | { 54 | var supervisor = new ConfiguredSupervisor( 55 | values.StageName, 56 | values.Name, 57 | values.Protocol, 58 | values.Supervisor); 59 | 60 | if (Supervisors.Contains(supervisor)) 61 | { 62 | Supervisors.Remove(supervisor); 63 | } 64 | Supervisors.Add(supervisor); 65 | } 66 | configuration.With(this); 67 | } 68 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Supervision/DefaultSupervisorOverride.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors.Plugin.Supervision; 11 | 12 | public sealed class DefaultSupervisorOverride : Actor, ISupervisor 13 | { 14 | public ISupervisionStrategy SupervisionStrategy { get; } = new DefaultSupervisorOvverideSupervisionStrategy(); 15 | 16 | public ISupervisor Supervisor { get; private set; } 17 | 18 | public DefaultSupervisorOverride() 19 | { 20 | Supervisor = ParentAs(); 21 | } 22 | 23 | public void Inform(Exception error, ISupervised supervised) 24 | { 25 | Logger.Error($"DefaultSupervisorOverride: Failure of: {supervised.Address} because: {error.Message} Action: Resuming.", error); 26 | supervised.Resume(); 27 | } 28 | 29 | private class DefaultSupervisorOvverideSupervisionStrategy : ISupervisionStrategy 30 | { 31 | public int Intensity => SupervisionStrategyConstants.ForeverIntensity; 32 | 33 | public long Period => SupervisionStrategyConstants.ForeverPeriod; 34 | 35 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 36 | } 37 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Supervision/DefaultSupervisorOverridePlugin.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.Plugin.Supervision; 9 | 10 | public class DefaultSupervisorOverridePlugin : AbstractPlugin 11 | { 12 | private readonly DefaultSupervisorOverridePluginConfiguration _configuration; 13 | 14 | public DefaultSupervisorOverridePlugin(string? name = null) => _configuration = DefaultSupervisorOverridePluginConfiguration.Define(); 15 | 16 | private DefaultSupervisorOverridePlugin(IPluginConfiguration configuration) => _configuration = (DefaultSupervisorOverridePluginConfiguration)configuration; 17 | 18 | public override string Name => "override_supervisor"; 19 | 20 | public override int Pass => 2; 21 | 22 | public override IPluginConfiguration Configuration => _configuration; 23 | 24 | public override void Close() 25 | { 26 | } 27 | 28 | public override void Start(IRegistrar registrar) 29 | { 30 | foreach(var supervisor in _configuration.Supervisors) 31 | { 32 | registrar.RegisterDefaultSupervisor(supervisor.StageName, supervisor.SupervisorName, supervisor.SupervisorClass); 33 | } 34 | } 35 | 36 | public override IPlugin With(IPluginConfiguration? overrideConfiguration) 37 | => overrideConfiguration == null ? this : new DefaultSupervisorOverridePlugin(overrideConfiguration); 38 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Plugin/Supervision/DefaultSupervisorOverridePluginConfiguration.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | 11 | namespace Vlingo.Xoom.Actors.Plugin.Supervision; 12 | 13 | public class DefaultSupervisorOverridePluginConfiguration : IPluginConfiguration 14 | { 15 | private DefaultSupervisorOverridePluginConfiguration() 16 | { 17 | Supervisors = new List(); 18 | } 19 | 20 | public static DefaultSupervisorOverridePluginConfiguration Define() => new DefaultSupervisorOverridePluginConfiguration(); 21 | 22 | public DefaultSupervisorOverridePluginConfiguration WithSupervisor( 23 | string stageName, 24 | string supervisorName, 25 | Type? supervisorClass) 26 | { 27 | Supervisors.Add(new ConfiguredSupervisor(stageName, supervisorName, supervisorClass)); 28 | return this; 29 | } 30 | 31 | public int Count => Supervisors.Count; 32 | 33 | public string SupervisorName(int index) => Supervisors[index].SupervisorName; 34 | 35 | public string StageName(int index) => Supervisors[index].StageName; 36 | 37 | public Type? SupervisorClass(int index) => Supervisors[index].SupervisorClass; 38 | 39 | internal IList Supervisors { get; } 40 | 41 | public string Name => SupervisorName(0); 42 | 43 | public void Build(Configuration configuration) 44 | { 45 | configuration.With(WithSupervisor( 46 | "default", 47 | "overrideSupervisor", 48 | ConfiguredSupervisor.SupervisorFrom("Vlingo.Xoom.Actors.Plugin.Supervision.DefaultSupervisorOverride"))); 49 | } 50 | 51 | public void BuildWith(Configuration configuration, PluginProperties properties) 52 | { 53 | foreach (var values in DefinitionValues.AllDefinitionValues(properties)) 54 | { 55 | var supervisor = new ConfiguredSupervisor( 56 | values.StageName, 57 | values.Name, 58 | values.Supervisor); 59 | 60 | Supervisors.Add(supervisor); 61 | } 62 | configuration.With(this); 63 | } 64 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PooledCompletes.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Common; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class PooledCompletes : ICompletesEventually 13 | { 14 | public long Id { get; } 15 | 16 | public ICompletes? ClientCompletes { get; } 17 | 18 | public ICompletesEventually CompletesEventually { get; } 19 | 20 | public PooledCompletes( 21 | long id, 22 | ICompletes? clientCompletes, 23 | ICompletesEventually completesEventually) 24 | { 25 | Id = id; 26 | ClientCompletes = clientCompletes; 27 | CompletesEventually = completesEventually; 28 | } 29 | 30 | public virtual object? Outcome { get; private set; } 31 | 32 | public virtual void With(object? outcome) 33 | { 34 | Outcome = outcome; 35 | CompletesEventually.With(this); 36 | } 37 | 38 | public virtual bool IsStopped => CompletesEventually.IsStopped; 39 | 40 | public virtual IAddress Address => CompletesEventually.Address; 41 | 42 | public virtual void Stop() 43 | { 44 | } 45 | 46 | public override int GetHashCode() => 31 * Address.GetHashCode(); 47 | 48 | public override bool Equals(object? other) 49 | { 50 | if (other == null || other.GetType() != GetType()) 51 | { 52 | return false; 53 | } 54 | 55 | return Address.Equals(((PooledCompletes)other).Address); 56 | } 57 | 58 | public override string ToString() => $"PooledCompletes[Id={Id} Address={Address} Outcome={Outcome} IsStopped={IsStopped}]"; 59 | 60 | public void Conclude() 61 | { 62 | } 63 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PrivateRootActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public sealed class PrivateRootActor : Actor, ISupervisor 13 | { 14 | public ISupervisionStrategy SupervisionStrategy { get; } 15 | 16 | public ISupervisor Supervisor { get; } = new DefaultSupervisorImpl(); 17 | 18 | public PrivateRootActor() 19 | { 20 | SupervisionStrategy = new PrivateRootActorSupervisionStrategy(); 21 | } 22 | 23 | protected internal override void BeforeStart() 24 | { 25 | base.BeforeStart(); 26 | 27 | Stage.World.SetPrivateRoot(SelfAs()); 28 | 29 | Stage.ActorProtocolFor( 30 | Definition.Has(Definition.NoParameters, World.PublicRootName), 31 | this, 32 | Stage.World.AddressFactory.From(World.PublicRootId, World.PublicRootName), 33 | null, 34 | null, 35 | Logger); 36 | 37 | Stage.ActorProtocolFor( 38 | Definition.Has(Definition.NoParameters, World.DeadLettersName), 39 | this, 40 | Stage.World.AddressFactory.From(World.DeadLettersId, World.DeadLettersName), 41 | null, 42 | null, 43 | Logger); 44 | } 45 | 46 | protected internal override void AfterStop() 47 | { 48 | Stage.World.SetPrivateRoot(null); 49 | base.AfterStop(); 50 | } 51 | 52 | public void Inform(Exception error, ISupervised supervised) 53 | { 54 | Logger.Error($"PrivateRootActor: Failure of: {supervised.Address} because: {error.Message} Action: Stopping.", error); 55 | supervised.Stop(SupervisionStrategy.Scope); 56 | } 57 | 58 | private class PrivateRootActorSupervisionStrategy : ISupervisionStrategy 59 | { 60 | public int Intensity => 0; 61 | 62 | public long Period => 0; 63 | 64 | public SupervisionStrategyConstants.Scope Scope => SupervisionStrategyConstants.Scope.One; 65 | } 66 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Properties.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.IO; 10 | using Vlingo.Xoom.Common; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | public sealed class Properties: ConfigurationProperties 15 | { 16 | private static Func Factory = () => 17 | { 18 | var props = new Properties(); 19 | props.Load(new FileInfo("vlingo-actors.json")); 20 | return props; 21 | }; 22 | 23 | private static Lazy SingleInstance => new Lazy(Factory, true); 24 | 25 | public static Properties Instance => SingleInstance.Value; 26 | 27 | public static long GetLong(string key, long defaultValue) => Get(key, long.Parse!, defaultValue); 28 | 29 | public static float GetFloat(string key, float defaultValue) => Get(key, float.Parse!, defaultValue); 30 | 31 | private static T Get(string key, Func parse, T defaultValue) 32 | { 33 | var property = Instance.GetProperty(key); 34 | if (!string.IsNullOrEmpty(key)) 35 | { 36 | try 37 | { 38 | return parse(property); 39 | } 40 | catch 41 | { 42 | return defaultValue; 43 | } 44 | } 45 | 46 | return defaultValue; 47 | } 48 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Protocols.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public class Protocols 11 | { 12 | private readonly object[] _protocolActors; 13 | 14 | public T Get(int index) => (T)_protocolActors[index]; 15 | 16 | internal Protocols(object[] protocolActors) => _protocolActors = protocolActors; 17 | 18 | public static Two Two(Protocols protocols) => new Two(protocols); 19 | 20 | public static Three Three(Protocols protocols) => new Three(protocols); 21 | 22 | public static Four Four(Protocols protocols) => new Four(protocols); 23 | 24 | public static Five Five(Protocols protocols) => new Five(protocols); 25 | } 26 | public class Two 27 | { 28 | public A _1; 29 | public B _2; 30 | 31 | public Two(Protocols protocols) 32 | { 33 | _1 = protocols.Get(0); 34 | _2 = protocols.Get(1); 35 | } 36 | } 37 | 38 | public class Three 39 | { 40 | public A _1; 41 | public B _2; 42 | public C _3; 43 | 44 | public Three(Protocols protocols) 45 | { 46 | _1 = protocols.Get(0); 47 | _2 = protocols.Get(1); 48 | _3 = protocols.Get(2); 49 | } 50 | } 51 | 52 | public class Four 53 | { 54 | public A _1; 55 | public B _2; 56 | public C _3; 57 | public D _4; 58 | 59 | public Four(Protocols protocols) 60 | { 61 | _1 = protocols.Get(0); 62 | _2 = protocols.Get(1); 63 | _3 = protocols.Get(2); 64 | _4 = protocols.Get(3); 65 | } 66 | } 67 | 68 | public class Five 69 | { 70 | public A _1; 71 | public B _2; 72 | public C _3; 73 | public D _4; 74 | public E _5; 75 | 76 | public Five(Protocols protocols) 77 | { 78 | _1 = protocols.Get(0); 79 | _2 = protocols.Get(1); 80 | _3 = protocols.Get(2); 81 | _4 = protocols.Get(3); 82 | _5 = protocols.Get(4); 83 | } 84 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/AffectedSubscriptions.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace Vlingo.Xoom.Actors.PubSub; 11 | 12 | public class AffectedSubscriptions 13 | { 14 | private readonly IDictionary _registry; 15 | 16 | public AffectedSubscriptions() => _registry = new Dictionary(); 17 | 18 | public virtual void Add(Topic topic, ISubscriber subscriber) => _registry[topic] = subscriber; 19 | 20 | public virtual bool HasAny => _registry.Count > 0; 21 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/Condition.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace Vlingo.Xoom.Actors.PubSub; 11 | 12 | internal delegate bool Condition(KeyValuePair> subscription, Topic? topic, ISubscriber subscriber); 13 | 14 | internal static class ConditionExtension 15 | { 16 | public static bool Should( 17 | this Condition condition, 18 | KeyValuePair> subscription, 19 | Topic? topic, 20 | ISubscriber subscriber) 21 | => condition.Invoke(subscription, topic, subscriber); 22 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/DefaultPublisher.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.PubSub; 9 | 10 | public class DefaultPublisher : IPublisher 11 | { 12 | private readonly Subscriptions _subscriptions; 13 | 14 | public DefaultPublisher() => _subscriptions = new Subscriptions(); 15 | 16 | public virtual void Publish(Topic topic, IMessage message) 17 | { 18 | foreach(var subscriber in _subscriptions.ForTopic(topic)) 19 | { 20 | subscriber.Receive(message); 21 | } 22 | } 23 | 24 | public virtual bool Subscribe(Topic topic, ISubscriber subscriber) 25 | { 26 | var affectedSubscriptions = _subscriptions.Create(topic, subscriber); 27 | return affectedSubscriptions.HasAny; 28 | } 29 | 30 | public virtual bool Unsubscribe(Topic topic, ISubscriber subscriber) 31 | { 32 | var affectedSubscriptions = _subscriptions.Cancel(topic, subscriber); 33 | return affectedSubscriptions.HasAny; 34 | } 35 | 36 | public virtual void UnsubscribeAllTopics(ISubscriber subscriber) 37 | => _subscriptions.CancelAll(subscriber); 38 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/IMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.PubSub; 9 | 10 | public interface IMessage 11 | { 12 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/IPublisher.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.PubSub; 9 | 10 | public interface IPublisher 11 | { 12 | void Publish(Topic topic, IMessage message); 13 | bool Subscribe(Topic topic, ISubscriber subscriber); 14 | bool Unsubscribe(Topic topic, ISubscriber subscriber); 15 | void UnsubscribeAllTopics(ISubscriber subscriber); 16 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/ISubscriber.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.PubSub; 9 | 10 | public interface ISubscriber 11 | { 12 | void Receive(IMessage message); 13 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/Operation.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace Vlingo.Xoom.Actors.PubSub; 11 | 12 | internal delegate bool Operation(ISet existingSubscriber, ISubscriber givenSubscriber); 13 | 14 | internal static class OperationExtension 15 | { 16 | public static bool Perform( 17 | this Operation operation, 18 | ISet existingSubscriber, 19 | ISubscriber givenSubscriber) 20 | => operation.Invoke(existingSubscriber, givenSubscriber); 21 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PubSub/Topic.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.PubSub; 9 | 10 | public abstract class Topic 11 | { 12 | public Topic(string name) 13 | { 14 | Name = name; 15 | } 16 | 17 | public virtual string Name { get; } 18 | 19 | public abstract bool IsSubTopic(Topic anotherTopic); 20 | 21 | public override bool Equals(object? obj) 22 | { 23 | if(obj == null || obj.GetType() != GetType()) 24 | { 25 | return false; 26 | } 27 | 28 | var otherTopic = (Topic)obj; 29 | 30 | return string.Equals(Name, otherTopic.Name); 31 | } 32 | 33 | public override int GetHashCode() 34 | => $"Topic[{GetType().FullName}]-{Name}".GetHashCode(); 35 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/PublicRootActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using static Vlingo.Xoom.Actors.SupervisionStrategyConstants; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public sealed class PublicRootActor : Actor, ISupervisor 14 | { 15 | public PublicRootActor() 16 | { 17 | SupervisionStrategy = new PublicRootActorSupervisionStrategy(); 18 | Supervisor = SelfAs(); 19 | } 20 | 21 | public ISupervisionStrategy SupervisionStrategy { get; } 22 | 23 | public ISupervisor Supervisor { get; } 24 | 25 | public void Inform(Exception error, ISupervised supervised) 26 | { 27 | Logger.Error($"PublicRootActor: Failure of: {supervised.Address} because: {error.Message} Action: Restarting.", error); 28 | supervised.RestartWithin(SupervisionStrategy.Period, SupervisionStrategy.Intensity, SupervisionStrategy.Scope); 29 | } 30 | 31 | protected internal override void BeforeStart() 32 | { 33 | base.BeforeStart(); 34 | Stage.World.SetDefaultParent(this); 35 | Stage.World.SetPublicRoot(SelfAs()); 36 | } 37 | 38 | protected internal override void AfterStop() 39 | { 40 | Stage.World.SetDefaultParent(null); 41 | Stage.World.SetPublicRoot(null); 42 | base.AfterStop(); 43 | } 44 | 45 | private class PublicRootActorSupervisionStrategy : ISupervisionStrategy 46 | { 47 | public int Intensity => ForeverIntensity; 48 | 49 | public long Period => ForeverPeriod; 50 | 51 | public Scope Scope => Scope.One; 52 | } 53 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/RandomRouter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | /// 13 | /// RandomRouter 14 | /// 15 | public class RandomRouter

: Router

16 | { 17 | private readonly Random _random; 18 | 19 | public RandomRouter(RouterSpecification

specification, int seed) : this(specification, new Random(seed)) 20 | { 21 | } 22 | 23 | public RandomRouter(RouterSpecification

specification, Random seededRandom) : base(specification) 24 | => _random = seededRandom; 25 | 26 | protected internal override Routing

ComputeRouting() => Routing.With(NextRoutee()); 27 | 28 | protected internal virtual Routee

? NextRoutee() 29 | { 30 | var index = _random.Next(routees.Count); 31 | return RouteeAt(index); 32 | } 33 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/ResumingMailbox.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Linq.Expressions; 10 | using System.Threading.Tasks; 11 | using Vlingo.Xoom.Common; 12 | 13 | namespace Vlingo.Xoom.Actors; 14 | 15 | public class ResumingMailbox : IMailbox 16 | { 17 | private readonly IMessage _message; 18 | 19 | public ResumingMailbox(IMessage message) => _message = message; 20 | 21 | public TaskScheduler TaskScheduler { get; } = null!; 22 | 23 | public bool IsClosed => false; 24 | 25 | public bool IsDelivering => true; 26 | public int ConcurrencyCapacity => 0; 27 | 28 | public bool IsSuspendedFor(string name) => throw new InvalidOperationException("Mailbox implementation does not support this operation."); 29 | 30 | public bool IsSuspended => false; 31 | 32 | public int PendingMessages => 1; 33 | 34 | public bool IsPreallocated => false; 35 | 36 | public void Close() 37 | { 38 | } 39 | 40 | public IMessage? Receive() => null; 41 | 42 | public void Resume(string name) 43 | { 44 | } 45 | 46 | public void Run() => _message.Deliver(); 47 | 48 | public void Send(IMessage message) 49 | { 50 | } 51 | 52 | public void Send(Actor actor, Action consumer, ICompletes? completes, string representation) => 53 | throw new InvalidOperationException("Not a preallocated mailbox."); 54 | 55 | public void Send(Actor actor, Type protocol, LambdaExpression consumer, ICompletes? completes, string representation) => 56 | throw new InvalidOperationException("Not a preallocated mailbox."); 57 | 58 | public void SuspendExceptFor(string name, params Type[] overrides) 59 | { 60 | } 61 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/RoundRobinRouter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public class RoundRobinRouter

: Router

11 | { 12 | private int _poolIndex; 13 | 14 | public RoundRobinRouter(RouterSpecification

specification) : base(specification) => _poolIndex = 0; 15 | 16 | internal int PoolIndex => _poolIndex; 17 | 18 | protected internal override Routing

ComputeRouting() => Routing.With(NextRoutee()); 19 | 20 | protected internal virtual Routee

NextRoutee() 21 | { 22 | var routees = Routees; 23 | _poolIndex = IncrementAndGetPoolIndex() % routees.Count; 24 | return routees[_poolIndex]; 25 | } 26 | 27 | private int IncrementAndGetPoolIndex() 28 | { 29 | _poolIndex = (_poolIndex == int.MaxValue) ? 0 : _poolIndex + 1; 30 | return _poolIndex; 31 | } 32 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/RouterSpecification.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | ///

13 | /// RouterSpecification specifies the definition and protocol of 14 | /// the to which a will route, 15 | /// as well as other details such as pool size. 16 | /// 17 | public class RouterSpecification 18 | { 19 | private readonly int _initialPoolSize; 20 | private readonly Definition _routerDefinition; 21 | private readonly Type _routerProtocol; 22 | 23 | public RouterSpecification(int poolSize, Definition routerDefinition) 24 | { 25 | if (poolSize < 0) 26 | { 27 | throw new ArgumentException("poolSize must be 1 or greater"); 28 | } 29 | 30 | _initialPoolSize = poolSize; 31 | _routerDefinition = routerDefinition; 32 | _routerProtocol = typeof(T); 33 | } 34 | 35 | public virtual int InitialPoolSize => _initialPoolSize; 36 | 37 | public virtual Definition RouterDefinition => _routerDefinition; 38 | 39 | public virtual Type RouterProtocol => _routerProtocol; 40 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Routing.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Collections.Generic; 10 | using System.Linq; 11 | 12 | namespace Vlingo.Xoom.Actors; 13 | 14 | /// 15 | /// See 16 | /// 17 | public static class Routing 18 | { 19 | public static Routing With(Routee? routee) 20 | => new Routing(new List> { 21 | routee ?? throw new ArgumentNullException(nameof(routee), "Routee may not be null") 22 | }); 23 | 24 | public static Routing With(ICollection> routees) 25 | { 26 | if (routees == null || routees.Count == 0) 27 | { 28 | throw new ArgumentNullException(nameof(routees), "routees may not be null or empty"); 29 | } 30 | 31 | return new Routing(routees); 32 | } 33 | } 34 | 35 | /// 36 | /// Routing is an ordered sequence of that 37 | /// was computed by way of some routing strategy and whose elements 38 | /// will be the target of a message forwarded by a . 39 | /// 40 | public class Routing

41 | { 42 | private readonly ArraySegment> _routees; 43 | 44 | internal Routing() : this(null) 45 | { 46 | } 47 | 48 | internal Routing(ICollection>? routees) 49 | { 50 | var routeesCollection = routees ?? new List>(); 51 | _routees = new ArraySegment>(routeesCollection.ToArray()); 52 | } 53 | 54 | public virtual Routee

First => _routees.ElementAt(0); 55 | 56 | public virtual IReadOnlyList> Routees => _routees; 57 | 58 | public virtual bool IsEmpty => _routees.Count == 0; 59 | 60 | public override string ToString() => $"Routing[routees={_routees}]"; 61 | 62 | public virtual void Validate() 63 | { 64 | if (IsEmpty) 65 | { 66 | throw new InvalidOperationException("routees may not be empty"); 67 | } 68 | } 69 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Scheduled__Proxy.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Vlingo.Xoom.Common; 3 | 4 | namespace Vlingo.Xoom.Actors; 5 | 6 | public class Scheduled__Proxy : IScheduled 7 | { 8 | private const string IntervalSignalRepresentation1 = "IntervalSignal(Vlingo.Xoom.Common.IScheduled, T)"; 9 | 10 | private readonly Actor _actor; 11 | private readonly IMailbox _mailbox; 12 | 13 | public Scheduled__Proxy(Actor actor, IMailbox mailbox) 14 | { 15 | _actor = actor; 16 | _mailbox = mailbox; 17 | } 18 | 19 | public void IntervalSignal(IScheduled scheduled, T data) 20 | { 21 | if (!_actor.IsStopped) 22 | { 23 | Action> cons1513252312 = __ => __.IntervalSignal(scheduled, data); 24 | if (_mailbox.IsPreallocated) 25 | { 26 | _mailbox.Send(_actor, cons1513252312, null, IntervalSignalRepresentation1); 27 | } 28 | else 29 | { 30 | _mailbox.Send(new LocalMessage>(_actor, cons1513252312, 31 | IntervalSignalRepresentation1)); 32 | } 33 | } 34 | else 35 | { 36 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, IntervalSignalRepresentation1)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/SmallestMailboxRouter.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | 9 | namespace Vlingo.Xoom.Actors; 10 | 11 | ///

12 | /// SmallestMailboxRouter 13 | /// 14 | public class SmallestMailboxRouter

: Router

15 | { 16 | public SmallestMailboxRouter(RouterSpecification

specification) : base(specification) 17 | { 18 | } 19 | 20 | ///

21 | /// See 22 | /// 23 | protected internal override Routing

ComputeRouting() 24 | { 25 | Routee

? least = null; 26 | var leastCount = int.MaxValue; 27 | 28 | foreach(var routee in Routees) 29 | { 30 | var count = routee.PendingMessages; 31 | if(count == 0) 32 | { 33 | least = routee; 34 | break; 35 | } 36 | 37 | if(count < leastCount) 38 | { 39 | least = routee; 40 | leastCount = count; 41 | } 42 | } 43 | 44 | return Routing.With(least); 45 | } 46 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Startable__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class Startable__Proxy : IStartable 13 | { 14 | private readonly Actor actor; 15 | private readonly IMailbox mailbox; 16 | 17 | public Startable__Proxy(Actor actor, IMailbox mailbox) 18 | { 19 | this.actor = actor; 20 | this.mailbox = mailbox; 21 | } 22 | 23 | public void Start() 24 | { 25 | Action consumer = x => x.Start(); 26 | if (mailbox.IsPreallocated) 27 | { 28 | mailbox.Send(actor, consumer, null, "Start()"); 29 | } 30 | else 31 | { 32 | mailbox.Send(new LocalMessage(actor, consumer, "Start()")); 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Stoppable__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class Stoppable__Proxy : IStoppable 13 | { 14 | private readonly Actor _actor; 15 | private readonly IMailbox _mailbox; 16 | 17 | public Stoppable__Proxy(Actor actor, IMailbox mailbox) 18 | { 19 | _actor = actor; 20 | _mailbox = mailbox; 21 | } 22 | 23 | public bool IsStopped => _actor.IsStopped; 24 | 25 | public void Conclude() 26 | { 27 | if (!_actor.IsStopped) 28 | { 29 | Action consumer = x => x.Conclude(); 30 | if (_mailbox.IsPreallocated) 31 | { 32 | _mailbox.Send(_actor, consumer, null, "Conclude()"); 33 | } 34 | else 35 | { 36 | _mailbox.Send(new LocalMessage(_actor, consumer, "Conclude()")); 37 | } 38 | } 39 | else 40 | { 41 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, "Conclude()")); 42 | } 43 | } 44 | 45 | public void Stop() 46 | { 47 | if (!_actor.IsStopped) 48 | { 49 | Action consumer = x => x.Stop(); 50 | if (_mailbox.IsPreallocated) 51 | { 52 | _mailbox.Send(_actor, consumer, null, "Stop()"); 53 | } 54 | else 55 | { 56 | _mailbox.Send(new LocalMessage(_actor, consumer, "Stop()")); 57 | } 58 | } 59 | else 60 | { 61 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, "Stop()")); 62 | } 63 | } 64 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/StowedLocalMessage.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using Vlingo.Xoom.Common; 10 | 11 | namespace Vlingo.Xoom.Actors; 12 | 13 | public class StowedLocalMessage : LocalMessage 14 | { 15 | public StowedLocalMessage(Actor actor, Action consumer, ICompletes completes, string representation) 16 | : base(actor, consumer, completes, representation) 17 | { 18 | } 19 | 20 | public StowedLocalMessage(LocalMessage message) 21 | : base(message) 22 | { 23 | } 24 | 25 | public override bool IsStowed => true; 26 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/SupervisionStrategyConstants.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public static class SupervisionStrategyConstants 11 | { 12 | public enum Scope { All, One }; 13 | public const int DefaultIntensity = 1; 14 | public const int ForeverIntensity = -1; 15 | public const long DefaultPeriod = 5000; 16 | public const long ForeverPeriod = long.MaxValue; 17 | 18 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Supervisor__Proxy.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | 10 | namespace Vlingo.Xoom.Actors; 11 | 12 | public class Supervisor__Proxy : ISupervisor 13 | { 14 | private const string RepresentationInform1 = "inform(Throwable, Supervised)"; 15 | 16 | private readonly Actor _actor; 17 | private readonly IMailbox _mailbox; 18 | 19 | public Supervisor__Proxy(Actor actor, IMailbox mailbox) 20 | { 21 | _actor = actor; 22 | _mailbox = mailbox; 23 | } 24 | 25 | public ISupervisionStrategy SupervisionStrategy => null!; 26 | 27 | public ISupervisor Supervisor => new DefaultSupervisorImpl(); 28 | 29 | public void Inform(Exception error, ISupervised supervised) 30 | { 31 | if (!_actor.IsStopped) 32 | { 33 | Action consumer = x => x.Inform(error, supervised); 34 | if (_mailbox.IsPreallocated) 35 | { 36 | _mailbox.Send(_actor, consumer, null, RepresentationInform1); 37 | } 38 | else 39 | { 40 | _mailbox.Send(new LocalMessage(_actor, consumer, RepresentationInform1)); 41 | } 42 | } 43 | else 44 | { 45 | _actor.DeadLetters?.FailedDelivery(new DeadLetter(_actor, RepresentationInform1)); 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/TestAddressableActor.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors; 9 | 10 | public class TestAddressableActor : Actor, IAddressable 11 | { 12 | LifeCycle IAddressable.LifeCycle => LifeCycle; 13 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/TestKit/ITestStateView.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | namespace Vlingo.Xoom.Actors.TestKit; 9 | 10 | public interface ITestStateView 11 | { 12 | TestState ViewTestState(); 13 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/TestKit/TestEnvironment.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using Vlingo.Xoom.Actors.Plugin.Mailbox.TestKit; 9 | 10 | namespace Vlingo.Xoom.Actors.TestKit; 11 | 12 | internal class TestEnvironment : Environment 13 | { 14 | public TestEnvironment() : 15 | base( 16 | TestWorld.Instance!.World.Stage, 17 | TestWorld.Instance.World.AddressFactory.UniqueWith("test"), 18 | Definition.Has(Definition.NoParameters), 19 | TestWorld.Instance.World.DefaultParent!, 20 | new TestMailbox(), 21 | TestWorld.Instance.World.DefaultSupervisor, 22 | TestWorld.Instance.World.DefaultLogger) 23 | { 24 | } 25 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/TestKit/TestState.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System.Collections.Generic; 9 | 10 | namespace Vlingo.Xoom.Actors.TestKit; 11 | 12 | public class TestState 13 | { 14 | private readonly IDictionary _state; 15 | 16 | public TestState() => _state = new Dictionary(); 17 | 18 | public TestState PutValue(string name, object value) 19 | { 20 | _state[name] = value; 21 | return this; 22 | } 23 | 24 | public T ValueOf(string name) 25 | { 26 | _state.TryGetValue(name, out object? value); 27 | return (T) value!; 28 | } 29 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/TestKit/TestUntil.cs: -------------------------------------------------------------------------------- 1 | // Copyright © 2012-2023 VLINGO LABS. All rights reserved. 2 | // 3 | // This Source Code Form is subject to the terms of the 4 | // Mozilla Public License, v. 2.0. If a copy of the MPL 5 | // was not distributed with this file, You can obtain 6 | // one at https://mozilla.org/MPL/2.0/. 7 | 8 | using System; 9 | using System.Threading; 10 | 11 | namespace Vlingo.Xoom.Actors.TestKit; 12 | 13 | public class TestUntil : IDisposable 14 | { 15 | private readonly CountdownEvent _countDownEvent; 16 | 17 | public static TestUntil Happenings(int times) => new TestUntil(count: times); 18 | 19 | public void CompleteNow() 20 | { 21 | while (!_countDownEvent.IsSet) 22 | { 23 | Happened(); 24 | } 25 | } 26 | 27 | public void Completes() 28 | { 29 | try 30 | { 31 | _countDownEvent.Wait(); 32 | } 33 | catch (Exception) 34 | { 35 | // Ignore ! 36 | } 37 | } 38 | 39 | public bool CompletesWithin(long timeout) 40 | { 41 | try 42 | { 43 | _countDownEvent.Wait(TimeSpan.FromMilliseconds(timeout)); 44 | return _countDownEvent.CurrentCount == 0; 45 | } 46 | catch (Exception) 47 | { 48 | return false; 49 | } 50 | } 51 | 52 | public TestUntil Happened() 53 | { 54 | if (!_countDownEvent.IsSet) 55 | { 56 | _countDownEvent.Signal(); 57 | } 58 | 59 | return this; 60 | } 61 | 62 | public int Remaining => _countDownEvent.CurrentCount; 63 | 64 | public void ResetHappeningsTo(int times) => _countDownEvent.Reset(times); 65 | 66 | public override string ToString() => $"TestUntil[count={_countDownEvent.CurrentCount}]"; 67 | 68 | public void Dispose() => _countDownEvent.Dispose(); 69 | 70 | private TestUntil(int count) 71 | { 72 | _countDownEvent = new CountdownEvent(initialCount: count); 73 | } 74 | } -------------------------------------------------------------------------------- /src/Vlingo.Xoom.Actors/Vlingo.Xoom.Actors.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net6.0 4 | latest 5 | enable 6 | 7 | 8 | true 9 | $(VlingoVersion) 10 | Vlingo.Xoom.Actors 11 | Vlingo 12 | 13 | Type safe Actor Model toolkit for reactive concurrency and resiliency using C# and other .NET languages. 14 | 15 | false 16 | LICENSE 17 | https://github.com/vlingo-net/xoom-net-actors 18 | vlingo-64x64.png 19 | https://github.com/vlingo-net/xoom-net-actors 20 | Debug;Release;Debug With Project References 21 | 22 | 23 | 24 | <_Parameter1>$(MSBuildProjectName).Tests 25 | 26 | 27 | <_Parameter1>Vlingo.Xoom.Lattice 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | PreserveNewest 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /vlingo-64x64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vlingo-net/xoom-net-actors/3ae2171ba4d05dc9a47d98177ca93c376767ad41/vlingo-64x64.png --------------------------------------------------------------------------------