This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Protos.proto(1,8): error CS1022: Type or namespace definition, or end-of-file expected [C:\Code\tomliversidge\protoactor-dotnet\tests\Proto.Remote.Tests.Messages\Proto.Remote.Tests.Messages.csproj] | |
| Protos.proto(1,1): error CS0116: A namespace cannot directly contain members such as fields or methods [C:\Code\tomliversidge\protoactor-dotnet\tests\Proto.Remote.Tests.Messages\Proto.Remote.Tests.Messages.csproj] | |
| Protos.proto(4,1): error CS0116: A namespace cannot directly contain members such as fields or methods [C:\Code\tomliversidge\protoactor-dotnet\tests\Proto.Remote.Tests.Messages\Proto.Remote.Tests.Messages.csproj] | |
| Protos.proto(4,8): error CS1022: Type or namespace definition, or end-of-file expected [C:\Code\tomliversidge\protoactor-dotnet\tests\Proto.Remote.Tests.Messages\Proto.Remote.Tests.Messages.csproj] | |
| Protos.proto(8,2): error CS1014: A get or set accessor expected [C:\Code\tomliversidge\protoactor-dotnet\tests\Proto.Remote.Tests.Messages\Proto.Remote.Tests.Messages.csproj] | |
| Protos.proto(8,7): error |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <Project Sdk="Microsoft.NET.Sdk"> | |
| <PropertyGroup> | |
| <TargetFramework>netstandard1.5</TargetFramework> | |
| </PropertyGroup> | |
| <ItemGroup> | |
| <PackageReference Include="Google.Protobuf" Version="3.2.0" /> | |
| </ItemGroup> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Fact] | |
| public async void CanWatchRemoteActor() | |
| { | |
| var props = Actor.FromProducer(() => new LocalActor()); | |
| var localActor = Actor.SpawnNamed(props, "local watcher"); | |
| var remoteActorName = Guid.NewGuid().ToString(); | |
| var remoteActor = await Remote.SpawnNamedAsync("127.0.0.1:12000", remoteActorName, "remote", TimeSpan.FromSeconds(5)); | |
| remoteActor.Tell(new Watch { Watcher = localActor }); | |
| await Task.Delay(TimeSpan.FromSeconds(3)); | |
| remoteActor.Stop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var props1 = Actor.FromProducer(() => new DoNothingActor()) | |
| .WithMailbox(() => new TestMailbox()); | |
| var localActor1 = Actor.SpawnNamed(props1, "local"); | |
| var props2 = Actor.FromProducer(() => new LocalActor(localActor1)) | |
| .WithMailbox(() => new TestMailbox()); | |
| var watcher = Actor.SpawnNamed(props2, "watcher"); | |
| localActor1.Stop(); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public async Task PersistEventAsync(object @event) | |
| { | |
| Index++; | |
| await _state.PersistEventAsync(ActorId, Index, @event); | |
| _actor.UpdateState(new PersistedEvent(@event, Index)); | |
| if (_snapshotStrategy.ShouldTakeSnapshot(Index)) | |
| { | |
| await PersistSnapshotAsync(_actor.GetState()); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface ISnapshotStrategy | |
| { | |
| bool ShouldTakeSnapshot(long index); | |
| } | |
| public class EventsCountStrategy : ISnapshotStrategy | |
| { | |
| private readonly int _eventsPerSnapshot; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace Proto.Persistence | |
| { | |
| public interface IProvider : IEventSourcingProvider, ISnapshotProvider { } | |
| public interface IEventSourcingProvider : IModifyEvents, IGetEvents { } | |
| public interface IModifyEvents | |
| { | |
| Task PersistEventAsync(string actorName, long index, object @event); | |
| Task DeleteEventsAsync(string actorName, long inclusiveToIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Linq; | |
| using System.IO; | |
| using System.Text; | |
| using System.Collections; | |
| using System.Collections.Generic; | |
| /** | |
| * Auto-generated code below aims at helping you parse | |
| * the standard input according to the problem statement. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Task ReceiveAsync(IContext context) | |
| { | |
| switch (context.Message) | |
| { | |
| // ... | |
| case Credit msg: | |
| return AdjustBalance(msg.ReplyTo, msg.Amount); | |
| case Debit msg when msg.Amount + _balance >= 0: | |
| return AdjustBalance(msg.ReplyTo, msg.Amount); | |
| // ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private Task AdjustBalance(PID replyTo, decimal amount) | |
| { | |
| if (RefusePermanently()) | |
| { | |
| _processedMessages.Add(replyTo, new Refused()); | |
| replyTo.Tell(new Refused()); | |
| } | |
| if (Busy()) | |
| replyTo.Tell(new ServiceUnavailable()); |