From e8e7b7b813380996986940be8eeef181c0c166bb Mon Sep 17 00:00:00 2001 From: rogeralsing Date: Sun, 12 Feb 2017 11:32:47 +0100 Subject: [PATCH] update dotnet to use same remote scheme as Go --- .gitignore | 512 ++--- .travis.yml | 22 +- .vscode/launch.json | 44 +- .vscode/settings.json | 294 +-- .vscode/tasks.json | 30 +- LICENSE | 402 ++-- ProtoActor.sln | 818 ++++---- README.md | 8 +- appveyor.yml | 54 +- examples/Chat/Client/Client.csproj | 28 +- examples/Chat/Client/Program.cs | 126 +- examples/Chat/Messages/Chat.Messages.csproj | 34 +- examples/Chat/Messages/Chat.g.cs | 1746 ++++++++--------- examples/Chat/Messages/Chat.proto | 64 +- examples/Chat/Server/Program.cs | 96 +- examples/Chat/Server/Server.csproj | 28 +- examples/Futures/Futures.csproj | 18 +- examples/Futures/Program.cs | 52 +- examples/HelloWorld/HelloWorld.csproj | 18 +- examples/HelloWorld/Program.cs | 80 +- .../InprocessBenchmark.csproj | 24 +- examples/InprocessBenchmark/Program.cs | 312 +-- .../runtimeconfig.template.json | 10 +- examples/Labb/App.config | 10 +- examples/Labb/Labb.csproj | 130 +- examples/Labb/Program.cs | 62 +- examples/Labb/Properties/AssemblyInfo.cs | 88 +- .../MailboxBenchmark/MailboxBenchmark.csproj | 18 +- examples/MailboxBenchmark/Program.cs | 110 +- examples/Middleware/Middleware.csproj | 18 +- examples/Middleware/Program.cs | 76 +- examples/Persistence/Messages/Messages.csproj | 30 +- examples/Persistence/Messages/Protos.g.cs | 790 ++++---- examples/Persistence/Messages/Protos.proto | 24 +- .../Persistence/Persistence.csproj | 24 +- examples/Persistence/Persistence/Program.cs | 198 +- examples/ReceiveTimeout/Program.cs | 128 +- examples/ReceiveTimeout/ReceiveTimeout.csproj | 18 +- .../RemoteBenchmark/Messages/Messages.csproj | 38 +- examples/RemoteBenchmark/Messages/Protos.g.cs | 872 ++++---- .../RemoteBenchmark/Messages/Protos.proto | 22 +- examples/RemoteBenchmark/Node1/Node1.csproj | 28 +- examples/RemoteBenchmark/Node1/Program.cs | 160 +- .../Node1/runtimeconfig.template.json | 10 +- examples/RemoteBenchmark/Node2/Node2.csproj | 36 +- examples/RemoteBenchmark/Node2/Program.cs | 94 +- .../Node2/runtimeconfig.template.json | 10 +- examples/Router/Program.cs | 332 ++-- examples/Router/Router.csproj | 20 +- examples/SpawnBenchmark/Program.cs | 180 +- examples/SpawnBenchmark/SpawnBenchmark.csproj | 32 +- .../runtimeconfig.template.json | 10 +- runtimeconfig.template.dev.json | 10 +- .../CouchbaseProvider.cs | 54 +- .../CouchbaseProviderState.cs | 164 +- .../Proto.Persistence.Couchbase/Envelope.cs | 60 +- .../Proto.Persistence.Couchbase.csproj | 24 +- src/Proto.Actor/Actor.cs | 152 +- src/Proto.Actor/Context.cs | 240 +-- src/Proto.Actor/DeadLetter.cs | 72 +- src/Proto.Actor/EventStream.cs | 88 +- src/Proto.Actor/Futures.cs | 64 +- src/Proto.Actor/HashedConcurrentDictionary.cs | 148 +- src/Proto.Actor/LocalContext.cs | 872 ++++---- src/Proto.Actor/Messages.cs | 252 +-- src/Proto.Actor/PID.cs | 126 +- src/Proto.Actor/Process.cs | 94 +- src/Proto.Actor/ProcessRegistry.cs | 156 +- src/Proto.Actor/Props.cs | 224 +-- src/Proto.Actor/Proto.Actor.csproj | 42 +- src/Proto.Actor/Protos.g.cs | 1552 +++++++-------- src/Proto.Actor/Protos.proto | 54 +- src/Proto.Actor/RestartStatistics.cs | 96 +- src/Proto.Actor/Supervision.cs | 226 +-- src/Proto.Actor/build.bat | 2 +- src/Proto.Mailbox/BoundedMailboxQueue.cs | 62 +- src/Proto.Mailbox/Dispatcher.cs | 88 +- src/Proto.Mailbox/MPMCQueue.cs | 288 +-- src/Proto.Mailbox/Mailbox.cs | 334 ++-- src/Proto.Mailbox/Messages.cs | 50 +- src/Proto.Mailbox/Proto.Mailbox.csproj | 20 +- src/Proto.Mailbox/Queue.cs | 28 +- src/Proto.Mailbox/UnboundedMailboxQueue.cs | 54 +- src/Proto.Persistence/IPersistentActor.cs | 24 +- src/Proto.Persistence/IProvider.cs | 24 +- src/Proto.Persistence/IProviderState.cs | 40 +- src/Proto.Persistence/InMemoryProvider.cs | 30 +- .../InMemoryProviderState.cs | 126 +- src/Proto.Persistence/Persistence.cs | 168 +- .../Proto.Persistence.csproj | 16 +- src/Proto.Persistence/Replay.cs | 22 +- src/Proto.Remote/EndpointManager.cs | 210 +- src/Proto.Remote/EndpointReader.cs | 93 +- src/Proto.Remote/EndpointWatcher.cs | 172 +- src/Proto.Remote/EndpointWriter.cs | 247 ++- src/Proto.Remote/EndpointWriterMailbox.cs | 208 +- src/Proto.Remote/Messages.cs | 96 +- src/Proto.Remote/Proto.Remote.csproj | 34 +- src/Proto.Remote/Protos.g.cs | 356 ++-- src/Proto.Remote/Protos.proto | 66 +- src/Proto.Remote/RemoteProcess.cs | 153 +- src/Proto.Remote/RemotingSystem.cs | 70 +- src/Proto.Remote/Serialization.cs | 86 +- src/Proto.Remote/build.bat | 2 +- src/Proto.Router/HashRing.cs | 96 +- src/Proto.Router/IHashable.cs | 24 +- src/Proto.Router/Messages/Routees.cs | 38 +- src/Proto.Router/Messages/RouterAddRoutee.cs | 24 +- .../Messages/RouterBroadcastMessage.cs | 24 +- src/Proto.Router/Messages/RouterGetRoutees.cs | 22 +- .../Messages/RouterManagementMessage.cs | 22 +- .../Messages/RouterRemoveRoutee.cs | 24 +- src/Proto.Router/Proto.Router.csproj | 22 +- src/Proto.Router/Router.cs | 142 +- src/Proto.Router/RouterActor.cs | 154 +- src/Proto.Router/RouterProcess.cs | 80 +- .../Routers/BroadcastGroupRouterConfig.cs | 44 +- .../Routers/BroadcastPoolRouterConfig.cs | 40 +- .../Routers/BroadcastRouterState.cs | 64 +- .../ConsistentHashGroupRouterConfig.cs | 44 +- .../Routers/ConsistentHashPoolRouterConfig.cs | 40 +- .../Routers/ConsistentHashRouterState.cs | 90 +- src/Proto.Router/Routers/GroupRouterConfig.cs | 50 +- .../Routers/IGroupRouterConfig.cs | 22 +- src/Proto.Router/Routers/IPoolRouterConfig.cs | 22 +- src/Proto.Router/Routers/IRouterConfig.cs | 28 +- src/Proto.Router/Routers/PoolRouterConfig.cs | 56 +- .../Routers/RandomGroupRouterConfig.cs | 44 +- .../Routers/RandomPoolRouterConfig.cs | 40 +- src/Proto.Router/Routers/RandomRouterState.cs | 72 +- .../Routers/RoundRobinGroupRouterConfig.cs | 44 +- .../Routers/RoundRobinPoolRouterConfig.cs | 40 +- .../Routers/RoundRobinRouterState.cs | 74 +- src/Proto.Router/Routers/RouterState.cs | 32 +- tests/Proto.Actor.Tests/ActorFixture.cs | 78 +- tests/Proto.Actor.Tests/MiddlewareTests.cs | 108 +- .../Proto.Actor.Tests.csproj | 40 +- tests/Proto.Actor.Tests/SpawnTests.cs | 50 +- 138 files changed, 9105 insertions(+), 9016 deletions(-) diff --git a/.gitignore b/.gitignore index f9c48bc09f..66da34d77b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,257 +1,257 @@ -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.userosscache -*.sln.docstates - -# User-specific files (MonoDevelop/Xamarin Studio) -*.userprefs - -# Build results -[Dd]ebug/ -[Dd]ebugPublic/ -[Rr]elease/ -[Rr]eleases/ -x64/ -x86/ -bld/ -[Bb]in/ -[Oo]bj/ -[Ll]og/ - -# Visual Studio 2015 cache/options directory -.vs/ -# Uncomment if you have tasks that create the project's static files in wwwroot -#wwwroot/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -# NUNIT -*.VisualState.xml -TestResult.xml - -# Build Results of an ATL Project -[Dd]ebugPS/ -[Rr]eleasePS/ -dlldata.c - -# DNX -project.lock.json -artifacts/ - -*_i.c -*_p.c -*_i.h -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.svclog -*.scc - -# Chutzpah Test files -_Chutzpah* - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opendb -*.opensdf -*.sdf -*.cachefile -*.VC.db -*.VC.VC.opendb - -# Visual Studio profiler -*.psess -*.vsp -*.vspx -*.sap - -# TFS 2012 Local Workspace -$tf/ - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper -*.DotSettings.user - -# JustCode is a .NET coding add-in -.JustCode - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -_NCrunch_* -.*crunch*.local.xml -nCrunchTemp_* - -# MightyMoose -*.mm.* -AutoTest.Net/ - -# Web workbench (sass) -.sass-cache/ - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.[Pp]ublish.xml -*.azurePubxml -# TODO: Comment the next line if you want to checkin your web deploy settings -# but database connection strings (with potential passwords) will be unencrypted -*.pubxml -*.publishproj - -# Microsoft Azure Web App publish settings. Comment the next line if you want to -# checkin your Azure Web App publish settings, but sensitive information contained -# in these scripts will be unencrypted -PublishScripts/ - -# NuGet Packages -*.nupkg -# The packages folder can be ignored because of Package Restore -**/packages/* -# except build/, which is used as an MSBuild target. -!**/packages/build/ -# Uncomment if necessary however generally it will be regenerated when needed -#!**/packages/repositories.config -# NuGet v3's project.json files produces more ignoreable files -*.nuget.props -*.nuget.targets - -# Microsoft Azure Build Output -csx/ -*.build.csdef - -# Microsoft Azure Emulator -ecf/ -rcf/ - -# Windows Store app package directories and files -AppPackages/ -BundleArtifacts/ -Package.StoreAssociation.xml -_pkginfo.txt - -# Visual Studio cache files -# files ending in .cache can be ignored -*.[Cc]ache -# but keep track of directories ending in .cache -!*.[Cc]ache/ - -# Others -ClientBin/ -~$* -*~ -*.dbmdl -*.dbproj.schemaview -*.pfx -*.publishsettings -node_modules/ -orleans.codegen.cs - -# Since there are multiple workflows, uncomment next line to ignore bower_components -# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) -#bower_components/ - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file -# to a newer Visual Studio version. Backup files are not needed, -# because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -*.mdf -*.ldf - -# Business Intelligence projects -*.rdl.data -*.bim.layout -*.bim_*.settings - -# Microsoft Fakes -FakesAssemblies/ - -# GhostDoc plugin setting file -*.GhostDoc.xml - -# Node.js Tools for Visual Studio -.ntvs_analysis.dat - -# Visual Studio 6 build log -*.plg - -# Visual Studio 6 workspace options file -*.opt - -# Visual Studio LightSwitch build output -**/*.HTMLClient/GeneratedArtifacts -**/*.DesktopClient/GeneratedArtifacts -**/*.DesktopClient/ModelManifest.xml -**/*.Server/GeneratedArtifacts -**/*.Server/ModelManifest.xml -_Pvt_Extensions - -# Paket dependency manager -.paket/paket.exe -paket-files/ - -# FAKE - F# Make -.fake/ - -# JetBrains Rider -.idea/ -*.sln.iml - -# merge leftovers -*.orig - +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# merge leftovers +*.orig + tools/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index ed428e8ee8..3b84b5fad7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,12 @@ -dist: trusty -language: csharp -solution: ProtoActor.sln -matrix: - include: - - dotnet: 1.0.0-preview4-004233 - mono: none - env: DOTNETCORE=1 -script: - - dotnet restore - - dotnet build +dist: trusty +language: csharp +solution: ProtoActor.sln +matrix: + include: + - dotnet: 1.0.0-preview4-004233 + mono: none + env: DOTNETCORE=1 +script: + - dotnet restore + - dotnet build - dotnet test ./tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index c6fe1fd050..41d588f12f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,23 +1,23 @@ -{ - "version": "0.2.0", - "configurations": [ - { - "name": ".NET Core Launch (console)", - "type": "coreclr", - "request": "launch", - "preLaunchTask": "build", - "program": "${workspaceRoot}\\examples\\InprocessBenchmark\\bin\\Debug\\netcoreapp1.0\\InprocessBenchmark.dll", - "args": [], - "cwd": "${workspaceRoot}", - "externalConsole": false, - "stopAtEntry": false, - "internalConsoleOptions": "openOnSessionStart" - }, - { - "name": ".NET Core Attach", - "type": "coreclr", - "request": "attach", - "processId": "${command.pickProcess}" - } - ] +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceRoot}\\examples\\InprocessBenchmark\\bin\\Debug\\netcoreapp1.0\\InprocessBenchmark.dll", + "args": [], + "cwd": "${workspaceRoot}", + "externalConsole": false, + "stopAtEntry": false, + "internalConsoleOptions": "openOnSessionStart" + }, + { + "name": ".NET Core Attach", + "type": "coreclr", + "request": "attach", + "processId": "${command.pickProcess}" + } + ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 5a6dc07cc7..6b5c2a909f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,148 +1,148 @@ -{ - "files.exclude": { - "*.suo": "explorerExcludedFiles", - "*.user": "explorerExcludedFiles", - "*.userosscache": "explorerExcludedFiles", - "*.sln.docstates": "explorerExcludedFiles", - "*.userprefs": "explorerExcludedFiles", - "[Dd]ebug/": "explorerExcludedFiles", - "[Dd]ebugPublic/": "explorerExcludedFiles", - "[Rr]elease/": "explorerExcludedFiles", - "[Rr]eleases/": "explorerExcludedFiles", - "x64/": "explorerExcludedFiles", - "x86/": "explorerExcludedFiles", - "bld/": "explorerExcludedFiles", - "[Bb]in/": "explorerExcludedFiles", - "[Oo]bj/": "explorerExcludedFiles", - "[Ll]og/": "explorerExcludedFiles", - ".vs/": "explorerExcludedFiles", - "[Tt]est[Rr]esult*/": "explorerExcludedFiles", - "[Bb]uild[Ll]og.*": "explorerExcludedFiles", - "*.VisualState.xml": "explorerExcludedFiles", - "TestResult.xml": "explorerExcludedFiles", - "[Dd]ebugPS/": "explorerExcludedFiles", - "[Rr]eleasePS/": "explorerExcludedFiles", - "dlldata.c": "explorerExcludedFiles", - "project.lock.json": "explorerExcludedFiles", - "artifacts/": "explorerExcludedFiles", - "*_i.c": "explorerExcludedFiles", - "*_p.c": "explorerExcludedFiles", - "*_i.h": "explorerExcludedFiles", - "*.ilk": "explorerExcludedFiles", - "*.meta": "explorerExcludedFiles", - "*.obj": "explorerExcludedFiles", - "*.pch": "explorerExcludedFiles", - "*.pdb": "explorerExcludedFiles", - "*.pgc": "explorerExcludedFiles", - "*.pgd": "explorerExcludedFiles", - "*.rsp": "explorerExcludedFiles", - "*.sbr": "explorerExcludedFiles", - "*.tlb": "explorerExcludedFiles", - "*.tli": "explorerExcludedFiles", - "*.tlh": "explorerExcludedFiles", - "*.tmp": "explorerExcludedFiles", - "*.tmp_proj": "explorerExcludedFiles", - "*.log": "explorerExcludedFiles", - "*.vspscc": "explorerExcludedFiles", - "*.vssscc": "explorerExcludedFiles", - ".builds": "explorerExcludedFiles", - "*.pidb": "explorerExcludedFiles", - "*.svclog": "explorerExcludedFiles", - "*.scc": "explorerExcludedFiles", - "_Chutzpah*": "explorerExcludedFiles", - "ipch/": "explorerExcludedFiles", - "*.aps": "explorerExcludedFiles", - "*.ncb": "explorerExcludedFiles", - "*.opendb": "explorerExcludedFiles", - "*.opensdf": "explorerExcludedFiles", - "*.sdf": "explorerExcludedFiles", - "*.cachefile": "explorerExcludedFiles", - "*.VC.db": "explorerExcludedFiles", - "*.VC.VC.opendb": "explorerExcludedFiles", - "*.psess": "explorerExcludedFiles", - "*.vsp": "explorerExcludedFiles", - "*.vspx": "explorerExcludedFiles", - "*.sap": "explorerExcludedFiles", - "$tf/": "explorerExcludedFiles", - "*.gpState": "explorerExcludedFiles", - "_ReSharper*/": "explorerExcludedFiles", - "*.[Rr]e[Ss]harper": "explorerExcludedFiles", - "*.DotSettings.user": "explorerExcludedFiles", - ".JustCode": "explorerExcludedFiles", - "_TeamCity*": "explorerExcludedFiles", - "*.dotCover": "explorerExcludedFiles", - "_NCrunch_*": "explorerExcludedFiles", - ".*crunch*.local.xml": "explorerExcludedFiles", - "nCrunchTemp_*": "explorerExcludedFiles", - "*.mm.*": "explorerExcludedFiles", - "AutoTest.Net/": "explorerExcludedFiles", - ".sass-cache/": "explorerExcludedFiles", - "[Ee]xpress/": "explorerExcludedFiles", - "DocProject/buildhelp/": "explorerExcludedFiles", - "DocProject/Help/*.HxT": "explorerExcludedFiles", - "DocProject/Help/*.HxC": "explorerExcludedFiles", - "DocProject/Help/*.hhc": "explorerExcludedFiles", - "DocProject/Help/*.hhk": "explorerExcludedFiles", - "DocProject/Help/*.hhp": "explorerExcludedFiles", - "DocProject/Help/Html2": "explorerExcludedFiles", - "DocProject/Help/html": "explorerExcludedFiles", - "publish/": "explorerExcludedFiles", - "*.[Pp]ublish.xml": "explorerExcludedFiles", - "*.azurePubxml": "explorerExcludedFiles", - "*.pubxml": "explorerExcludedFiles", - "*.publishproj": "explorerExcludedFiles", - "PublishScripts/": "explorerExcludedFiles", - "*.nupkg": "explorerExcludedFiles", - "**/packages/*": "explorerExcludedFiles", - "!**/packages/build/": "explorerExcludedFiles", - "*.nuget.props": "explorerExcludedFiles", - "*.nuget.targets": "explorerExcludedFiles", - "csx/": "explorerExcludedFiles", - "*.build.csdef": "explorerExcludedFiles", - "ecf/": "explorerExcludedFiles", - "rcf/": "explorerExcludedFiles", - "AppPackages/": "explorerExcludedFiles", - "BundleArtifacts/": "explorerExcludedFiles", - "Package.StoreAssociation.xml": "explorerExcludedFiles", - "_pkginfo.txt": "explorerExcludedFiles", - "*.[Cc]ache": "explorerExcludedFiles", - "!*.[Cc]ache/": "explorerExcludedFiles", - "ClientBin/": "explorerExcludedFiles", - "~$*": "explorerExcludedFiles", - "*~": "explorerExcludedFiles", - "*.dbmdl": "explorerExcludedFiles", - "*.dbproj.schemaview": "explorerExcludedFiles", - "*.pfx": "explorerExcludedFiles", - "*.publishsettings": "explorerExcludedFiles", - "node_modules/": "explorerExcludedFiles", - "orleans.codegen.cs": "explorerExcludedFiles", - "Generated_Code/": "explorerExcludedFiles", - "_UpgradeReport_Files/": "explorerExcludedFiles", - "Backup*/": "explorerExcludedFiles", - "UpgradeLog*.XML": "explorerExcludedFiles", - "UpgradeLog*.htm": "explorerExcludedFiles", - "*.mdf": "explorerExcludedFiles", - "*.ldf": "explorerExcludedFiles", - "*.rdl.data": "explorerExcludedFiles", - "*.bim.layout": "explorerExcludedFiles", - "*.bim_*.settings": "explorerExcludedFiles", - "FakesAssemblies/": "explorerExcludedFiles", - "*.GhostDoc.xml": "explorerExcludedFiles", - ".ntvs_analysis.dat": "explorerExcludedFiles", - "*.plg": "explorerExcludedFiles", - "*.opt": "explorerExcludedFiles", - "**/*.HTMLClient/GeneratedArtifacts": "explorerExcludedFiles", - "**/*.DesktopClient/GeneratedArtifacts": "explorerExcludedFiles", - "**/*.DesktopClient/ModelManifest.xml": "explorerExcludedFiles", - "**/*.Server/GeneratedArtifacts": "explorerExcludedFiles", - "**/*.Server/ModelManifest.xml": "explorerExcludedFiles", - "_Pvt_Extensions": "explorerExcludedFiles", - ".paket/paket.exe": "explorerExcludedFiles", - "paket-files/": "explorerExcludedFiles", - ".fake/": "explorerExcludedFiles", - ".idea/": "explorerExcludedFiles", - "*.sln.iml": "explorerExcludedFiles", - "*.orig": "explorerExcludedFiles", - "tools/": "explorerExcludedFiles" - } +{ + "files.exclude": { + "*.suo": "explorerExcludedFiles", + "*.user": "explorerExcludedFiles", + "*.userosscache": "explorerExcludedFiles", + "*.sln.docstates": "explorerExcludedFiles", + "*.userprefs": "explorerExcludedFiles", + "[Dd]ebug/": "explorerExcludedFiles", + "[Dd]ebugPublic/": "explorerExcludedFiles", + "[Rr]elease/": "explorerExcludedFiles", + "[Rr]eleases/": "explorerExcludedFiles", + "x64/": "explorerExcludedFiles", + "x86/": "explorerExcludedFiles", + "bld/": "explorerExcludedFiles", + "[Bb]in/": "explorerExcludedFiles", + "[Oo]bj/": "explorerExcludedFiles", + "[Ll]og/": "explorerExcludedFiles", + ".vs/": "explorerExcludedFiles", + "[Tt]est[Rr]esult*/": "explorerExcludedFiles", + "[Bb]uild[Ll]og.*": "explorerExcludedFiles", + "*.VisualState.xml": "explorerExcludedFiles", + "TestResult.xml": "explorerExcludedFiles", + "[Dd]ebugPS/": "explorerExcludedFiles", + "[Rr]eleasePS/": "explorerExcludedFiles", + "dlldata.c": "explorerExcludedFiles", + "project.lock.json": "explorerExcludedFiles", + "artifacts/": "explorerExcludedFiles", + "*_i.c": "explorerExcludedFiles", + "*_p.c": "explorerExcludedFiles", + "*_i.h": "explorerExcludedFiles", + "*.ilk": "explorerExcludedFiles", + "*.meta": "explorerExcludedFiles", + "*.obj": "explorerExcludedFiles", + "*.pch": "explorerExcludedFiles", + "*.pdb": "explorerExcludedFiles", + "*.pgc": "explorerExcludedFiles", + "*.pgd": "explorerExcludedFiles", + "*.rsp": "explorerExcludedFiles", + "*.sbr": "explorerExcludedFiles", + "*.tlb": "explorerExcludedFiles", + "*.tli": "explorerExcludedFiles", + "*.tlh": "explorerExcludedFiles", + "*.tmp": "explorerExcludedFiles", + "*.tmp_proj": "explorerExcludedFiles", + "*.log": "explorerExcludedFiles", + "*.vspscc": "explorerExcludedFiles", + "*.vssscc": "explorerExcludedFiles", + ".builds": "explorerExcludedFiles", + "*.pidb": "explorerExcludedFiles", + "*.svclog": "explorerExcludedFiles", + "*.scc": "explorerExcludedFiles", + "_Chutzpah*": "explorerExcludedFiles", + "ipch/": "explorerExcludedFiles", + "*.aps": "explorerExcludedFiles", + "*.ncb": "explorerExcludedFiles", + "*.opendb": "explorerExcludedFiles", + "*.opensdf": "explorerExcludedFiles", + "*.sdf": "explorerExcludedFiles", + "*.cachefile": "explorerExcludedFiles", + "*.VC.db": "explorerExcludedFiles", + "*.VC.VC.opendb": "explorerExcludedFiles", + "*.psess": "explorerExcludedFiles", + "*.vsp": "explorerExcludedFiles", + "*.vspx": "explorerExcludedFiles", + "*.sap": "explorerExcludedFiles", + "$tf/": "explorerExcludedFiles", + "*.gpState": "explorerExcludedFiles", + "_ReSharper*/": "explorerExcludedFiles", + "*.[Rr]e[Ss]harper": "explorerExcludedFiles", + "*.DotSettings.user": "explorerExcludedFiles", + ".JustCode": "explorerExcludedFiles", + "_TeamCity*": "explorerExcludedFiles", + "*.dotCover": "explorerExcludedFiles", + "_NCrunch_*": "explorerExcludedFiles", + ".*crunch*.local.xml": "explorerExcludedFiles", + "nCrunchTemp_*": "explorerExcludedFiles", + "*.mm.*": "explorerExcludedFiles", + "AutoTest.Net/": "explorerExcludedFiles", + ".sass-cache/": "explorerExcludedFiles", + "[Ee]xpress/": "explorerExcludedFiles", + "DocProject/buildhelp/": "explorerExcludedFiles", + "DocProject/Help/*.HxT": "explorerExcludedFiles", + "DocProject/Help/*.HxC": "explorerExcludedFiles", + "DocProject/Help/*.hhc": "explorerExcludedFiles", + "DocProject/Help/*.hhk": "explorerExcludedFiles", + "DocProject/Help/*.hhp": "explorerExcludedFiles", + "DocProject/Help/Html2": "explorerExcludedFiles", + "DocProject/Help/html": "explorerExcludedFiles", + "publish/": "explorerExcludedFiles", + "*.[Pp]ublish.xml": "explorerExcludedFiles", + "*.azurePubxml": "explorerExcludedFiles", + "*.pubxml": "explorerExcludedFiles", + "*.publishproj": "explorerExcludedFiles", + "PublishScripts/": "explorerExcludedFiles", + "*.nupkg": "explorerExcludedFiles", + "**/packages/*": "explorerExcludedFiles", + "!**/packages/build/": "explorerExcludedFiles", + "*.nuget.props": "explorerExcludedFiles", + "*.nuget.targets": "explorerExcludedFiles", + "csx/": "explorerExcludedFiles", + "*.build.csdef": "explorerExcludedFiles", + "ecf/": "explorerExcludedFiles", + "rcf/": "explorerExcludedFiles", + "AppPackages/": "explorerExcludedFiles", + "BundleArtifacts/": "explorerExcludedFiles", + "Package.StoreAssociation.xml": "explorerExcludedFiles", + "_pkginfo.txt": "explorerExcludedFiles", + "*.[Cc]ache": "explorerExcludedFiles", + "!*.[Cc]ache/": "explorerExcludedFiles", + "ClientBin/": "explorerExcludedFiles", + "~$*": "explorerExcludedFiles", + "*~": "explorerExcludedFiles", + "*.dbmdl": "explorerExcludedFiles", + "*.dbproj.schemaview": "explorerExcludedFiles", + "*.pfx": "explorerExcludedFiles", + "*.publishsettings": "explorerExcludedFiles", + "node_modules/": "explorerExcludedFiles", + "orleans.codegen.cs": "explorerExcludedFiles", + "Generated_Code/": "explorerExcludedFiles", + "_UpgradeReport_Files/": "explorerExcludedFiles", + "Backup*/": "explorerExcludedFiles", + "UpgradeLog*.XML": "explorerExcludedFiles", + "UpgradeLog*.htm": "explorerExcludedFiles", + "*.mdf": "explorerExcludedFiles", + "*.ldf": "explorerExcludedFiles", + "*.rdl.data": "explorerExcludedFiles", + "*.bim.layout": "explorerExcludedFiles", + "*.bim_*.settings": "explorerExcludedFiles", + "FakesAssemblies/": "explorerExcludedFiles", + "*.GhostDoc.xml": "explorerExcludedFiles", + ".ntvs_analysis.dat": "explorerExcludedFiles", + "*.plg": "explorerExcludedFiles", + "*.opt": "explorerExcludedFiles", + "**/*.HTMLClient/GeneratedArtifacts": "explorerExcludedFiles", + "**/*.DesktopClient/GeneratedArtifacts": "explorerExcludedFiles", + "**/*.DesktopClient/ModelManifest.xml": "explorerExcludedFiles", + "**/*.Server/GeneratedArtifacts": "explorerExcludedFiles", + "**/*.Server/ModelManifest.xml": "explorerExcludedFiles", + "_Pvt_Extensions": "explorerExcludedFiles", + ".paket/paket.exe": "explorerExcludedFiles", + "paket-files/": "explorerExcludedFiles", + ".fake/": "explorerExcludedFiles", + ".idea/": "explorerExcludedFiles", + "*.sln.iml": "explorerExcludedFiles", + "*.orig": "explorerExcludedFiles", + "tools/": "explorerExcludedFiles" + } } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ef9bc4b494..9e8fe49315 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,16 +1,16 @@ -{ - "version": "0.1.0", - "command": "dotnet", - "isShellCommand": true, - "args": [], - "tasks": [ - { - "taskName": "build", - "args": [ - "${workspaceRoot}\\examples\\InprocessBenchmark\\InprocessBenchmark.csproj" - ], - "isBuildCommand": true, - "problemMatcher": "$msCompile" - } - ] +{ + "version": "0.1.0", + "command": "dotnet", + "isShellCommand": true, + "args": [], + "tasks": [ + { + "taskName": "build", + "args": [ + "${workspaceRoot}\\examples\\InprocessBenchmark\\InprocessBenchmark.csproj" + ], + "isBuildCommand": true, + "problemMatcher": "$msCompile" + } + ] } \ No newline at end of file diff --git a/LICENSE b/LICENSE index 8dada3edaf..c0ee81299b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,201 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright {yyyy} {name of copyright owner} - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/ProtoActor.sln b/ProtoActor.sln index 5412f91e6b..6cef934db1 100644 --- a/ProtoActor.sln +++ b/ProtoActor.sln @@ -1,409 +1,409 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26127.3 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{771514F1-12AE-4A26-89CB-2646D3EF7034}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{59DCCC96-DDAF-469F-9E8E-9BC733285082}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RemoteBenchmark", "RemoteBenchmark", "{92EB7B8A-7DCC-426A-9386-F58C167D82C3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "examples\RemoteBenchmark\Messages\Messages.csproj", "{55904739-71E8-478F-8BBD-9A32CAE9E01B}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Node2", "examples\RemoteBenchmark\Node2\Node2.csproj", "{DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpawnBenchmark", "examples\SpawnBenchmark\SpawnBenchmark.csproj", "{76BA8256-C071-4353-B5A3-FA0E4BC444EF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SpawnBenchmark", "SpawnBenchmark", "{9EA30F02-E35A-4EB2-80D9-1C64ED4613C4}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Actor", "src\Proto.Actor\Proto.Actor.csproj", "{7D13CCDD-6B93-45B8-BA88-761744601726}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9AA2BCF0-19AB-4DD9-8D91-7D188E463806}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Router", "Router", "{DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MailboxBenchmark", "MailboxBenchmark", "{99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MailboxBenchmark", "examples\MailboxBenchmark\MailboxBenchmark.csproj", "{14B4D6B3-C458-4EEF-8D00-178272E2DE30}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Middleware", "Middleware", "{AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Actor.Tests", "tests\Proto.Actor.Tests\Proto.Actor.Tests.csproj", "{6A8DB932-5230-4179-A3F0-291407E0419D}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Remote", "src\Proto.Remote\Proto.Remote.csproj", "{4494E76E-16AC-4A7B-A2B8-A9B2D0568630}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Router", "src\Proto.Router\Proto.Router.csproj", "{8C10C7BB-5A7B-494A-9428-A3F11AA4B374}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Router", "examples\Router\Router.csproj", "{571A1CB9-2819-4FCD-A721-DB9AD63CC444}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Persistence", "src\Proto.Persistence\Proto.Persistence.csproj", "{30AAE00A-7FB9-43AC-8304-B824C0F097F2}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{8622758C-75DB-4067-AB13-7D9531A16E9E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "examples\Persistence\Persistence\Persistence.csproj", "{2F58942D-7C9F-49B3-8560-5AE786A177CA}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "examples\Persistence\Messages\Messages.csproj", "{43E1097C-A356-4740-B4B1-A5AFC486CA8C}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PersistenceProviders", "PersistenceProviders", "{7AF64900-EA34-4A93-9514-FEBC4648E39E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Persistence.Couchbase", "src\PersistenceProviders\Proto.Persistence.Couchbase\Proto.Persistence.Couchbase.csproj", "{89ED6E98-BB85-4B82-907A-D5EC5422C740}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Node1", "examples\RemoteBenchmark\Node1\Node1.csproj", "{A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InprocessBenchmark", "InprocessBenchmark", "{768E2FB6-A663-4D6A-A791-B2E1AF7296AF}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InprocessBenchmark", "examples\InprocessBenchmark\InprocessBenchmark.csproj", "{2C02A779-3805-42D3-A8F6-12940E6BDF34}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ReceiveTimeout", "ReceiveTimeout", "{C78E50DC-8D65-4117-9B3E-BFA3F4A8101E}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReceiveTimeout", "examples\ReceiveTimeout\ReceiveTimeout.csproj", "{AC11D152-F1FD-4A48-A0DC-0B315D507457}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Mailbox", "src\Proto.Mailbox\Proto.Mailbox.csproj", "{7B1E82F7-270F-40F0-AF76-3FA54EF79124}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Middleware", "examples\Middleware\Middleware.csproj", "{3378E8AC-72C6-4A19-8061-C22CC390EE09}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Futures", "Futures", "{F045416D-2BFA-4048-AB1D-D908F4566F75}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Futures", "examples\Futures\Futures.csproj", "{9DA55746-E70B-4B37-972C-F0745AF151DE}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelloWorld", "HelloWorld", "{02D69941-5D89-4F54-9876-D5EC06B214A1}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "examples\HelloWorld\HelloWorld.csproj", "{84180640-21F6-4EB4-AF37-16481F93933E}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chat", "Chat", "{7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "examples\Chat\Client\Client.csproj", "{DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "examples\Chat\Server\Server.csproj", "{BB91F8FB-412B-420F-90DA-6DCB970CEA74}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chat.Messages", "examples\Chat\Messages\Chat.Messages.csproj", "{08EB688D-2E71-4C78-BB50-797AAC310650}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x64.ActiveCfg = Debug|x64 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x64.Build.0 = Debug|x64 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x86.ActiveCfg = Debug|x86 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x86.Build.0 = Debug|x86 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|Any CPU.Build.0 = Release|Any CPU - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x64.ActiveCfg = Release|x64 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x64.Build.0 = Release|x64 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x86.ActiveCfg = Release|x86 - {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x86.Build.0 = Release|x86 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x64.ActiveCfg = Debug|x64 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x64.Build.0 = Debug|x64 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x86.ActiveCfg = Debug|x86 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x86.Build.0 = Debug|x86 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|Any CPU.Build.0 = Release|Any CPU - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x64.ActiveCfg = Release|x64 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x64.Build.0 = Release|x64 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x86.ActiveCfg = Release|x86 - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x86.Build.0 = Release|x86 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x64.ActiveCfg = Debug|x64 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x64.Build.0 = Debug|x64 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x86.ActiveCfg = Debug|x86 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x86.Build.0 = Debug|x86 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|Any CPU.Build.0 = Release|Any CPU - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x64.ActiveCfg = Release|x64 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x64.Build.0 = Release|x64 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x86.ActiveCfg = Release|x86 - {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x86.Build.0 = Release|x86 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x64.ActiveCfg = Debug|x64 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x64.Build.0 = Debug|x64 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x86.ActiveCfg = Debug|x86 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x86.Build.0 = Debug|x86 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|Any CPU.Build.0 = Release|Any CPU - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x64.ActiveCfg = Release|x64 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x64.Build.0 = Release|x64 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x86.ActiveCfg = Release|x86 - {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x86.Build.0 = Release|x86 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|Any CPU.Build.0 = Debug|Any CPU - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x64.ActiveCfg = Debug|x64 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x64.Build.0 = Debug|x64 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x86.ActiveCfg = Debug|x86 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x86.Build.0 = Debug|x86 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|Any CPU.ActiveCfg = Release|Any CPU - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|Any CPU.Build.0 = Release|Any CPU - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x64.ActiveCfg = Release|x64 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x64.Build.0 = Release|x64 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x86.ActiveCfg = Release|x86 - {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x86.Build.0 = Release|x86 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x64.ActiveCfg = Debug|x64 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x64.Build.0 = Debug|x64 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x86.ActiveCfg = Debug|x86 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x86.Build.0 = Debug|x86 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|Any CPU.Build.0 = Release|Any CPU - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x64.ActiveCfg = Release|x64 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x64.Build.0 = Release|x64 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x86.ActiveCfg = Release|x86 - {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x86.Build.0 = Release|x86 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x64.ActiveCfg = Debug|x64 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x64.Build.0 = Debug|x64 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x86.ActiveCfg = Debug|x86 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x86.Build.0 = Debug|x86 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|Any CPU.Build.0 = Release|Any CPU - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x64.ActiveCfg = Release|x64 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x64.Build.0 = Release|x64 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x86.ActiveCfg = Release|x86 - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x86.Build.0 = Release|x86 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x64.ActiveCfg = Debug|x64 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x64.Build.0 = Debug|x64 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x86.ActiveCfg = Debug|x86 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x86.Build.0 = Debug|x86 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|Any CPU.Build.0 = Release|Any CPU - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x64.ActiveCfg = Release|x64 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x64.Build.0 = Release|x64 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x86.ActiveCfg = Release|x86 - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x86.Build.0 = Release|x86 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|Any CPU.Build.0 = Debug|Any CPU - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x64.ActiveCfg = Debug|x64 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x64.Build.0 = Debug|x64 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x86.ActiveCfg = Debug|x86 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x86.Build.0 = Debug|x86 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|Any CPU.ActiveCfg = Release|Any CPU - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|Any CPU.Build.0 = Release|Any CPU - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x64.ActiveCfg = Release|x64 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x64.Build.0 = Release|x64 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x86.ActiveCfg = Release|x86 - {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x86.Build.0 = Release|x86 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x64.ActiveCfg = Debug|x64 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x64.Build.0 = Debug|x64 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x86.ActiveCfg = Debug|x86 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x86.Build.0 = Debug|x86 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|Any CPU.Build.0 = Release|Any CPU - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x64.ActiveCfg = Release|x64 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x64.Build.0 = Release|x64 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x86.ActiveCfg = Release|x86 - {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x86.Build.0 = Release|x86 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x64.ActiveCfg = Debug|x64 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x64.Build.0 = Debug|x64 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x86.ActiveCfg = Debug|x86 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x86.Build.0 = Debug|x86 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|Any CPU.Build.0 = Release|Any CPU - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x64.ActiveCfg = Release|x64 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x64.Build.0 = Release|x64 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x86.ActiveCfg = Release|x86 - {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x86.Build.0 = Release|x86 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x64.ActiveCfg = Debug|x64 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x64.Build.0 = Debug|x64 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x86.ActiveCfg = Debug|x86 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x86.Build.0 = Debug|x86 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|Any CPU.Build.0 = Release|Any CPU - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x64.ActiveCfg = Release|x64 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x64.Build.0 = Release|x64 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x86.ActiveCfg = Release|x86 - {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x86.Build.0 = Release|x86 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|Any CPU.Build.0 = Debug|Any CPU - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x64.ActiveCfg = Debug|x64 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x64.Build.0 = Debug|x64 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x86.ActiveCfg = Debug|x86 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x86.Build.0 = Debug|x86 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|Any CPU.ActiveCfg = Release|Any CPU - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|Any CPU.Build.0 = Release|Any CPU - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x64.ActiveCfg = Release|x64 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x64.Build.0 = Release|x64 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x86.ActiveCfg = Release|x86 - {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x86.Build.0 = Release|x86 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x64.ActiveCfg = Debug|x64 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x64.Build.0 = Debug|x64 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x86.ActiveCfg = Debug|x86 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x86.Build.0 = Debug|x86 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|Any CPU.Build.0 = Release|Any CPU - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x64.ActiveCfg = Release|x64 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x64.Build.0 = Release|x64 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x86.ActiveCfg = Release|x86 - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x86.Build.0 = Release|x86 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x64.ActiveCfg = Debug|x64 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x64.Build.0 = Debug|x64 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x86.ActiveCfg = Debug|x86 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x86.Build.0 = Debug|x86 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|Any CPU.Build.0 = Release|Any CPU - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x64.ActiveCfg = Release|x64 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x64.Build.0 = Release|x64 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x86.ActiveCfg = Release|x86 - {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x86.Build.0 = Release|x86 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x64.ActiveCfg = Debug|x64 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x64.Build.0 = Debug|x64 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x86.ActiveCfg = Debug|x86 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x86.Build.0 = Debug|x86 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|Any CPU.Build.0 = Release|Any CPU - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x64.ActiveCfg = Release|x64 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x64.Build.0 = Release|x64 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x86.ActiveCfg = Release|x86 - {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x86.Build.0 = Release|x86 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x64.ActiveCfg = Debug|x64 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x64.Build.0 = Debug|x64 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x86.ActiveCfg = Debug|x86 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x86.Build.0 = Debug|x86 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|Any CPU.Build.0 = Release|Any CPU - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x64.ActiveCfg = Release|x64 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x64.Build.0 = Release|x64 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x86.ActiveCfg = Release|x86 - {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x86.Build.0 = Release|x86 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|Any CPU.Build.0 = Debug|Any CPU - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x64.ActiveCfg = Debug|x64 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x64.Build.0 = Debug|x64 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x86.ActiveCfg = Debug|x86 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x86.Build.0 = Debug|x86 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|Any CPU.ActiveCfg = Release|Any CPU - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|Any CPU.Build.0 = Release|Any CPU - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x64.ActiveCfg = Release|x64 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x64.Build.0 = Release|x64 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x86.ActiveCfg = Release|x86 - {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x86.Build.0 = Release|x86 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x64.ActiveCfg = Debug|x64 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x64.Build.0 = Debug|x64 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x86.ActiveCfg = Debug|x86 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x86.Build.0 = Debug|x86 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|Any CPU.Build.0 = Release|Any CPU - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x64.ActiveCfg = Release|x64 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x64.Build.0 = Release|x64 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x86.ActiveCfg = Release|x86 - {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x86.Build.0 = Release|x86 - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x64.ActiveCfg = Debug|x64 - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x64.Build.0 = Debug|x64 - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x86.ActiveCfg = Debug|x86 - {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x86.Build.0 = Debug|x86 - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|Any CPU.Build.0 = Release|Any CPU - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x64.ActiveCfg = Release|x64 - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x64.Build.0 = Release|x64 - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x86.ActiveCfg = Release|x86 - {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x86.Build.0 = Release|x86 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x64.ActiveCfg = Debug|x64 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x64.Build.0 = Debug|x64 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x86.ActiveCfg = Debug|x86 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x86.Build.0 = Debug|x86 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|Any CPU.Build.0 = Release|Any CPU - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x64.ActiveCfg = Release|x64 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x64.Build.0 = Release|x64 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x86.ActiveCfg = Release|x86 - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x86.Build.0 = Release|x86 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x64.ActiveCfg = Debug|x64 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x64.Build.0 = Debug|x64 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x86.ActiveCfg = Debug|x86 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x86.Build.0 = Debug|x86 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|Any CPU.Build.0 = Release|Any CPU - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x64.ActiveCfg = Release|x64 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x64.Build.0 = Release|x64 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x86.ActiveCfg = Release|x86 - {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x86.Build.0 = Release|x86 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|Any CPU.Build.0 = Debug|Any CPU - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x64.ActiveCfg = Debug|x64 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x64.Build.0 = Debug|x64 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x86.ActiveCfg = Debug|x86 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x86.Build.0 = Debug|x86 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|Any CPU.ActiveCfg = Release|Any CPU - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|Any CPU.Build.0 = Release|Any CPU - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x64.ActiveCfg = Release|x64 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x64.Build.0 = Release|x64 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x86.ActiveCfg = Release|x86 - {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {92EB7B8A-7DCC-426A-9386-F58C167D82C3} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {55904739-71E8-478F-8BBD-9A32CAE9E01B} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} - {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} - {76BA8256-C071-4353-B5A3-FA0E4BC444EF} = {9EA30F02-E35A-4EB2-80D9-1C64ED4613C4} - {9EA30F02-E35A-4EB2-80D9-1C64ED4613C4} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {7D13CCDD-6B93-45B8-BA88-761744601726} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {14B4D6B3-C458-4EEF-8D00-178272E2DE30} = {99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33} - {AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {6A8DB932-5230-4179-A3F0-291407E0419D} = {9AA2BCF0-19AB-4DD9-8D91-7D188E463806} - {4494E76E-16AC-4A7B-A2B8-A9B2D0568630} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {8C10C7BB-5A7B-494A-9428-A3F11AA4B374} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {571A1CB9-2819-4FCD-A721-DB9AD63CC444} = {DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F} - {30AAE00A-7FB9-43AC-8304-B824C0F097F2} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {8622758C-75DB-4067-AB13-7D9531A16E9E} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {2F58942D-7C9F-49B3-8560-5AE786A177CA} = {8622758C-75DB-4067-AB13-7D9531A16E9E} - {43E1097C-A356-4740-B4B1-A5AFC486CA8C} = {8622758C-75DB-4067-AB13-7D9531A16E9E} - {7AF64900-EA34-4A93-9514-FEBC4648E39E} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {89ED6E98-BB85-4B82-907A-D5EC5422C740} = {7AF64900-EA34-4A93-9514-FEBC4648E39E} - {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} - {768E2FB6-A663-4D6A-A791-B2E1AF7296AF} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {2C02A779-3805-42D3-A8F6-12940E6BDF34} = {768E2FB6-A663-4D6A-A791-B2E1AF7296AF} - {C78E50DC-8D65-4117-9B3E-BFA3F4A8101E} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {AC11D152-F1FD-4A48-A0DC-0B315D507457} = {C78E50DC-8D65-4117-9B3E-BFA3F4A8101E} - {7B1E82F7-270F-40F0-AF76-3FA54EF79124} = {771514F1-12AE-4A26-89CB-2646D3EF7034} - {3378E8AC-72C6-4A19-8061-C22CC390EE09} = {AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3} - {F045416D-2BFA-4048-AB1D-D908F4566F75} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {9DA55746-E70B-4B37-972C-F0745AF151DE} = {F045416D-2BFA-4048-AB1D-D908F4566F75} - {02D69941-5D89-4F54-9876-D5EC06B214A1} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {84180640-21F6-4EB4-AF37-16481F93933E} = {02D69941-5D89-4F54-9876-D5EC06B214A1} - {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} - {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} - {BB91F8FB-412B-420F-90DA-6DCB970CEA74} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} - {08EB688D-2E71-4C78-BB50-797AAC310650} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26127.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{771514F1-12AE-4A26-89CB-2646D3EF7034}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", "{59DCCC96-DDAF-469F-9E8E-9BC733285082}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RemoteBenchmark", "RemoteBenchmark", "{92EB7B8A-7DCC-426A-9386-F58C167D82C3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "examples\RemoteBenchmark\Messages\Messages.csproj", "{55904739-71E8-478F-8BBD-9A32CAE9E01B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Node2", "examples\RemoteBenchmark\Node2\Node2.csproj", "{DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpawnBenchmark", "examples\SpawnBenchmark\SpawnBenchmark.csproj", "{76BA8256-C071-4353-B5A3-FA0E4BC444EF}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "SpawnBenchmark", "SpawnBenchmark", "{9EA30F02-E35A-4EB2-80D9-1C64ED4613C4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Actor", "src\Proto.Actor\Proto.Actor.csproj", "{7D13CCDD-6B93-45B8-BA88-761744601726}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{9AA2BCF0-19AB-4DD9-8D91-7D188E463806}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Router", "Router", "{DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MailboxBenchmark", "MailboxBenchmark", "{99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MailboxBenchmark", "examples\MailboxBenchmark\MailboxBenchmark.csproj", "{14B4D6B3-C458-4EEF-8D00-178272E2DE30}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Middleware", "Middleware", "{AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Actor.Tests", "tests\Proto.Actor.Tests\Proto.Actor.Tests.csproj", "{6A8DB932-5230-4179-A3F0-291407E0419D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Remote", "src\Proto.Remote\Proto.Remote.csproj", "{4494E76E-16AC-4A7B-A2B8-A9B2D0568630}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Router", "src\Proto.Router\Proto.Router.csproj", "{8C10C7BB-5A7B-494A-9428-A3F11AA4B374}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Router", "examples\Router\Router.csproj", "{571A1CB9-2819-4FCD-A721-DB9AD63CC444}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Persistence", "src\Proto.Persistence\Proto.Persistence.csproj", "{30AAE00A-7FB9-43AC-8304-B824C0F097F2}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Persistence", "Persistence", "{8622758C-75DB-4067-AB13-7D9531A16E9E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Persistence", "examples\Persistence\Persistence\Persistence.csproj", "{2F58942D-7C9F-49B3-8560-5AE786A177CA}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Messages", "examples\Persistence\Messages\Messages.csproj", "{43E1097C-A356-4740-B4B1-A5AFC486CA8C}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PersistenceProviders", "PersistenceProviders", "{7AF64900-EA34-4A93-9514-FEBC4648E39E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Persistence.Couchbase", "src\PersistenceProviders\Proto.Persistence.Couchbase\Proto.Persistence.Couchbase.csproj", "{89ED6E98-BB85-4B82-907A-D5EC5422C740}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Node1", "examples\RemoteBenchmark\Node1\Node1.csproj", "{A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InprocessBenchmark", "InprocessBenchmark", "{768E2FB6-A663-4D6A-A791-B2E1AF7296AF}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InprocessBenchmark", "examples\InprocessBenchmark\InprocessBenchmark.csproj", "{2C02A779-3805-42D3-A8F6-12940E6BDF34}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ReceiveTimeout", "ReceiveTimeout", "{C78E50DC-8D65-4117-9B3E-BFA3F4A8101E}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ReceiveTimeout", "examples\ReceiveTimeout\ReceiveTimeout.csproj", "{AC11D152-F1FD-4A48-A0DC-0B315D507457}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Proto.Mailbox", "src\Proto.Mailbox\Proto.Mailbox.csproj", "{7B1E82F7-270F-40F0-AF76-3FA54EF79124}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Middleware", "examples\Middleware\Middleware.csproj", "{3378E8AC-72C6-4A19-8061-C22CC390EE09}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Futures", "Futures", "{F045416D-2BFA-4048-AB1D-D908F4566F75}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Futures", "examples\Futures\Futures.csproj", "{9DA55746-E70B-4B37-972C-F0745AF151DE}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "HelloWorld", "HelloWorld", "{02D69941-5D89-4F54-9876-D5EC06B214A1}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloWorld", "examples\HelloWorld\HelloWorld.csproj", "{84180640-21F6-4EB4-AF37-16481F93933E}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Chat", "Chat", "{7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "examples\Chat\Client\Client.csproj", "{DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Server", "examples\Chat\Server\Server.csproj", "{BB91F8FB-412B-420F-90DA-6DCB970CEA74}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chat.Messages", "examples\Chat\Messages\Chat.Messages.csproj", "{08EB688D-2E71-4C78-BB50-797AAC310650}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x64.ActiveCfg = Debug|x64 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x64.Build.0 = Debug|x64 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x86.ActiveCfg = Debug|x86 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Debug|x86.Build.0 = Debug|x86 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|Any CPU.Build.0 = Release|Any CPU + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x64.ActiveCfg = Release|x64 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x64.Build.0 = Release|x64 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x86.ActiveCfg = Release|x86 + {55904739-71E8-478F-8BBD-9A32CAE9E01B}.Release|x86.Build.0 = Release|x86 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x64.ActiveCfg = Debug|x64 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x64.Build.0 = Debug|x64 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x86.ActiveCfg = Debug|x86 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Debug|x86.Build.0 = Debug|x86 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|Any CPU.Build.0 = Release|Any CPU + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x64.ActiveCfg = Release|x64 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x64.Build.0 = Release|x64 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x86.ActiveCfg = Release|x86 + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB}.Release|x86.Build.0 = Release|x86 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x64.ActiveCfg = Debug|x64 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x64.Build.0 = Debug|x64 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x86.ActiveCfg = Debug|x86 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Debug|x86.Build.0 = Debug|x86 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|Any CPU.Build.0 = Release|Any CPU + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x64.ActiveCfg = Release|x64 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x64.Build.0 = Release|x64 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x86.ActiveCfg = Release|x86 + {76BA8256-C071-4353-B5A3-FA0E4BC444EF}.Release|x86.Build.0 = Release|x86 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x64.ActiveCfg = Debug|x64 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x64.Build.0 = Debug|x64 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x86.ActiveCfg = Debug|x86 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Debug|x86.Build.0 = Debug|x86 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|Any CPU.Build.0 = Release|Any CPU + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x64.ActiveCfg = Release|x64 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x64.Build.0 = Release|x64 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x86.ActiveCfg = Release|x86 + {7D13CCDD-6B93-45B8-BA88-761744601726}.Release|x86.Build.0 = Release|x86 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|Any CPU.Build.0 = Debug|Any CPU + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x64.ActiveCfg = Debug|x64 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x64.Build.0 = Debug|x64 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x86.ActiveCfg = Debug|x86 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Debug|x86.Build.0 = Debug|x86 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|Any CPU.ActiveCfg = Release|Any CPU + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|Any CPU.Build.0 = Release|Any CPU + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x64.ActiveCfg = Release|x64 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x64.Build.0 = Release|x64 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x86.ActiveCfg = Release|x86 + {14B4D6B3-C458-4EEF-8D00-178272E2DE30}.Release|x86.Build.0 = Release|x86 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x64.ActiveCfg = Debug|x64 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x64.Build.0 = Debug|x64 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x86.ActiveCfg = Debug|x86 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Debug|x86.Build.0 = Debug|x86 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|Any CPU.Build.0 = Release|Any CPU + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x64.ActiveCfg = Release|x64 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x64.Build.0 = Release|x64 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x86.ActiveCfg = Release|x86 + {6A8DB932-5230-4179-A3F0-291407E0419D}.Release|x86.Build.0 = Release|x86 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|Any CPU.Build.0 = Debug|Any CPU + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x64.ActiveCfg = Debug|x64 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x64.Build.0 = Debug|x64 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x86.ActiveCfg = Debug|x86 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Debug|x86.Build.0 = Debug|x86 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|Any CPU.ActiveCfg = Release|Any CPU + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|Any CPU.Build.0 = Release|Any CPU + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x64.ActiveCfg = Release|x64 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x64.Build.0 = Release|x64 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x86.ActiveCfg = Release|x86 + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630}.Release|x86.Build.0 = Release|x86 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|Any CPU.Build.0 = Debug|Any CPU + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x64.ActiveCfg = Debug|x64 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x64.Build.0 = Debug|x64 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x86.ActiveCfg = Debug|x86 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Debug|x86.Build.0 = Debug|x86 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|Any CPU.ActiveCfg = Release|Any CPU + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|Any CPU.Build.0 = Release|Any CPU + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x64.ActiveCfg = Release|x64 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x64.Build.0 = Release|x64 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x86.ActiveCfg = Release|x86 + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374}.Release|x86.Build.0 = Release|x86 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|Any CPU.Build.0 = Debug|Any CPU + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x64.ActiveCfg = Debug|x64 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x64.Build.0 = Debug|x64 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x86.ActiveCfg = Debug|x86 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Debug|x86.Build.0 = Debug|x86 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|Any CPU.ActiveCfg = Release|Any CPU + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|Any CPU.Build.0 = Release|Any CPU + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x64.ActiveCfg = Release|x64 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x64.Build.0 = Release|x64 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x86.ActiveCfg = Release|x86 + {571A1CB9-2819-4FCD-A721-DB9AD63CC444}.Release|x86.Build.0 = Release|x86 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x64.ActiveCfg = Debug|x64 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x64.Build.0 = Debug|x64 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x86.ActiveCfg = Debug|x86 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Debug|x86.Build.0 = Debug|x86 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|Any CPU.Build.0 = Release|Any CPU + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x64.ActiveCfg = Release|x64 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x64.Build.0 = Release|x64 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x86.ActiveCfg = Release|x86 + {30AAE00A-7FB9-43AC-8304-B824C0F097F2}.Release|x86.Build.0 = Release|x86 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x64.ActiveCfg = Debug|x64 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x64.Build.0 = Debug|x64 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x86.ActiveCfg = Debug|x86 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Debug|x86.Build.0 = Debug|x86 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|Any CPU.Build.0 = Release|Any CPU + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x64.ActiveCfg = Release|x64 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x64.Build.0 = Release|x64 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x86.ActiveCfg = Release|x86 + {2F58942D-7C9F-49B3-8560-5AE786A177CA}.Release|x86.Build.0 = Release|x86 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x64.ActiveCfg = Debug|x64 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x64.Build.0 = Debug|x64 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x86.ActiveCfg = Debug|x86 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Debug|x86.Build.0 = Debug|x86 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|Any CPU.Build.0 = Release|Any CPU + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x64.ActiveCfg = Release|x64 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x64.Build.0 = Release|x64 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x86.ActiveCfg = Release|x86 + {43E1097C-A356-4740-B4B1-A5AFC486CA8C}.Release|x86.Build.0 = Release|x86 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|Any CPU.Build.0 = Debug|Any CPU + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x64.ActiveCfg = Debug|x64 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x64.Build.0 = Debug|x64 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x86.ActiveCfg = Debug|x86 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Debug|x86.Build.0 = Debug|x86 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|Any CPU.ActiveCfg = Release|Any CPU + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|Any CPU.Build.0 = Release|Any CPU + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x64.ActiveCfg = Release|x64 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x64.Build.0 = Release|x64 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x86.ActiveCfg = Release|x86 + {89ED6E98-BB85-4B82-907A-D5EC5422C740}.Release|x86.Build.0 = Release|x86 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x64.ActiveCfg = Debug|x64 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x64.Build.0 = Debug|x64 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x86.ActiveCfg = Debug|x86 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Debug|x86.Build.0 = Debug|x86 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|Any CPU.Build.0 = Release|Any CPU + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x64.ActiveCfg = Release|x64 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x64.Build.0 = Release|x64 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x86.ActiveCfg = Release|x86 + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89}.Release|x86.Build.0 = Release|x86 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x64.ActiveCfg = Debug|x64 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x64.Build.0 = Debug|x64 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x86.ActiveCfg = Debug|x86 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Debug|x86.Build.0 = Debug|x86 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|Any CPU.Build.0 = Release|Any CPU + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x64.ActiveCfg = Release|x64 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x64.Build.0 = Release|x64 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x86.ActiveCfg = Release|x86 + {2C02A779-3805-42D3-A8F6-12940E6BDF34}.Release|x86.Build.0 = Release|x86 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x64.ActiveCfg = Debug|x64 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x64.Build.0 = Debug|x64 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x86.ActiveCfg = Debug|x86 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Debug|x86.Build.0 = Debug|x86 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|Any CPU.Build.0 = Release|Any CPU + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x64.ActiveCfg = Release|x64 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x64.Build.0 = Release|x64 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x86.ActiveCfg = Release|x86 + {AC11D152-F1FD-4A48-A0DC-0B315D507457}.Release|x86.Build.0 = Release|x86 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x64.ActiveCfg = Debug|x64 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x64.Build.0 = Debug|x64 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x86.ActiveCfg = Debug|x86 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Debug|x86.Build.0 = Debug|x86 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|Any CPU.Build.0 = Release|Any CPU + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x64.ActiveCfg = Release|x64 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x64.Build.0 = Release|x64 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x86.ActiveCfg = Release|x86 + {7B1E82F7-270F-40F0-AF76-3FA54EF79124}.Release|x86.Build.0 = Release|x86 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x64.ActiveCfg = Debug|x64 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x64.Build.0 = Debug|x64 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x86.ActiveCfg = Debug|x86 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Debug|x86.Build.0 = Debug|x86 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|Any CPU.Build.0 = Release|Any CPU + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x64.ActiveCfg = Release|x64 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x64.Build.0 = Release|x64 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x86.ActiveCfg = Release|x86 + {3378E8AC-72C6-4A19-8061-C22CC390EE09}.Release|x86.Build.0 = Release|x86 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x64.ActiveCfg = Debug|x64 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x64.Build.0 = Debug|x64 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x86.ActiveCfg = Debug|x86 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Debug|x86.Build.0 = Debug|x86 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|Any CPU.Build.0 = Release|Any CPU + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x64.ActiveCfg = Release|x64 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x64.Build.0 = Release|x64 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x86.ActiveCfg = Release|x86 + {9DA55746-E70B-4B37-972C-F0745AF151DE}.Release|x86.Build.0 = Release|x86 + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x64.ActiveCfg = Debug|x64 + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x64.Build.0 = Debug|x64 + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x86.ActiveCfg = Debug|x86 + {84180640-21F6-4EB4-AF37-16481F93933E}.Debug|x86.Build.0 = Debug|x86 + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|Any CPU.Build.0 = Release|Any CPU + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x64.ActiveCfg = Release|x64 + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x64.Build.0 = Release|x64 + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x86.ActiveCfg = Release|x86 + {84180640-21F6-4EB4-AF37-16481F93933E}.Release|x86.Build.0 = Release|x86 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x64.ActiveCfg = Debug|x64 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x64.Build.0 = Debug|x64 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x86.ActiveCfg = Debug|x86 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Debug|x86.Build.0 = Debug|x86 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|Any CPU.Build.0 = Release|Any CPU + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x64.ActiveCfg = Release|x64 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x64.Build.0 = Release|x64 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x86.ActiveCfg = Release|x86 + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F}.Release|x86.Build.0 = Release|x86 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x64.ActiveCfg = Debug|x64 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x64.Build.0 = Debug|x64 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x86.ActiveCfg = Debug|x86 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Debug|x86.Build.0 = Debug|x86 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|Any CPU.Build.0 = Release|Any CPU + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x64.ActiveCfg = Release|x64 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x64.Build.0 = Release|x64 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x86.ActiveCfg = Release|x86 + {BB91F8FB-412B-420F-90DA-6DCB970CEA74}.Release|x86.Build.0 = Release|x86 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x64.ActiveCfg = Debug|x64 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x64.Build.0 = Debug|x64 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x86.ActiveCfg = Debug|x86 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Debug|x86.Build.0 = Debug|x86 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|Any CPU.Build.0 = Release|Any CPU + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x64.ActiveCfg = Release|x64 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x64.Build.0 = Release|x64 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x86.ActiveCfg = Release|x86 + {08EB688D-2E71-4C78-BB50-797AAC310650}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {92EB7B8A-7DCC-426A-9386-F58C167D82C3} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {55904739-71E8-478F-8BBD-9A32CAE9E01B} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} + {DFEEF3A8-F9EB-43AE-AA73-A5FBF7402DAB} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} + {76BA8256-C071-4353-B5A3-FA0E4BC444EF} = {9EA30F02-E35A-4EB2-80D9-1C64ED4613C4} + {9EA30F02-E35A-4EB2-80D9-1C64ED4613C4} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {7D13CCDD-6B93-45B8-BA88-761744601726} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {14B4D6B3-C458-4EEF-8D00-178272E2DE30} = {99C3129A-1DD2-45BE-A6C0-3B7A04CD6D33} + {AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {6A8DB932-5230-4179-A3F0-291407E0419D} = {9AA2BCF0-19AB-4DD9-8D91-7D188E463806} + {4494E76E-16AC-4A7B-A2B8-A9B2D0568630} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {8C10C7BB-5A7B-494A-9428-A3F11AA4B374} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {571A1CB9-2819-4FCD-A721-DB9AD63CC444} = {DF1B4E58-8B85-49F0-A75B-5DC231D0FB8F} + {30AAE00A-7FB9-43AC-8304-B824C0F097F2} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {8622758C-75DB-4067-AB13-7D9531A16E9E} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {2F58942D-7C9F-49B3-8560-5AE786A177CA} = {8622758C-75DB-4067-AB13-7D9531A16E9E} + {43E1097C-A356-4740-B4B1-A5AFC486CA8C} = {8622758C-75DB-4067-AB13-7D9531A16E9E} + {7AF64900-EA34-4A93-9514-FEBC4648E39E} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {89ED6E98-BB85-4B82-907A-D5EC5422C740} = {7AF64900-EA34-4A93-9514-FEBC4648E39E} + {A003CCAB-BE2A-4A8A-A858-A4FAE08B5F89} = {92EB7B8A-7DCC-426A-9386-F58C167D82C3} + {768E2FB6-A663-4D6A-A791-B2E1AF7296AF} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {2C02A779-3805-42D3-A8F6-12940E6BDF34} = {768E2FB6-A663-4D6A-A791-B2E1AF7296AF} + {C78E50DC-8D65-4117-9B3E-BFA3F4A8101E} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {AC11D152-F1FD-4A48-A0DC-0B315D507457} = {C78E50DC-8D65-4117-9B3E-BFA3F4A8101E} + {7B1E82F7-270F-40F0-AF76-3FA54EF79124} = {771514F1-12AE-4A26-89CB-2646D3EF7034} + {3378E8AC-72C6-4A19-8061-C22CC390EE09} = {AFF0BC22-B7E5-43C2-AB4F-5BBBF688C3F3} + {F045416D-2BFA-4048-AB1D-D908F4566F75} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {9DA55746-E70B-4B37-972C-F0745AF151DE} = {F045416D-2BFA-4048-AB1D-D908F4566F75} + {02D69941-5D89-4F54-9876-D5EC06B214A1} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {84180640-21F6-4EB4-AF37-16481F93933E} = {02D69941-5D89-4F54-9876-D5EC06B214A1} + {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} = {59DCCC96-DDAF-469F-9E8E-9BC733285082} + {DAFD0819-5CE9-40AF-AFAE-D149B4EFB09F} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} + {BB91F8FB-412B-420F-90DA-6DCB970CEA74} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} + {08EB688D-2E71-4C78-BB50-797AAC310650} = {7C1624BB-71C7-4F2F-8A2F-84C1E7B034A4} + EndGlobalSection +EndGlobal diff --git a/README.md b/README.md index a3b0b37412..7f6546b214 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build status](https://ci.appveyor.com/api/projects/status/22q8a3e8ovejl5qf/branch/master?svg=true)](https://ci.appveyor.com/project/cpx/protoactor-dotnet-pr5pp/branch/master) - -# Proto.Actor -Ultra fast distributed actors for .NET and Go +[![Build status](https://ci.appveyor.com/api/projects/status/22q8a3e8ovejl5qf/branch/master?svg=true)](https://ci.appveyor.com/project/cpx/protoactor-dotnet-pr5pp/branch/master) + +# Proto.Actor +Ultra fast distributed actors for .NET and Go diff --git a/appveyor.yml b/appveyor.yml index c8aad8ac12..164570476d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,27 +1,27 @@ -image: Visual Studio 2017 RC -version: '0.1.0.{build}' -configuration: -#- Debug -- Release -platform: Any CPU -#environment: - # Don't report back to the mothership - # DOTNET_CLI_TELEMETRY_OPTOUT: 1 -#init: -#- ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") -before_build: -#- appveyor-retry dotnet restore -v Minimal -- dotnet restore -build_script: -- dotnet build -#after_build: -#- dotnet pack "src\LibNETStandard16" -c %CONFIGURATION% --no-build --version-suffix %LABEL% -o artifacts -#- dotnet publish "src\ConsoleApplication" -c %CONFIGURATION% --no-build --version-suffix %LABEL% -o artifacts\ConsoleApplication -test_script: -- dotnet test "tests\Proto.Actor.Tests\Proto.Actor.Tests.csproj" -#artifacts: -#- path: artifacts\**\*.* -#cache: -#- '%USERPROFILE%\.nuget\packages' -#on_finish: # Run the demo to show that it works -#- dotnet artifacts\ConsoleApplication\ConsoleApplication.dll +image: Visual Studio 2017 RC +version: '0.1.0.{build}' +configuration: +#- Debug +- Release +platform: Any CPU +#environment: + # Don't report back to the mothership + # DOTNET_CLI_TELEMETRY_OPTOUT: 1 +#init: +#- ps: $Env:LABEL = "CI" + $Env:APPVEYOR_BUILD_NUMBER.PadLeft(5, "0") +before_build: +#- appveyor-retry dotnet restore -v Minimal +- dotnet restore +build_script: +- dotnet build +#after_build: +#- dotnet pack "src\LibNETStandard16" -c %CONFIGURATION% --no-build --version-suffix %LABEL% -o artifacts +#- dotnet publish "src\ConsoleApplication" -c %CONFIGURATION% --no-build --version-suffix %LABEL% -o artifacts\ConsoleApplication +test_script: +- dotnet test "tests\Proto.Actor.Tests\Proto.Actor.Tests.csproj" +#artifacts: +#- path: artifacts\**\*.* +#cache: +#- '%USERPROFILE%\.nuget\packages' +#on_finish: # Run the demo to show that it works +#- dotnet artifacts\ConsoleApplication\ConsoleApplication.dll diff --git a/examples/Chat/Client/Client.csproj b/examples/Chat/Client/Client.csproj index fd1d6a3f03..d174a89c13 100644 --- a/examples/Chat/Client/Client.csproj +++ b/examples/Chat/Client/Client.csproj @@ -1,15 +1,15 @@ - - - Exe - netcoreapp1.1 - - - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + + + \ No newline at end of file diff --git a/examples/Chat/Client/Program.cs b/examples/Chat/Client/Program.cs index 1894e5e9df..3775475de1 100644 --- a/examples/Chat/Client/Program.cs +++ b/examples/Chat/Client/Program.cs @@ -1,64 +1,64 @@ -using System; -using chat.messages; -using Proto; -using Proto.Remote; - -class Program -{ - static void Main(string[] args) - { - Serialization.RegisterFileDescriptor(ChatReflection.Descriptor); - RemotingSystem.Start("127.0.0.1", new Random().Next(10000, 65000)); - var server = new PID("127.0.0.1:8000", "chatserver"); - - var props = Actor.FromFunc(ctx => - { - switch (ctx.Message) - { - case Connected connected: - Console.WriteLine(connected.Message); - break; - case SayResponse sayResponse: - Console.WriteLine($"{sayResponse.UserName} {sayResponse.Message}"); - break; - case NickResponse nickResponse: - Console.WriteLine($"{nickResponse.OldUserName} is now {nickResponse.NewUserName}"); - break; - } - return Actor.Done; - }); - - var client = Actor.Spawn(props); - server.Tell(new Connect - { - Sender = client - }); - var nick = "Alex"; - while (true) - { - var text = Console.ReadLine(); - if (text.Equals("/exit")) - { - return; - } - if (text.StartsWith("/nick ")) - { - var t = text.Split(' ')[1]; - server.Tell(new NickRequest - { - OldUserName = nick, - NewUserName = t - }); - nick = t; - } - else - { - server.Tell(new SayRequest - { - UserName = nick, - Message = text - }); - } - } - } +using System; +using chat.messages; +using Proto; +using Proto.Remote; + +class Program +{ + static void Main(string[] args) + { + Serialization.RegisterFileDescriptor(ChatReflection.Descriptor); + RemotingSystem.Start("127.0.0.1", new Random().Next(10000, 65000)); + var server = new PID("127.0.0.1:8000", "chatserver"); + + var props = Actor.FromFunc(ctx => + { + switch (ctx.Message) + { + case Connected connected: + Console.WriteLine(connected.Message); + break; + case SayResponse sayResponse: + Console.WriteLine($"{sayResponse.UserName} {sayResponse.Message}"); + break; + case NickResponse nickResponse: + Console.WriteLine($"{nickResponse.OldUserName} is now {nickResponse.NewUserName}"); + break; + } + return Actor.Done; + }); + + var client = Actor.Spawn(props); + server.Tell(new Connect + { + Sender = client + }); + var nick = "Alex"; + while (true) + { + var text = Console.ReadLine(); + if (text.Equals("/exit")) + { + return; + } + if (text.StartsWith("/nick ")) + { + var t = text.Split(' ')[1]; + server.Tell(new NickRequest + { + OldUserName = nick, + NewUserName = t + }); + nick = t; + } + else + { + server.Tell(new SayRequest + { + UserName = nick, + Message = text + }); + } + } + } } \ No newline at end of file diff --git a/examples/Chat/Messages/Chat.Messages.csproj b/examples/Chat/Messages/Chat.Messages.csproj index 641af1c2d9..15b9131ce4 100644 --- a/examples/Chat/Messages/Chat.Messages.csproj +++ b/examples/Chat/Messages/Chat.Messages.csproj @@ -1,18 +1,18 @@ - - - netstandard1.6 - Chat.Messages - Chat.Messages - - - - - - - - - - - - + + + netstandard1.6 + Chat.Messages + Chat.Messages + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/Chat/Messages/Chat.g.cs b/examples/Chat/Messages/Chat.g.cs index cc4e107597..358a07f8c8 100644 --- a/examples/Chat/Messages/Chat.g.cs +++ b/examples/Chat/Messages/Chat.g.cs @@ -1,873 +1,873 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Chat.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace chat.messages { - - /// Holder for reflection information generated from Chat.proto - public static partial class ChatReflection { - - #region Descriptor - /// File descriptor for Chat.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static ChatReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgpDaGF0LnByb3RvEg1jaGF0Lm1lc3NhZ2VzGhhQcm90by5BY3Rvci9Qcm90", - "b3MucHJvdG8iJQoHQ29ubmVjdBIaCgZTZW5kZXIYASABKAsyCi5hY3Rvci5Q", - "SUQiHAoJQ29ubmVjdGVkEg8KB01lc3NhZ2UYASABKAkiLwoKU2F5UmVxdWVz", - "dBIQCghVc2VyTmFtZRgBIAEoCRIPCgdNZXNzYWdlGAIgASgJIjAKC1NheVJl", - "c3BvbnNlEhAKCFVzZXJOYW1lGAEgASgJEg8KB01lc3NhZ2UYAiABKAkiNwoL", - "Tmlja1JlcXVlc3QSEwoLT2xkVXNlck5hbWUYASABKAkSEwoLTmV3VXNlck5h", - "bWUYAiABKAkiOAoMTmlja1Jlc3BvbnNlEhMKC09sZFVzZXJOYW1lGAEgASgJ", - "EhMKC05ld1VzZXJOYW1lGAIgASgJQhCqAg1jaGF0Lm1lc3NhZ2VzYgZwcm90", - "bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Proto.ProtosReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.Connect), global::chat.messages.Connect.Parser, new[]{ "Sender" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.Connected), global::chat.messages.Connected.Parser, new[]{ "Message" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.SayRequest), global::chat.messages.SayRequest.Parser, new[]{ "UserName", "Message" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.SayResponse), global::chat.messages.SayResponse.Parser, new[]{ "UserName", "Message" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.NickRequest), global::chat.messages.NickRequest.Parser, new[]{ "OldUserName", "NewUserName" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.NickResponse), global::chat.messages.NickResponse.Parser, new[]{ "OldUserName", "NewUserName" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Connect : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Connect()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connect() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connect(Connect other) : this() { - Sender = other.sender_ != null ? other.Sender.Clone() : null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connect Clone() { - return new Connect(this); - } - - /// Field number for the "Sender" field. - public const int SenderFieldNumber = 1; - private global::Proto.PID sender_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Sender { - get { return sender_; } - set { - sender_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Connect); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Connect other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Sender, other.Sender)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (sender_ != null) hash ^= Sender.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (sender_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Sender); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (sender_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sender); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Connect other) { - if (other == null) { - return; - } - if (other.sender_ != null) { - if (sender_ == null) { - sender_ = new global::Proto.PID(); - } - Sender.MergeFrom(other.Sender); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - if (sender_ == null) { - sender_ = new global::Proto.PID(); - } - input.ReadMessage(sender_); - break; - } - } - } - } - - } - - public sealed partial class Connected : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Connected()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connected() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connected(Connected other) : this() { - message_ = other.message_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Connected Clone() { - return new Connected(this); - } - - /// Field number for the "Message" field. - public const int MessageFieldNumber = 1; - private string message_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Message { - get { return message_; } - set { - message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Connected); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Connected other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Message != other.Message) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Message.Length != 0) hash ^= Message.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Message.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Message); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Message.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Connected other) { - if (other == null) { - return; - } - if (other.Message.Length != 0) { - Message = other.Message; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Message = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class SayRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SayRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayRequest(SayRequest other) : this() { - userName_ = other.userName_; - message_ = other.message_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayRequest Clone() { - return new SayRequest(this); - } - - /// Field number for the "UserName" field. - public const int UserNameFieldNumber = 1; - private string userName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string UserName { - get { return userName_; } - set { - userName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "Message" field. - public const int MessageFieldNumber = 2; - private string message_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Message { - get { return message_; } - set { - message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as SayRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(SayRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (UserName != other.UserName) return false; - if (Message != other.Message) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (UserName.Length != 0) hash ^= UserName.GetHashCode(); - if (Message.Length != 0) hash ^= Message.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (UserName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(UserName); - } - if (Message.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Message); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (UserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(UserName); - } - if (Message.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(SayRequest other) { - if (other == null) { - return; - } - if (other.UserName.Length != 0) { - UserName = other.UserName; - } - if (other.Message.Length != 0) { - Message = other.Message; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - UserName = input.ReadString(); - break; - } - case 18: { - Message = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class SayResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SayResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayResponse(SayResponse other) : this() { - userName_ = other.userName_; - message_ = other.message_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public SayResponse Clone() { - return new SayResponse(this); - } - - /// Field number for the "UserName" field. - public const int UserNameFieldNumber = 1; - private string userName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string UserName { - get { return userName_; } - set { - userName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "Message" field. - public const int MessageFieldNumber = 2; - private string message_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Message { - get { return message_; } - set { - message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as SayResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(SayResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (UserName != other.UserName) return false; - if (Message != other.Message) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (UserName.Length != 0) hash ^= UserName.GetHashCode(); - if (Message.Length != 0) hash ^= Message.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (UserName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(UserName); - } - if (Message.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Message); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (UserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(UserName); - } - if (Message.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(SayResponse other) { - if (other == null) { - return; - } - if (other.UserName.Length != 0) { - UserName = other.UserName; - } - if (other.Message.Length != 0) { - Message = other.Message; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - UserName = input.ReadString(); - break; - } - case 18: { - Message = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class NickRequest : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NickRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[4]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickRequest() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickRequest(NickRequest other) : this() { - oldUserName_ = other.oldUserName_; - newUserName_ = other.newUserName_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickRequest Clone() { - return new NickRequest(this); - } - - /// Field number for the "OldUserName" field. - public const int OldUserNameFieldNumber = 1; - private string oldUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OldUserName { - get { return oldUserName_; } - set { - oldUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "NewUserName" field. - public const int NewUserNameFieldNumber = 2; - private string newUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string NewUserName { - get { return newUserName_; } - set { - newUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as NickRequest); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(NickRequest other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (OldUserName != other.OldUserName) return false; - if (NewUserName != other.NewUserName) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (OldUserName.Length != 0) hash ^= OldUserName.GetHashCode(); - if (NewUserName.Length != 0) hash ^= NewUserName.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (OldUserName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(OldUserName); - } - if (NewUserName.Length != 0) { - output.WriteRawTag(18); - output.WriteString(NewUserName); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (OldUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(OldUserName); - } - if (NewUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(NewUserName); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(NickRequest other) { - if (other == null) { - return; - } - if (other.OldUserName.Length != 0) { - OldUserName = other.OldUserName; - } - if (other.NewUserName.Length != 0) { - NewUserName = other.NewUserName; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - OldUserName = input.ReadString(); - break; - } - case 18: { - NewUserName = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class NickResponse : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NickResponse()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[5]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickResponse() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickResponse(NickResponse other) : this() { - oldUserName_ = other.oldUserName_; - newUserName_ = other.newUserName_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public NickResponse Clone() { - return new NickResponse(this); - } - - /// Field number for the "OldUserName" field. - public const int OldUserNameFieldNumber = 1; - private string oldUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string OldUserName { - get { return oldUserName_; } - set { - oldUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "NewUserName" field. - public const int NewUserNameFieldNumber = 2; - private string newUserName_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string NewUserName { - get { return newUserName_; } - set { - newUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as NickResponse); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(NickResponse other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (OldUserName != other.OldUserName) return false; - if (NewUserName != other.NewUserName) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (OldUserName.Length != 0) hash ^= OldUserName.GetHashCode(); - if (NewUserName.Length != 0) hash ^= NewUserName.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (OldUserName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(OldUserName); - } - if (NewUserName.Length != 0) { - output.WriteRawTag(18); - output.WriteString(NewUserName); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (OldUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(OldUserName); - } - if (NewUserName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(NewUserName); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(NickResponse other) { - if (other == null) { - return; - } - if (other.OldUserName.Length != 0) { - OldUserName = other.OldUserName; - } - if (other.NewUserName.Length != 0) { - NewUserName = other.NewUserName; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - OldUserName = input.ReadString(); - break; - } - case 18: { - NewUserName = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Chat.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace chat.messages { + + /// Holder for reflection information generated from Chat.proto + public static partial class ChatReflection { + + #region Descriptor + /// File descriptor for Chat.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ChatReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgpDaGF0LnByb3RvEg1jaGF0Lm1lc3NhZ2VzGhhQcm90by5BY3Rvci9Qcm90", + "b3MucHJvdG8iJQoHQ29ubmVjdBIaCgZTZW5kZXIYASABKAsyCi5hY3Rvci5Q", + "SUQiHAoJQ29ubmVjdGVkEg8KB01lc3NhZ2UYASABKAkiLwoKU2F5UmVxdWVz", + "dBIQCghVc2VyTmFtZRgBIAEoCRIPCgdNZXNzYWdlGAIgASgJIjAKC1NheVJl", + "c3BvbnNlEhAKCFVzZXJOYW1lGAEgASgJEg8KB01lc3NhZ2UYAiABKAkiNwoL", + "Tmlja1JlcXVlc3QSEwoLT2xkVXNlck5hbWUYASABKAkSEwoLTmV3VXNlck5h", + "bWUYAiABKAkiOAoMTmlja1Jlc3BvbnNlEhMKC09sZFVzZXJOYW1lGAEgASgJ", + "EhMKC05ld1VzZXJOYW1lGAIgASgJQhCqAg1jaGF0Lm1lc3NhZ2VzYgZwcm90", + "bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Proto.ProtosReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.Connect), global::chat.messages.Connect.Parser, new[]{ "Sender" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.Connected), global::chat.messages.Connected.Parser, new[]{ "Message" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.SayRequest), global::chat.messages.SayRequest.Parser, new[]{ "UserName", "Message" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.SayResponse), global::chat.messages.SayResponse.Parser, new[]{ "UserName", "Message" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.NickRequest), global::chat.messages.NickRequest.Parser, new[]{ "OldUserName", "NewUserName" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::chat.messages.NickResponse), global::chat.messages.NickResponse.Parser, new[]{ "OldUserName", "NewUserName" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Connect : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Connect()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connect() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connect(Connect other) : this() { + Sender = other.sender_ != null ? other.Sender.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connect Clone() { + return new Connect(this); + } + + /// Field number for the "Sender" field. + public const int SenderFieldNumber = 1; + private global::Proto.PID sender_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Proto.PID Sender { + get { return sender_; } + set { + sender_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Connect); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Connect other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Sender, other.Sender)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (sender_ != null) hash ^= Sender.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (sender_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Sender); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (sender_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sender); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Connect other) { + if (other == null) { + return; + } + if (other.sender_ != null) { + if (sender_ == null) { + sender_ = new global::Proto.PID(); + } + Sender.MergeFrom(other.Sender); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (sender_ == null) { + sender_ = new global::Proto.PID(); + } + input.ReadMessage(sender_); + break; + } + } + } + } + + } + + public sealed partial class Connected : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Connected()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connected() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connected(Connected other) : this() { + message_ = other.message_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Connected Clone() { + return new Connected(this); + } + + /// Field number for the "Message" field. + public const int MessageFieldNumber = 1; + private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Message { + get { return message_; } + set { + message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Connected); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Connected other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Message != other.Message) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Message.Length != 0) hash ^= Message.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Message.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Message); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Message.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Connected other) { + if (other == null) { + return; + } + if (other.Message.Length != 0) { + Message = other.Message; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Message = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class SayRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SayRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayRequest(SayRequest other) : this() { + userName_ = other.userName_; + message_ = other.message_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayRequest Clone() { + return new SayRequest(this); + } + + /// Field number for the "UserName" field. + public const int UserNameFieldNumber = 1; + private string userName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string UserName { + get { return userName_; } + set { + userName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Message" field. + public const int MessageFieldNumber = 2; + private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Message { + get { return message_; } + set { + message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SayRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SayRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (UserName != other.UserName) return false; + if (Message != other.Message) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (UserName.Length != 0) hash ^= UserName.GetHashCode(); + if (Message.Length != 0) hash ^= Message.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (UserName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(UserName); + } + if (Message.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Message); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (UserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(UserName); + } + if (Message.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SayRequest other) { + if (other == null) { + return; + } + if (other.UserName.Length != 0) { + UserName = other.UserName; + } + if (other.Message.Length != 0) { + Message = other.Message; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + UserName = input.ReadString(); + break; + } + case 18: { + Message = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class SayResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new SayResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayResponse(SayResponse other) : this() { + userName_ = other.userName_; + message_ = other.message_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public SayResponse Clone() { + return new SayResponse(this); + } + + /// Field number for the "UserName" field. + public const int UserNameFieldNumber = 1; + private string userName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string UserName { + get { return userName_; } + set { + userName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Message" field. + public const int MessageFieldNumber = 2; + private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Message { + get { return message_; } + set { + message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as SayResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(SayResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (UserName != other.UserName) return false; + if (Message != other.Message) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (UserName.Length != 0) hash ^= UserName.GetHashCode(); + if (Message.Length != 0) hash ^= Message.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (UserName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(UserName); + } + if (Message.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Message); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (UserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(UserName); + } + if (Message.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(SayResponse other) { + if (other == null) { + return; + } + if (other.UserName.Length != 0) { + UserName = other.UserName; + } + if (other.Message.Length != 0) { + Message = other.Message; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + UserName = input.ReadString(); + break; + } + case 18: { + Message = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class NickRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NickRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickRequest(NickRequest other) : this() { + oldUserName_ = other.oldUserName_; + newUserName_ = other.newUserName_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickRequest Clone() { + return new NickRequest(this); + } + + /// Field number for the "OldUserName" field. + public const int OldUserNameFieldNumber = 1; + private string oldUserName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OldUserName { + get { return oldUserName_; } + set { + oldUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "NewUserName" field. + public const int NewUserNameFieldNumber = 2; + private string newUserName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NewUserName { + get { return newUserName_; } + set { + newUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NickRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NickRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (OldUserName != other.OldUserName) return false; + if (NewUserName != other.NewUserName) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (OldUserName.Length != 0) hash ^= OldUserName.GetHashCode(); + if (NewUserName.Length != 0) hash ^= NewUserName.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (OldUserName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(OldUserName); + } + if (NewUserName.Length != 0) { + output.WriteRawTag(18); + output.WriteString(NewUserName); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (OldUserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OldUserName); + } + if (NewUserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NewUserName); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NickRequest other) { + if (other == null) { + return; + } + if (other.OldUserName.Length != 0) { + OldUserName = other.OldUserName; + } + if (other.NewUserName.Length != 0) { + NewUserName = other.NewUserName; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + OldUserName = input.ReadString(); + break; + } + case 18: { + NewUserName = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class NickResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new NickResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::chat.messages.ChatReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickResponse(NickResponse other) : this() { + oldUserName_ = other.oldUserName_; + newUserName_ = other.newUserName_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public NickResponse Clone() { + return new NickResponse(this); + } + + /// Field number for the "OldUserName" field. + public const int OldUserNameFieldNumber = 1; + private string oldUserName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string OldUserName { + get { return oldUserName_; } + set { + oldUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "NewUserName" field. + public const int NewUserNameFieldNumber = 2; + private string newUserName_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string NewUserName { + get { return newUserName_; } + set { + newUserName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as NickResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(NickResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (OldUserName != other.OldUserName) return false; + if (NewUserName != other.NewUserName) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (OldUserName.Length != 0) hash ^= OldUserName.GetHashCode(); + if (NewUserName.Length != 0) hash ^= NewUserName.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (OldUserName.Length != 0) { + output.WriteRawTag(10); + output.WriteString(OldUserName); + } + if (NewUserName.Length != 0) { + output.WriteRawTag(18); + output.WriteString(NewUserName); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (OldUserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(OldUserName); + } + if (NewUserName.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(NewUserName); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(NickResponse other) { + if (other == null) { + return; + } + if (other.OldUserName.Length != 0) { + OldUserName = other.OldUserName; + } + if (other.NewUserName.Length != 0) { + NewUserName = other.NewUserName; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + OldUserName = input.ReadString(); + break; + } + case 18: { + NewUserName = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/examples/Chat/Messages/Chat.proto b/examples/Chat/Messages/Chat.proto index cd2fbba394..1dfdae00f6 100644 --- a/examples/Chat/Messages/Chat.proto +++ b/examples/Chat/Messages/Chat.proto @@ -1,33 +1,33 @@ -syntax = "proto3"; -package chat.messages; -option csharp_namespace = "chat.messages"; -import "Proto.Actor/Protos.proto"; - -message Connect -{ - actor.PID Sender = 1; -} - -message Connected { - string Message = 1; -} - -message SayRequest { - string UserName = 1; - string Message = 2; -} - -message SayResponse { - string UserName = 1; - string Message = 2; -} - -message NickRequest { - string OldUserName = 1; - string NewUserName = 2; -} - -message NickResponse { - string OldUserName = 1; - string NewUserName = 2; +syntax = "proto3"; +package chat.messages; +option csharp_namespace = "chat.messages"; +import "Proto.Actor/Protos.proto"; + +message Connect +{ + actor.PID Sender = 1; +} + +message Connected { + string Message = 1; +} + +message SayRequest { + string UserName = 1; + string Message = 2; +} + +message SayResponse { + string UserName = 1; + string Message = 2; +} + +message NickRequest { + string OldUserName = 1; + string NewUserName = 2; +} + +message NickResponse { + string OldUserName = 1; + string NewUserName = 2; } \ No newline at end of file diff --git a/examples/Chat/Server/Program.cs b/examples/Chat/Server/Program.cs index 21da36a010..d7e5f81cd1 100644 --- a/examples/Chat/Server/Program.cs +++ b/examples/Chat/Server/Program.cs @@ -1,49 +1,49 @@ -using System; -using System.Collections.Generic; -using chat.messages; -using Proto; -using Proto.Remote; - -class Program -{ - static void Main(string[] args) - { - Serialization.RegisterFileDescriptor(ChatReflection.Descriptor); - RemotingSystem.Start("127.0.0.1", 8000); - var clients = new HashSet(); - var props = Actor.FromFunc(ctx => - { - switch (ctx.Message) - { - case Connect connect: - Console.WriteLine($"Client {connect.Sender} connected"); - clients.Add(connect.Sender); - connect.Sender.Tell(new Connected { Message = "Welcome!"}); - break; - case SayRequest sayRequest: - foreach (var client in clients) - { - client.Tell(new SayResponse - { - UserName = sayRequest.UserName, - Message = sayRequest.Message - }); - } - break; - case NickRequest nickRequest: - foreach (var client in clients) - { - client.Tell(new NickResponse - { - OldUserName = nickRequest.OldUserName, - NewUserName = nickRequest.NewUserName - }); - } - break; - } - return Actor.Done; - }); - Actor.SpawnNamed(props, "chatserver"); - Console.ReadLine(); - } +using System; +using System.Collections.Generic; +using chat.messages; +using Proto; +using Proto.Remote; + +class Program +{ + static void Main(string[] args) + { + Serialization.RegisterFileDescriptor(ChatReflection.Descriptor); + RemotingSystem.Start("127.0.0.1", 8000); + var clients = new HashSet(); + var props = Actor.FromFunc(ctx => + { + switch (ctx.Message) + { + case Connect connect: + Console.WriteLine($"Client {connect.Sender} connected"); + clients.Add(connect.Sender); + connect.Sender.Tell(new Connected { Message = "Welcome!"}); + break; + case SayRequest sayRequest: + foreach (var client in clients) + { + client.Tell(new SayResponse + { + UserName = sayRequest.UserName, + Message = sayRequest.Message + }); + } + break; + case NickRequest nickRequest: + foreach (var client in clients) + { + client.Tell(new NickResponse + { + OldUserName = nickRequest.OldUserName, + NewUserName = nickRequest.NewUserName + }); + } + break; + } + return Actor.Done; + }); + Actor.SpawnNamed(props, "chatserver"); + Console.ReadLine(); + } } \ No newline at end of file diff --git a/examples/Chat/Server/Server.csproj b/examples/Chat/Server/Server.csproj index fd1d6a3f03..d174a89c13 100644 --- a/examples/Chat/Server/Server.csproj +++ b/examples/Chat/Server/Server.csproj @@ -1,15 +1,15 @@ - - - Exe - netcoreapp1.1 - - - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + + + \ No newline at end of file diff --git a/examples/Futures/Futures.csproj b/examples/Futures/Futures.csproj index 1739415973..fe2117901c 100644 --- a/examples/Futures/Futures.csproj +++ b/examples/Futures/Futures.csproj @@ -1,10 +1,10 @@ - - - Exe - netcoreapp1.1 - - - - - + + + Exe + netcoreapp1.1 + + + + + \ No newline at end of file diff --git a/examples/Futures/Program.cs b/examples/Futures/Program.cs index 2486e654e8..6d5b850561 100644 --- a/examples/Futures/Program.cs +++ b/examples/Futures/Program.cs @@ -1,27 +1,27 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Proto; - -class Program -{ - static void Main(string[] args) - { - var props = Actor.FromFunc(ctx => - { - if (ctx.Message is string) - { - ctx.Respond("hey"); - } - return Actor.Done; - }); - var pid = Actor.Spawn(props); - - var reply = pid.RequestAsync("hello").Result; - Console.WriteLine(reply); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Proto; + +class Program +{ + static void Main(string[] args) + { + var props = Actor.FromFunc(ctx => + { + if (ctx.Message is string) + { + ctx.Respond("hey"); + } + return Actor.Done; + }); + var pid = Actor.Spawn(props); + + var reply = pid.RequestAsync("hello").Result; + Console.WriteLine(reply); + } } \ No newline at end of file diff --git a/examples/HelloWorld/HelloWorld.csproj b/examples/HelloWorld/HelloWorld.csproj index 3266302fa0..5a710ef17b 100644 --- a/examples/HelloWorld/HelloWorld.csproj +++ b/examples/HelloWorld/HelloWorld.csproj @@ -1,10 +1,10 @@ - - - Exe - netcoreapp1.1 - - - - - + + + Exe + netcoreapp1.1 + + + + + \ No newline at end of file diff --git a/examples/HelloWorld/Program.cs b/examples/HelloWorld/Program.cs index 799d9b1437..e771a04d6f 100644 --- a/examples/HelloWorld/Program.cs +++ b/examples/HelloWorld/Program.cs @@ -1,41 +1,41 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; -using Proto; - -class Program -{ - static void Main(string[] args) - { - var props = Actor.FromProducer(() => new HelloActor()); - var pid = Actor.Spawn(props); - pid.Tell(new Hello - { - Who = "Alex" - }); - Console.ReadLine(); - } - - internal class Hello - { - public string Who; - } - - internal class HelloActor : IActor - { - public Task ReceiveAsync(IContext context) - { - var msg = context.Message; - if (msg is Hello r) - { - Console.WriteLine($"Hello {r.Who}"); - } - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; +using Proto; + +class Program +{ + static void Main(string[] args) + { + var props = Actor.FromProducer(() => new HelloActor()); + var pid = Actor.Spawn(props); + pid.Tell(new Hello + { + Who = "Alex" + }); + Console.ReadLine(); + } + + internal class Hello + { + public string Who; + } + + internal class HelloActor : IActor + { + public Task ReceiveAsync(IContext context) + { + var msg = context.Message; + if (msg is Hello r) + { + Console.WriteLine($"Hello {r.Who}"); + } + return Actor.Done; + } + } } \ No newline at end of file diff --git a/examples/InprocessBenchmark/InprocessBenchmark.csproj b/examples/InprocessBenchmark/InprocessBenchmark.csproj index ec4d998c32..eaec561ccd 100644 --- a/examples/InprocessBenchmark/InprocessBenchmark.csproj +++ b/examples/InprocessBenchmark/InprocessBenchmark.csproj @@ -1,13 +1,13 @@ - - - Exe - netcoreapp1.1 - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + \ No newline at end of file diff --git a/examples/InprocessBenchmark/Program.cs b/examples/InprocessBenchmark/Program.cs index aac73bc05c..5249e721eb 100644 --- a/examples/InprocessBenchmark/Program.cs +++ b/examples/InprocessBenchmark/Program.cs @@ -1,157 +1,157 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Diagnostics; -using System.Linq; -using System.Runtime; -using System.Threading; -using System.Threading.Tasks; -using Proto; -using Proto.Mailbox; - -class Program -{ - static void Main(string[] args) - { - Console.WriteLine($"Is Server GC {GCSettings.IsServerGC}"); - const int messageCount = 1000000; - const int batchSize = 100; - - Console.WriteLine("Dispatcher\t\tElapsed\t\tMsg/sec"); - var tps = new[] {300, 400, 500, 600, 700, 800, 900}; - foreach (var t in tps) - { - var d = new ThreadPoolDispatcher {Throughput = t}; - - var clientCount = Environment.ProcessorCount * 2; - var clients = new PID[clientCount]; - var echos = new PID[clientCount]; - var completions = new TaskCompletionSource[clientCount]; - - - var echoProps = Actor.FromFunc(ctx => - { - switch (ctx.Message) - { - case Msg msg: - msg.Sender.Tell(msg); - break; - } - return Actor.Done; - }).WithDispatcher(d); - - for (var i = 0; i < clientCount; i++) - { - var tsc = new TaskCompletionSource(); - completions[i] = tsc; - var clientProps = Actor.FromProducer(() => new PingActor(tsc, messageCount, batchSize)) - .WithDispatcher(d); - - clients[i] = Actor.Spawn(clientProps); - echos[i] = Actor.Spawn(echoProps); - } - var tasks = completions.Select(tsc => tsc.Task).ToArray(); - var sw = Stopwatch.StartNew(); - for (var i = 0; i < clientCount; i++) - { - var client = clients[i]; - var echo = echos[i]; - - client.Tell(new Start(echo)); - } - Task.WaitAll(tasks); - - sw.Stop(); - var totalMessages = messageCount * 2 * clientCount; - - var x = (int) (totalMessages / (double) sw.ElapsedMilliseconds * 1000.0d); - Console.WriteLine($"{t}\t\t\t{sw.ElapsedMilliseconds}\t\t{x}"); - Thread.Sleep(2000); - } - - Console.ReadLine(); - } - - public class Msg - { - public Msg(PID sender) - { - Sender = sender; - } - - public PID Sender { get; } - } - - public class Start - { - public Start(PID sender) - { - Sender = sender; - } - - public PID Sender { get; } - } - - - public class PingActor : IActor - { - private readonly int _batchSize; - private readonly TaskCompletionSource _wgStop; - private int _batch; - private int _messageCount; - - public PingActor(TaskCompletionSource wgStop, int messageCount, int batchSize) - { - _wgStop = wgStop; - _messageCount = messageCount; - _batchSize = batchSize; - } - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case Start s: - SendBatch(context, s.Sender); - break; - case Msg m: - _batch--; - - if (_batch > 0) - { - break; - } - - if (!SendBatch(context, m.Sender)) - { - _wgStop.SetResult(true); - } - break; - } - return Actor.Done; - } - - private bool SendBatch(IContext context, PID sender) - { - if (_messageCount == 0) - { - return false; - } - - var m = new Msg(context.Self); - - for (var i = 0; i < _batchSize; i++) - { - sender.Tell(m); - } - - _messageCount -= _batchSize; - _batch = _batchSize; - return true; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Diagnostics; +using System.Linq; +using System.Runtime; +using System.Threading; +using System.Threading.Tasks; +using Proto; +using Proto.Mailbox; + +class Program +{ + static void Main(string[] args) + { + Console.WriteLine($"Is Server GC {GCSettings.IsServerGC}"); + const int messageCount = 1000000; + const int batchSize = 100; + + Console.WriteLine("Dispatcher\t\tElapsed\t\tMsg/sec"); + var tps = new[] {300, 400, 500, 600, 700, 800, 900}; + foreach (var t in tps) + { + var d = new ThreadPoolDispatcher {Throughput = t}; + + var clientCount = Environment.ProcessorCount * 2; + var clients = new PID[clientCount]; + var echos = new PID[clientCount]; + var completions = new TaskCompletionSource[clientCount]; + + + var echoProps = Actor.FromFunc(ctx => + { + switch (ctx.Message) + { + case Msg msg: + msg.Sender.Tell(msg); + break; + } + return Actor.Done; + }).WithDispatcher(d); + + for (var i = 0; i < clientCount; i++) + { + var tsc = new TaskCompletionSource(); + completions[i] = tsc; + var clientProps = Actor.FromProducer(() => new PingActor(tsc, messageCount, batchSize)) + .WithDispatcher(d); + + clients[i] = Actor.Spawn(clientProps); + echos[i] = Actor.Spawn(echoProps); + } + var tasks = completions.Select(tsc => tsc.Task).ToArray(); + var sw = Stopwatch.StartNew(); + for (var i = 0; i < clientCount; i++) + { + var client = clients[i]; + var echo = echos[i]; + + client.Tell(new Start(echo)); + } + Task.WaitAll(tasks); + + sw.Stop(); + var totalMessages = messageCount * 2 * clientCount; + + var x = (int) (totalMessages / (double) sw.ElapsedMilliseconds * 1000.0d); + Console.WriteLine($"{t}\t\t\t{sw.ElapsedMilliseconds}\t\t{x}"); + Thread.Sleep(2000); + } + + Console.ReadLine(); + } + + public class Msg + { + public Msg(PID sender) + { + Sender = sender; + } + + public PID Sender { get; } + } + + public class Start + { + public Start(PID sender) + { + Sender = sender; + } + + public PID Sender { get; } + } + + + public class PingActor : IActor + { + private readonly int _batchSize; + private readonly TaskCompletionSource _wgStop; + private int _batch; + private int _messageCount; + + public PingActor(TaskCompletionSource wgStop, int messageCount, int batchSize) + { + _wgStop = wgStop; + _messageCount = messageCount; + _batchSize = batchSize; + } + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case Start s: + SendBatch(context, s.Sender); + break; + case Msg m: + _batch--; + + if (_batch > 0) + { + break; + } + + if (!SendBatch(context, m.Sender)) + { + _wgStop.SetResult(true); + } + break; + } + return Actor.Done; + } + + private bool SendBatch(IContext context, PID sender) + { + if (_messageCount == 0) + { + return false; + } + + var m = new Msg(context.Self); + + for (var i = 0; i < _batchSize; i++) + { + sender.Tell(m); + } + + _messageCount -= _batchSize; + _batch = _batchSize; + return true; + } + } } \ No newline at end of file diff --git a/examples/InprocessBenchmark/runtimeconfig.template.json b/examples/InprocessBenchmark/runtimeconfig.template.json index ab9ecca168..0881eab7c0 100644 --- a/examples/InprocessBenchmark/runtimeconfig.template.json +++ b/examples/InprocessBenchmark/runtimeconfig.template.json @@ -1,6 +1,6 @@ -{ - "configProperties": { - "System.GC.Server": true, - "System.GC.Concurrent": true - } +{ + "configProperties": { + "System.GC.Server": true, + "System.GC.Concurrent": true + } } \ No newline at end of file diff --git a/examples/Labb/App.config b/examples/Labb/App.config index 88fa4027bd..d740e88600 100644 --- a/examples/Labb/App.config +++ b/examples/Labb/App.config @@ -1,6 +1,6 @@ - - - - - + + + + + \ No newline at end of file diff --git a/examples/Labb/Labb.csproj b/examples/Labb/Labb.csproj index f269bd1504..39e4940e4d 100644 --- a/examples/Labb/Labb.csproj +++ b/examples/Labb/Labb.csproj @@ -1,66 +1,66 @@ - - - - - Debug - AnyCPU - {ABADF472-0EDE-4EC0-8AC1-B8612EFF76FE} - Exe - Properties - Labb - Labb - v4.5.2 - 512 - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - - - - - - - - - - - - - - - - - - {c036f196-0aa6-4c3d-b340-93a922461b54} - GAM - - - - + + + + + Debug + AnyCPU + {ABADF472-0EDE-4EC0-8AC1-B8612EFF76FE} + Exe + Properties + Labb + Labb + v4.5.2 + 512 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + {c036f196-0aa6-4c3d-b340-93a922461b54} + GAM + + + + \ No newline at end of file diff --git a/examples/Labb/Program.cs b/examples/Labb/Program.cs index dc5b5d8545..957446eb99 100644 --- a/examples/Labb/Program.cs +++ b/examples/Labb/Program.cs @@ -1,32 +1,32 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; -using GAM; - -namespace Labb -{ - public class TheActor : IActor - { - public Task ReceiveAsync(IContext ctx) - { - Console.WriteLine(ctx.Message); - return Task.FromResult(0); - } - } - - class Program - { - static void Main(string[] args) - { - var props = Actor.FromProducer(() => new TheActor()); - var a = Actor.Spawn(props); - a.Tell("Hello"); - Console.ReadLine(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; +using GAM; + +namespace Labb +{ + public class TheActor : IActor + { + public Task ReceiveAsync(IContext ctx) + { + Console.WriteLine(ctx.Message); + return Task.FromResult(0); + } + } + + class Program + { + static void Main(string[] args) + { + var props = Actor.FromProducer(() => new TheActor()); + var a = Actor.Spawn(props); + a.Tell("Hello"); + Console.ReadLine(); + } + } } \ No newline at end of file diff --git a/examples/Labb/Properties/AssemblyInfo.cs b/examples/Labb/Properties/AssemblyInfo.cs index 8bb5293693..066451f040 100644 --- a/examples/Labb/Properties/AssemblyInfo.cs +++ b/examples/Labb/Properties/AssemblyInfo.cs @@ -1,45 +1,45 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Reflection; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitle("Labb")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("Labb")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. - -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM - -[assembly: Guid("abadf472-0ede-4ec0-8ac1-b8612eff76fe")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] - -[assembly: AssemblyVersion("1.0.0.0")] +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("Labb")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Labb")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("abadf472-0ede-4ec0-8ac1-b8612eff76fe")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] + +[assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] \ No newline at end of file diff --git a/examples/MailboxBenchmark/MailboxBenchmark.csproj b/examples/MailboxBenchmark/MailboxBenchmark.csproj index 1739415973..fe2117901c 100644 --- a/examples/MailboxBenchmark/MailboxBenchmark.csproj +++ b/examples/MailboxBenchmark/MailboxBenchmark.csproj @@ -1,10 +1,10 @@ - - - Exe - netcoreapp1.1 - - - - - + + + Exe + netcoreapp1.1 + + + + + \ No newline at end of file diff --git a/examples/MailboxBenchmark/Program.cs b/examples/MailboxBenchmark/Program.cs index e33d9f4250..24b0e2d377 100644 --- a/examples/MailboxBenchmark/Program.cs +++ b/examples/MailboxBenchmark/Program.cs @@ -1,56 +1,56 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Diagnostics; -using Proto; -using Proto.Mailbox; - -class Program -{ - static void Main(string[] args) - { - Func unboundedMailbox = - () => new DefaultMailbox(new UnboundedMailboxQueue(), new UnboundedMailboxQueue()); - Func boundedMailbox = - () => new DefaultMailbox(new BoundedMailboxQueue(1024 * 1024), new BoundedMailboxQueue(1024 * 1024)); - - RunTest(boundedMailbox, "Bounded mailbox"); - RunTest(unboundedMailbox, "Unbounded mailbox"); - - Console.ReadLine(); - } - - private static void RunTest(Func mailbox, string name) - { - Stopwatch sendSw = new Stopwatch(), recvSw = new Stopwatch(); - const int n = 10 * 1000 * 1000; - var props = Actor.FromFunc(c => - { - switch (c.Message) - { - case int i: - if (i == n) - { - recvSw.Stop(); - Console.WriteLine($"recv {(int) (n / recvSw.Elapsed.TotalSeconds / 1000)}K/sec ({name})"); - } - break; - } - return Actor.Done; - }) - .WithMailbox(mailbox); - var pid = Actor.Spawn(props); - sendSw.Start(); - recvSw.Start(); - for (var i = 1; i <= n; i++) - { - pid.Tell(i); - } - sendSw.Stop(); - Console.WriteLine($"send {(int) (n / sendSw.Elapsed.TotalSeconds / 1000)}K/sec ({name})"); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Diagnostics; +using Proto; +using Proto.Mailbox; + +class Program +{ + static void Main(string[] args) + { + Func unboundedMailbox = + () => new DefaultMailbox(new UnboundedMailboxQueue(), new UnboundedMailboxQueue()); + Func boundedMailbox = + () => new DefaultMailbox(new BoundedMailboxQueue(1024 * 1024), new BoundedMailboxQueue(1024 * 1024)); + + RunTest(boundedMailbox, "Bounded mailbox"); + RunTest(unboundedMailbox, "Unbounded mailbox"); + + Console.ReadLine(); + } + + private static void RunTest(Func mailbox, string name) + { + Stopwatch sendSw = new Stopwatch(), recvSw = new Stopwatch(); + const int n = 10 * 1000 * 1000; + var props = Actor.FromFunc(c => + { + switch (c.Message) + { + case int i: + if (i == n) + { + recvSw.Stop(); + Console.WriteLine($"recv {(int) (n / recvSw.Elapsed.TotalSeconds / 1000)}K/sec ({name})"); + } + break; + } + return Actor.Done; + }) + .WithMailbox(mailbox); + var pid = Actor.Spawn(props); + sendSw.Start(); + recvSw.Start(); + for (var i = 1; i <= n; i++) + { + pid.Tell(i); + } + sendSw.Stop(); + Console.WriteLine($"send {(int) (n / sendSw.Elapsed.TotalSeconds / 1000)}K/sec ({name})"); + } } \ No newline at end of file diff --git a/examples/Middleware/Middleware.csproj b/examples/Middleware/Middleware.csproj index 1739415973..fe2117901c 100644 --- a/examples/Middleware/Middleware.csproj +++ b/examples/Middleware/Middleware.csproj @@ -1,10 +1,10 @@ - - - Exe - netcoreapp1.1 - - - - - + + + Exe + netcoreapp1.1 + + + + + \ No newline at end of file diff --git a/examples/Middleware/Program.cs b/examples/Middleware/Program.cs index 17d4326558..f038178ec4 100644 --- a/examples/Middleware/Program.cs +++ b/examples/Middleware/Program.cs @@ -1,39 +1,39 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Proto; - -class Program -{ - static void Main(string[] args) - { - var actor = Actor.FromFunc(c => - { - Console.WriteLine($"actor got {c.Message.GetType()}:{c.Message}"); - return Actor.Done; - }) - .WithMiddleware( - next => async c => - { - Console.WriteLine($"middleware 1 enter {c.Message.GetType()}:{c.Message}"); - await next(c); - Console.WriteLine($"middleware 1 exit"); - }, - next => async c => - { - Console.WriteLine($"middleware 2 enter {c.Message.GetType()}:{c.Message}"); - await next(c); - Console.WriteLine($"middleware 2 exit"); - }); - - var pid = Actor.Spawn(actor); - pid.Tell("hello"); - - Console.ReadLine(); - Console.ReadLine(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Proto; + +class Program +{ + static void Main(string[] args) + { + var actor = Actor.FromFunc(c => + { + Console.WriteLine($"actor got {c.Message.GetType()}:{c.Message}"); + return Actor.Done; + }) + .WithMiddleware( + next => async c => + { + Console.WriteLine($"middleware 1 enter {c.Message.GetType()}:{c.Message}"); + await next(c); + Console.WriteLine($"middleware 1 exit"); + }, + next => async c => + { + Console.WriteLine($"middleware 2 enter {c.Message.GetType()}:{c.Message}"); + await next(c); + Console.WriteLine($"middleware 2 exit"); + }); + + var pid = Actor.Spawn(actor); + pid.Tell("hello"); + + Console.ReadLine(); + Console.ReadLine(); + } } \ No newline at end of file diff --git a/examples/Persistence/Messages/Messages.csproj b/examples/Persistence/Messages/Messages.csproj index 55d0d99c01..8b044e8fc0 100644 --- a/examples/Persistence/Messages/Messages.csproj +++ b/examples/Persistence/Messages/Messages.csproj @@ -1,16 +1,16 @@ - - - netstandard1.6 - - - library - - - - - - - - - + + + netstandard1.6 + + + library + + + + + + + + + \ No newline at end of file diff --git a/examples/Persistence/Messages/Protos.g.cs b/examples/Persistence/Messages/Protos.g.cs index 0bc0a3ef39..561979b92f 100644 --- a/examples/Persistence/Messages/Protos.g.cs +++ b/examples/Persistence/Messages/Protos.g.cs @@ -1,395 +1,395 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Protos.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Messages { - - /// Holder for reflection information generated from Protos.proto - public static partial class ProtosReflection { - - #region Descriptor - /// File descriptor for Protos.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static ProtosReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgxQcm90b3MucHJvdG8SCG1lc3NhZ2VzIh0KDVJlbmFtZUNvbW1hbmQSDAoE", - "bmFtZRgBIAEoCSIbCgtSZW5hbWVFdmVudBIMCgRuYW1lGAEgASgJIhUKBVN0", - "YXRlEgwKBE5hbWUYASABKAlCC6oCCE1lc3NhZ2VzYgZwcm90bzM=")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.RenameCommand), global::Messages.RenameCommand.Parser, new[]{ "Name" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.RenameEvent), global::Messages.RenameEvent.Parser, new[]{ "Name" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.State), global::Messages.State.Parser, new[]{ "Name" }, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class RenameCommand : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RenameCommand()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameCommand() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameCommand(RenameCommand other) : this() { - name_ = other.name_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameCommand Clone() { - return new RenameCommand(this); - } - - /// Field number for the "name" field. - public const int NameFieldNumber = 1; - private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Name { - get { return name_; } - set { - name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as RenameCommand); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(RenameCommand other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Name != other.Name) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Name); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Name.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(RenameCommand other) { - if (other == null) { - return; - } - if (other.Name.Length != 0) { - Name = other.Name; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Name = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class RenameEvent : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RenameEvent()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameEvent() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameEvent(RenameEvent other) : this() { - name_ = other.name_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public RenameEvent Clone() { - return new RenameEvent(this); - } - - /// Field number for the "name" field. - public const int NameFieldNumber = 1; - private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Name { - get { return name_; } - set { - name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as RenameEvent); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(RenameEvent other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Name != other.Name) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Name); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Name.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(RenameEvent other) { - if (other == null) { - return; - } - if (other.Name.Length != 0) { - Name = other.Name; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Name = input.ReadString(); - break; - } - } - } - } - - } - - public sealed partial class State : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new State()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public State() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public State(State other) : this() { - name_ = other.name_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public State Clone() { - return new State(this); - } - - /// Field number for the "Name" field. - public const int NameFieldNumber = 1; - private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Name { - get { return name_; } - set { - name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as State); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(State other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Name != other.Name) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Name.Length != 0) hash ^= Name.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Name.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Name); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Name.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(State other) { - if (other == null) { - return; - } - if (other.Name.Length != 0) { - Name = other.Name; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Name = input.ReadString(); - break; - } - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Protos.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Messages { + + /// Holder for reflection information generated from Protos.proto + public static partial class ProtosReflection { + + #region Descriptor + /// File descriptor for Protos.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ProtosReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgxQcm90b3MucHJvdG8SCG1lc3NhZ2VzIh0KDVJlbmFtZUNvbW1hbmQSDAoE", + "bmFtZRgBIAEoCSIbCgtSZW5hbWVFdmVudBIMCgRuYW1lGAEgASgJIhUKBVN0", + "YXRlEgwKBE5hbWUYASABKAlCC6oCCE1lc3NhZ2VzYgZwcm90bzM=")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.RenameCommand), global::Messages.RenameCommand.Parser, new[]{ "Name" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.RenameEvent), global::Messages.RenameEvent.Parser, new[]{ "Name" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.State), global::Messages.State.Parser, new[]{ "Name" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class RenameCommand : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RenameCommand()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameCommand() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameCommand(RenameCommand other) : this() { + name_ = other.name_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameCommand Clone() { + return new RenameCommand(this); + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RenameCommand); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RenameCommand other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RenameCommand other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class RenameEvent : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RenameEvent()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameEvent() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameEvent(RenameEvent other) : this() { + name_ = other.name_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RenameEvent Clone() { + return new RenameEvent(this); + } + + /// Field number for the "name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RenameEvent); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RenameEvent other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RenameEvent other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class State : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new State()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public State() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public State(State other) : this() { + name_ = other.name_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public State Clone() { + return new State(this); + } + + /// Field number for the "Name" field. + public const int NameFieldNumber = 1; + private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Name { + get { return name_; } + set { + name_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as State); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(State other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Name != other.Name) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Name.Length != 0) hash ^= Name.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Name.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Name); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Name.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Name); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(State other) { + if (other == null) { + return; + } + if (other.Name.Length != 0) { + Name = other.Name; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Name = input.ReadString(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/examples/Persistence/Messages/Protos.proto b/examples/Persistence/Messages/Protos.proto index 9212fd3d8e..e9a4f583b6 100644 --- a/examples/Persistence/Messages/Protos.proto +++ b/examples/Persistence/Messages/Protos.proto @@ -1,13 +1,13 @@ -syntax = "proto3"; -package messages; -option csharp_namespace = "Messages"; - -message RenameCommand { - string name = 1; -} -message RenameEvent { - string name = 1; -} -message State { - string Name = 1; +syntax = "proto3"; +package messages; +option csharp_namespace = "Messages"; + +message RenameCommand { + string name = 1; +} +message RenameEvent { + string name = 1; +} +message State { + string Name = 1; } \ No newline at end of file diff --git a/examples/Persistence/Persistence/Persistence.csproj b/examples/Persistence/Persistence/Persistence.csproj index b266019496..2173546bff 100644 --- a/examples/Persistence/Persistence/Persistence.csproj +++ b/examples/Persistence/Persistence/Persistence.csproj @@ -1,13 +1,13 @@ - - - Exe - netcoreapp1.1 - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + \ No newline at end of file diff --git a/examples/Persistence/Persistence/Program.cs b/examples/Persistence/Persistence/Program.cs index 35fd17d55b..839e97b0e0 100644 --- a/examples/Persistence/Persistence/Program.cs +++ b/examples/Persistence/Persistence/Program.cs @@ -1,100 +1,100 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Couchbase; -using Couchbase.Configuration.Client; -using Couchbase.Core; -using Couchbase.Core.Serialization; -using Messages; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; -using Proto; -using Proto.Persistence; -using Proto.Persistence.Couchbase; - -class Program -{ - static void Main(string[] args) - { - using (var cluster = GetCluster()) - using (var bucket = cluster.OpenBucket("protoactor-test")) - { - var provider = new CouchbaseProvider(bucket, 5); - var props = Actor.FromProducer(() => new MyActor()) - .WithMiddleware(Persistence.Using(provider)); - var pid = Actor.Spawn(props); - pid.Tell(new RenameCommand {Name = "Christian"}); - pid.Tell(new RenameCommand {Name = "Alex"}); - pid.Tell(new RenameCommand {Name = "Roger"}); - Console.WriteLine("Hello World!"); - Console.ReadLine(); - } - } - - private static ICluster GetCluster() - { - var clientDefinition = new CouchbaseClientDefinition - { - Buckets = new List - { - new BucketDefinition - { - Name = "protoactor-test", - ConnectionPool = new ConnectionPoolDefinition - { - EnableTcpKeepAlives = true, - MaxSize = 100, - MinSize = 10 - } - } - }, - Servers = new List - { - new Uri("http://localhost:8091") - } - }; - var jsonSerializerSettings = new JsonSerializerSettings - { - TypeNameHandling = TypeNameHandling.All, - ContractResolver = new CamelCasePropertyNamesContractResolver() - }; - var configuration = new ClientConfiguration(clientDefinition) - { - Serializer = () => new DefaultSerializer(jsonSerializerSettings, jsonSerializerSettings) - }; - return new Cluster(configuration); - } - - class MyActor : IPersistentActor - { - private State _state = new State(); - public Persistence Persistence { get; set; } - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case RenameCommand rc: - Persistence.PersistReceive(new RenameEvent {Name = rc.Name}); - break; - case RenameEvent re: - _state.Name = re.Name; - Console.WriteLine($"{context.Self.Id} changed name to {_state.Name}"); - break; - case RequestSnapshot rs: - Persistence.PersistSnapshot(_state); - break; - case State s: - _state = s; - break; - } - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Couchbase; +using Couchbase.Configuration.Client; +using Couchbase.Core; +using Couchbase.Core.Serialization; +using Messages; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Proto; +using Proto.Persistence; +using Proto.Persistence.Couchbase; + +class Program +{ + static void Main(string[] args) + { + using (var cluster = GetCluster()) + using (var bucket = cluster.OpenBucket("protoactor-test")) + { + var provider = new CouchbaseProvider(bucket, 5); + var props = Actor.FromProducer(() => new MyActor()) + .WithMiddleware(Persistence.Using(provider)); + var pid = Actor.Spawn(props); + pid.Tell(new RenameCommand {Name = "Christian"}); + pid.Tell(new RenameCommand {Name = "Alex"}); + pid.Tell(new RenameCommand {Name = "Roger"}); + Console.WriteLine("Hello World!"); + Console.ReadLine(); + } + } + + private static ICluster GetCluster() + { + var clientDefinition = new CouchbaseClientDefinition + { + Buckets = new List + { + new BucketDefinition + { + Name = "protoactor-test", + ConnectionPool = new ConnectionPoolDefinition + { + EnableTcpKeepAlives = true, + MaxSize = 100, + MinSize = 10 + } + } + }, + Servers = new List + { + new Uri("http://localhost:8091") + } + }; + var jsonSerializerSettings = new JsonSerializerSettings + { + TypeNameHandling = TypeNameHandling.All, + ContractResolver = new CamelCasePropertyNamesContractResolver() + }; + var configuration = new ClientConfiguration(clientDefinition) + { + Serializer = () => new DefaultSerializer(jsonSerializerSettings, jsonSerializerSettings) + }; + return new Cluster(configuration); + } + + class MyActor : IPersistentActor + { + private State _state = new State(); + public Persistence Persistence { get; set; } + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case RenameCommand rc: + Persistence.PersistReceive(new RenameEvent {Name = rc.Name}); + break; + case RenameEvent re: + _state.Name = re.Name; + Console.WriteLine($"{context.Self.Id} changed name to {_state.Name}"); + break; + case RequestSnapshot rs: + Persistence.PersistSnapshot(_state); + break; + case State s: + _state = s; + break; + } + return Actor.Done; + } + } } \ No newline at end of file diff --git a/examples/ReceiveTimeout/Program.cs b/examples/ReceiveTimeout/Program.cs index 809f5c56f2..49aedfefc1 100644 --- a/examples/ReceiveTimeout/Program.cs +++ b/examples/ReceiveTimeout/Program.cs @@ -1,65 +1,65 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading; -using Proto; - -class Program -{ - static void Main(string[] args) - { - var c = 0; - var props = Actor.FromFunc(context => - { - switch (context.Message) - { - case Started _: - Console.WriteLine($"{DateTime.Now} Started"); - context.SetReceiveTimeout(TimeSpan.FromSeconds(1)); - break; - case ReceiveTimeout _: - c++; - Console.WriteLine($"{DateTime.Now} ReceiveTimeout: {c}"); - break; - case NoInfluence _: - Console.WriteLine($"{DateTime.Now} Received a no-influence message"); - break; - case string s: - Console.WriteLine($"{DateTime.Now} Received message: {s}"); - break; - } - return Actor.Done; - }); - var pid = Actor.Spawn(props); - for (var i = 0; i < 6; i++) - { - pid.Tell("hello"); - Thread.Sleep(500); - } - - Console.WriteLine("Hit [return] to send no-influence messages"); - Console.ReadLine(); - - for (var i = 0; i < 6; i++) - { - pid.Tell(new NoInfluence()); - Thread.Sleep(500); - } - - Console.WriteLine("Hit [return] to send a message to cancel the timeout"); - Console.ReadLine(); - - pid.Tell("cancel"); - - Console.WriteLine("Hit [return] to finish"); - Console.ReadLine(); - } -} - -internal class NoInfluence : INotInfluenceReceiveTimeout -{ +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading; +using Proto; + +class Program +{ + static void Main(string[] args) + { + var c = 0; + var props = Actor.FromFunc(context => + { + switch (context.Message) + { + case Started _: + Console.WriteLine($"{DateTime.Now} Started"); + context.SetReceiveTimeout(TimeSpan.FromSeconds(1)); + break; + case ReceiveTimeout _: + c++; + Console.WriteLine($"{DateTime.Now} ReceiveTimeout: {c}"); + break; + case NoInfluence _: + Console.WriteLine($"{DateTime.Now} Received a no-influence message"); + break; + case string s: + Console.WriteLine($"{DateTime.Now} Received message: {s}"); + break; + } + return Actor.Done; + }); + var pid = Actor.Spawn(props); + for (var i = 0; i < 6; i++) + { + pid.Tell("hello"); + Thread.Sleep(500); + } + + Console.WriteLine("Hit [return] to send no-influence messages"); + Console.ReadLine(); + + for (var i = 0; i < 6; i++) + { + pid.Tell(new NoInfluence()); + Thread.Sleep(500); + } + + Console.WriteLine("Hit [return] to send a message to cancel the timeout"); + Console.ReadLine(); + + pid.Tell("cancel"); + + Console.WriteLine("Hit [return] to finish"); + Console.ReadLine(); + } +} + +internal class NoInfluence : INotInfluenceReceiveTimeout +{ } \ No newline at end of file diff --git a/examples/ReceiveTimeout/ReceiveTimeout.csproj b/examples/ReceiveTimeout/ReceiveTimeout.csproj index 1739415973..fe2117901c 100644 --- a/examples/ReceiveTimeout/ReceiveTimeout.csproj +++ b/examples/ReceiveTimeout/ReceiveTimeout.csproj @@ -1,10 +1,10 @@ - - - Exe - netcoreapp1.1 - - - - - + + + Exe + netcoreapp1.1 + + + + + \ No newline at end of file diff --git a/examples/RemoteBenchmark/Messages/Messages.csproj b/examples/RemoteBenchmark/Messages/Messages.csproj index cfe9bef6c3..d0875f0687 100644 --- a/examples/RemoteBenchmark/Messages/Messages.csproj +++ b/examples/RemoteBenchmark/Messages/Messages.csproj @@ -1,20 +1,20 @@ - - - netstandard1.6 - - - library - - - - - - - - - - - - - + + + netstandard1.6 + + + library + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/RemoteBenchmark/Messages/Protos.g.cs b/examples/RemoteBenchmark/Messages/Protos.g.cs index fee44d6488..b00bf1ac51 100644 --- a/examples/RemoteBenchmark/Messages/Protos.g.cs +++ b/examples/RemoteBenchmark/Messages/Protos.g.cs @@ -1,436 +1,436 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Protos.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Messages { - - /// Holder for reflection information generated from Protos.proto - public static partial class ProtosReflection { - - #region Descriptor - /// File descriptor for Protos.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static ProtosReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgxQcm90b3MucHJvdG8SCG1lc3NhZ2VzGhhQcm90by5BY3Rvci9Qcm90b3Mu", - "cHJvdG8iBwoFU3RhcnQiKQoLU3RhcnRSZW1vdGUSGgoGU2VuZGVyGAEgASgL", - "MgouYWN0b3IuUElEIgYKBFBpbmciBgoEUG9uZ0ILqgIITWVzc2FnZXNiBnBy", - "b3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Proto.ProtosReflection.Descriptor, }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Start), global::Messages.Start.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.StartRemote), global::Messages.StartRemote.Parser, new[]{ "Sender" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Ping), global::Messages.Ping.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Pong), global::Messages.Pong.Parser, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class Start : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Start()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Start() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Start(Start other) : this() { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Start Clone() { - return new Start(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Start); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Start other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Start other) { - if (other == null) { - return; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - } - } - } - - } - - public sealed partial class StartRemote : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new StartRemote()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public StartRemote() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public StartRemote(StartRemote other) : this() { - Sender = other.sender_ != null ? other.Sender.Clone() : null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public StartRemote Clone() { - return new StartRemote(this); - } - - /// Field number for the "Sender" field. - public const int SenderFieldNumber = 1; - private global::Proto.PID sender_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Sender { - get { return sender_; } - set { - sender_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as StartRemote); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(StartRemote other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Sender, other.Sender)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (sender_ != null) hash ^= Sender.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (sender_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Sender); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (sender_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sender); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(StartRemote other) { - if (other == null) { - return; - } - if (other.sender_ != null) { - if (sender_ == null) { - sender_ = new global::Proto.PID(); - } - Sender.MergeFrom(other.Sender); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - if (sender_ == null) { - sender_ = new global::Proto.PID(); - } - input.ReadMessage(sender_); - break; - } - } - } - } - - } - - public sealed partial class Ping : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Ping()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Ping() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Ping(Ping other) : this() { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Ping Clone() { - return new Ping(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Ping); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Ping other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Ping other) { - if (other == null) { - return; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - } - } - } - - } - - public sealed partial class Pong : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Pong()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Pong() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Pong(Pong other) : this() { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Pong Clone() { - return new Pong(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Pong); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Pong other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Pong other) { - if (other == null) { - return; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Protos.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Messages { + + /// Holder for reflection information generated from Protos.proto + public static partial class ProtosReflection { + + #region Descriptor + /// File descriptor for Protos.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ProtosReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgxQcm90b3MucHJvdG8SCG1lc3NhZ2VzGhhQcm90by5BY3Rvci9Qcm90b3Mu", + "cHJvdG8iBwoFU3RhcnQiKQoLU3RhcnRSZW1vdGUSGgoGU2VuZGVyGAEgASgL", + "MgouYWN0b3IuUElEIgYKBFBpbmciBgoEUG9uZ0ILqgIITWVzc2FnZXNiBnBy", + "b3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Proto.ProtosReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Start), global::Messages.Start.Parser, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.StartRemote), global::Messages.StartRemote.Parser, new[]{ "Sender" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Ping), global::Messages.Ping.Parser, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Messages.Pong), global::Messages.Pong.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class Start : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Start()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Start() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Start(Start other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Start Clone() { + return new Start(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Start); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Start other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Start other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + public sealed partial class StartRemote : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new StartRemote()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StartRemote() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StartRemote(StartRemote other) : this() { + Sender = other.sender_ != null ? other.Sender.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public StartRemote Clone() { + return new StartRemote(this); + } + + /// Field number for the "Sender" field. + public const int SenderFieldNumber = 1; + private global::Proto.PID sender_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Proto.PID Sender { + get { return sender_; } + set { + sender_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as StartRemote); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(StartRemote other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Sender, other.Sender)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (sender_ != null) hash ^= Sender.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (sender_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Sender); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (sender_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sender); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(StartRemote other) { + if (other == null) { + return; + } + if (other.sender_ != null) { + if (sender_ == null) { + sender_ = new global::Proto.PID(); + } + Sender.MergeFrom(other.Sender); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (sender_ == null) { + sender_ = new global::Proto.PID(); + } + input.ReadMessage(sender_); + break; + } + } + } + } + + } + + public sealed partial class Ping : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Ping()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ping() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ping(Ping other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Ping Clone() { + return new Ping(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Ping); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Ping other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Ping other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + public sealed partial class Pong : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Pong()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Messages.ProtosReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pong() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pong(Pong other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Pong Clone() { + return new Pong(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Pong); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Pong other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Pong other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/examples/RemoteBenchmark/Messages/Protos.proto b/examples/RemoteBenchmark/Messages/Protos.proto index 1ccac50657..805527d221 100644 --- a/examples/RemoteBenchmark/Messages/Protos.proto +++ b/examples/RemoteBenchmark/Messages/Protos.proto @@ -1,11 +1,11 @@ -syntax = "proto3"; -package messages; -option csharp_namespace = "Messages"; -import "Proto.Actor/Protos.proto"; - -message Start {} -message StartRemote { - actor.PID Sender = 1; -} -message Ping {} -message Pong {} +syntax = "proto3"; +package messages; +option csharp_namespace = "Messages"; +import "Proto.Actor/Protos.proto"; + +message Start {} +message StartRemote { + actor.PID Sender = 1; +} +message Ping {} +message Pong {} diff --git a/examples/RemoteBenchmark/Node1/Node1.csproj b/examples/RemoteBenchmark/Node1/Node1.csproj index 6846540bd1..806bdd499e 100644 --- a/examples/RemoteBenchmark/Node1/Node1.csproj +++ b/examples/RemoteBenchmark/Node1/Node1.csproj @@ -1,15 +1,15 @@ - - - Exe - netcoreapp1.1 - - - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + + + \ No newline at end of file diff --git a/examples/RemoteBenchmark/Node1/Program.cs b/examples/RemoteBenchmark/Node1/Program.cs index 8ce237ff44..91d871c4d6 100644 --- a/examples/RemoteBenchmark/Node1/Program.cs +++ b/examples/RemoteBenchmark/Node1/Program.cs @@ -1,81 +1,81 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading; -using System.Threading.Tasks; -using Messages; -using Proto; -using Proto.Remote; -using ProtosReflection = Messages.ProtosReflection; - -class Program -{ - static void Main(string[] args) - { - Serialization.RegisterFileDescriptor(ProtosReflection.Descriptor); - RemotingSystem.Start("127.0.0.1", 12001); - - var messageCount = 1000000; - var wg = new AutoResetEvent(false); - var props = Actor - .FromProducer(() => new LocalActor(0, messageCount, wg)); - - var pid = Actor.Spawn(props); - var remote = new PID("127.0.0.1:12000", "remote"); - remote.RequestAsync(new StartRemote {Sender = pid}).Wait(); - - var start = DateTime.Now; - Console.WriteLine("Starting to send"); - var msg = new Ping(); - for (var i = 0; i < messageCount; i++) - { - remote.Tell(msg); - } - wg.WaitOne(); - var elapsed = DateTime.Now - start; - Console.WriteLine("Elapsed {0}", elapsed); - - var t = messageCount * 2.0 / elapsed.TotalMilliseconds * 1000; - Console.WriteLine("Throughput {0} msg / sec", t); - - Console.ReadLine(); - } - - public class LocalActor : IActor - { - private int _count; - private readonly int _messageCount; - private readonly AutoResetEvent _wg; - - public LocalActor(int count, int messageCount, AutoResetEvent wg) - { - _count = count; - _messageCount = messageCount; - _wg = wg; - } - - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case Pong _: - _count++; - if (_count % 50000 == 0) - { - Console.WriteLine(_count); - } - if (_count == _messageCount) - { - _wg.Set(); - } - break; - } - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading; +using System.Threading.Tasks; +using Messages; +using Proto; +using Proto.Remote; +using ProtosReflection = Messages.ProtosReflection; + +class Program +{ + static void Main(string[] args) + { + Serialization.RegisterFileDescriptor(ProtosReflection.Descriptor); + RemotingSystem.Start("127.0.0.1", 12001); + + var messageCount = 1000000; + var wg = new AutoResetEvent(false); + var props = Actor + .FromProducer(() => new LocalActor(0, messageCount, wg)); + + var pid = Actor.Spawn(props); + var remote = new PID("127.0.0.1:12000", "remote"); + remote.RequestAsync(new StartRemote {Sender = pid}).Wait(); + + var start = DateTime.Now; + Console.WriteLine("Starting to send"); + var msg = new Ping(); + for (var i = 0; i < messageCount; i++) + { + remote.Tell(msg); + } + wg.WaitOne(); + var elapsed = DateTime.Now - start; + Console.WriteLine("Elapsed {0}", elapsed); + + var t = messageCount * 2.0 / elapsed.TotalMilliseconds * 1000; + Console.WriteLine("Throughput {0} msg / sec", t); + + Console.ReadLine(); + } + + public class LocalActor : IActor + { + private int _count; + private readonly int _messageCount; + private readonly AutoResetEvent _wg; + + public LocalActor(int count, int messageCount, AutoResetEvent wg) + { + _count = count; + _messageCount = messageCount; + _wg = wg; + } + + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case Pong _: + _count++; + if (_count % 50000 == 0) + { + Console.WriteLine(_count); + } + if (_count == _messageCount) + { + _wg.Set(); + } + break; + } + return Actor.Done; + } + } } \ No newline at end of file diff --git a/examples/RemoteBenchmark/Node1/runtimeconfig.template.json b/examples/RemoteBenchmark/Node1/runtimeconfig.template.json index ab9ecca168..0881eab7c0 100644 --- a/examples/RemoteBenchmark/Node1/runtimeconfig.template.json +++ b/examples/RemoteBenchmark/Node1/runtimeconfig.template.json @@ -1,6 +1,6 @@ -{ - "configProperties": { - "System.GC.Server": true, - "System.GC.Concurrent": true - } +{ + "configProperties": { + "System.GC.Server": true, + "System.GC.Concurrent": true + } } \ No newline at end of file diff --git a/examples/RemoteBenchmark/Node2/Node2.csproj b/examples/RemoteBenchmark/Node2/Node2.csproj index fa5037e612..5009e6000f 100644 --- a/examples/RemoteBenchmark/Node2/Node2.csproj +++ b/examples/RemoteBenchmark/Node2/Node2.csproj @@ -1,19 +1,19 @@ - - - Exe - netcoreapp1.1 - - - - - - - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/RemoteBenchmark/Node2/Program.cs b/examples/RemoteBenchmark/Node2/Program.cs index 8f833f2ad6..2dbc105bb3 100644 --- a/examples/RemoteBenchmark/Node2/Program.cs +++ b/examples/RemoteBenchmark/Node2/Program.cs @@ -1,48 +1,48 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; -using Messages; -using Proto; -using Proto.Remote; -using ProtosReflection = Messages.ProtosReflection; - -namespace Node2 -{ - public class EchoActor : IActor - { - private PID _sender; - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case StartRemote sr: - Console.WriteLine("Starting"); - _sender = sr.Sender; - context.Respond(new Start()); - return Actor.Done; - case Ping _: - _sender.Tell(new Pong()); - return Actor.Done; - default: - return Actor.Done; - } - } - } - - class Program - { - static void Main(string[] args) - { - Serialization.RegisterFileDescriptor(ProtosReflection.Descriptor); - RemotingSystem.Start("127.0.0.1", 12000); - Actor.SpawnNamed(Actor.FromProducer(() => new EchoActor()), "remote"); - Console.ReadLine(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; +using Messages; +using Proto; +using Proto.Remote; +using ProtosReflection = Messages.ProtosReflection; + +namespace Node2 +{ + public class EchoActor : IActor + { + private PID _sender; + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case StartRemote sr: + Console.WriteLine("Starting"); + _sender = sr.Sender; + context.Respond(new Start()); + return Actor.Done; + case Ping _: + _sender.Tell(new Pong()); + return Actor.Done; + default: + return Actor.Done; + } + } + } + + class Program + { + static void Main(string[] args) + { + Serialization.RegisterFileDescriptor(ProtosReflection.Descriptor); + RemotingSystem.Start("127.0.0.1", 12000); + Actor.SpawnNamed(Actor.FromProducer(() => new EchoActor()), "remote"); + Console.ReadLine(); + } + } } \ No newline at end of file diff --git a/examples/RemoteBenchmark/Node2/runtimeconfig.template.json b/examples/RemoteBenchmark/Node2/runtimeconfig.template.json index ab9ecca168..0881eab7c0 100644 --- a/examples/RemoteBenchmark/Node2/runtimeconfig.template.json +++ b/examples/RemoteBenchmark/Node2/runtimeconfig.template.json @@ -1,6 +1,6 @@ -{ - "configProperties": { - "System.GC.Server": true, - "System.GC.Concurrent": true - } +{ + "configProperties": { + "System.GC.Server": true, + "System.GC.Concurrent": true + } } \ No newline at end of file diff --git a/examples/Router/Program.cs b/examples/Router/Program.cs index b04ab903f9..d6c3f7676a 100644 --- a/examples/Router/Program.cs +++ b/examples/Router/Program.cs @@ -1,167 +1,167 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; -using Proto; -using Proto.Router; - -namespace RouterExample -{ - internal class Message : IHashable - { - public string Text; - - public string HashBy() - { - return Text; - } - - public override string ToString() - { - return Text; - } - } - - internal class MyActor : IActor - { - public Task ReceiveAsync(IContext context) - { - var msg = context.Message as Message; - if (msg != null) - { - Console.WriteLine($"Actor {context.Self.Id} got message '{msg.Text}'."); - } - return Actor.Done; - } - } - - internal class Program - { - private static readonly Props MyActorProps = Actor.FromProducer(() => new MyActor()); - - private static void Main() - { - TestBroadcastPool(); - //TestBroadcastGroup(); - - //TestRandomPool(); - //TestRandomGroup(); - - //TestRoundRobinPool(); - //TestRoundRobinGroup(); - - //TestConsistentHashPool(); - //TestConsistentHashGroup(); - - Console.ReadLine(); - } - - private static void TestBroadcastGroup() - { - var props = Router.NewBroadcastGroup( - MyActorProps, - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps) - ); - for (var i = 0; i < 10; i++) - { - var pid = Actor.Spawn(props); - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestBroadcastPool() - { - var props = Router.NewBroadcastPool(MyActorProps, 5); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestConsistentHashGroup() - { - var props = Router.NewConsistentHashGroup( - MyActorProps, - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps) - ); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestConsistentHashPool() - { - var props = Router.NewConsistentHashPool(MyActorProps, 5); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestRoundRobinGroup() - { - var props = Router.NewRoundRobinGroup( - MyActorProps, - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps) - ); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestRoundRobinPool() - { - var props = Router.NewRoundRobinPool(MyActorProps, 5); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestRandomGroup() - { - var props = Router.NewRandomGroup( - MyActorProps, - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps), - Actor.Spawn(MyActorProps) - ); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - - private static void TestRandomPool() - { - var props = Router.NewRandomPool(MyActorProps, 5); - var pid = Actor.Spawn(props); - for (var i = 0; i < 10; i++) - { - pid.Tell(new Message {Text = $"{i % 4}"}); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; +using Proto; +using Proto.Router; + +namespace RouterExample +{ + internal class Message : IHashable + { + public string Text; + + public string HashBy() + { + return Text; + } + + public override string ToString() + { + return Text; + } + } + + internal class MyActor : IActor + { + public Task ReceiveAsync(IContext context) + { + var msg = context.Message as Message; + if (msg != null) + { + Console.WriteLine($"Actor {context.Self.Id} got message '{msg.Text}'."); + } + return Actor.Done; + } + } + + internal class Program + { + private static readonly Props MyActorProps = Actor.FromProducer(() => new MyActor()); + + private static void Main() + { + TestBroadcastPool(); + //TestBroadcastGroup(); + + //TestRandomPool(); + //TestRandomGroup(); + + //TestRoundRobinPool(); + //TestRoundRobinGroup(); + + //TestConsistentHashPool(); + //TestConsistentHashGroup(); + + Console.ReadLine(); + } + + private static void TestBroadcastGroup() + { + var props = Router.NewBroadcastGroup( + MyActorProps, + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps) + ); + for (var i = 0; i < 10; i++) + { + var pid = Actor.Spawn(props); + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestBroadcastPool() + { + var props = Router.NewBroadcastPool(MyActorProps, 5); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestConsistentHashGroup() + { + var props = Router.NewConsistentHashGroup( + MyActorProps, + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps) + ); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestConsistentHashPool() + { + var props = Router.NewConsistentHashPool(MyActorProps, 5); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestRoundRobinGroup() + { + var props = Router.NewRoundRobinGroup( + MyActorProps, + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps) + ); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestRoundRobinPool() + { + var props = Router.NewRoundRobinPool(MyActorProps, 5); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestRandomGroup() + { + var props = Router.NewRandomGroup( + MyActorProps, + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps), + Actor.Spawn(MyActorProps) + ); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + + private static void TestRandomPool() + { + var props = Router.NewRandomPool(MyActorProps, 5); + var pid = Actor.Spawn(props); + for (var i = 0; i < 10; i++) + { + pid.Tell(new Message {Text = $"{i % 4}"}); + } + } + } } \ No newline at end of file diff --git a/examples/Router/Router.csproj b/examples/Router/Router.csproj index 02d59d3d8e..a30110a9f1 100644 --- a/examples/Router/Router.csproj +++ b/examples/Router/Router.csproj @@ -1,11 +1,11 @@ - - - Exe - netcoreapp1.1 - - - - - - + + + Exe + netcoreapp1.1 + + + + + + \ No newline at end of file diff --git a/examples/SpawnBenchmark/Program.cs b/examples/SpawnBenchmark/Program.cs index 60c01eab38..354fe0a30e 100644 --- a/examples/SpawnBenchmark/Program.cs +++ b/examples/SpawnBenchmark/Program.cs @@ -1,91 +1,91 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Diagnostics; -using System.Runtime; -using System.Threading.Tasks; -using Proto; - -namespace SpawnBenchmark -{ - internal class Request - { - public long Div; - public long Num; - public long Size; - } - - internal class MyActor : IActor - { - public static Props props = Actor.FromProducer(() => new MyActor()); - private long Replies; - private PID ReplyTo; - private long Sum; - - public Task ReceiveAsync(IContext context) - { - var msg = context.Message; - var r = msg as Request; - if (r != null) - { - if (r.Size == 1) - { - context.Respond(r.Num); - context.Self.Stop(); - return Actor.Done; - } - Replies = r.Div; - ReplyTo = context.Sender; - for (var i = 0; i < r.Div; i++) - { - var child = Actor.Spawn(props); - child.Request(new Request - { - Num = r.Num + i * (r.Size / r.Div), - Size = r.Size / r.Div, - Div = r.Div - }, context.Self); - } - - return Actor.Done; - } - if (msg is Int64) - { - Sum += (Int64) msg; - Replies--; - if (Replies == 0) - { - ReplyTo.Tell(Sum); - } - return Actor.Done; - } - return Actor.Done; - } - } - - internal class Program - { - private static void Main() - { - Console.WriteLine($"Is Server GC {GCSettings.IsServerGC}"); - - var pid = Actor.Spawn(MyActor.props); - var sw = Stopwatch.StartNew(); - var t = pid.RequestAsync(new Request - { - Num = 0, - Size = 1000000, - Div = 10 - }); - t.ConfigureAwait(false); - var res = t.Result; - Console.WriteLine(sw.Elapsed); - Console.WriteLine(res); - // Console.ReadLine(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Diagnostics; +using System.Runtime; +using System.Threading.Tasks; +using Proto; + +namespace SpawnBenchmark +{ + internal class Request + { + public long Div; + public long Num; + public long Size; + } + + internal class MyActor : IActor + { + public static Props props = Actor.FromProducer(() => new MyActor()); + private long Replies; + private PID ReplyTo; + private long Sum; + + public Task ReceiveAsync(IContext context) + { + var msg = context.Message; + var r = msg as Request; + if (r != null) + { + if (r.Size == 1) + { + context.Respond(r.Num); + context.Self.Stop(); + return Actor.Done; + } + Replies = r.Div; + ReplyTo = context.Sender; + for (var i = 0; i < r.Div; i++) + { + var child = Actor.Spawn(props); + child.Request(new Request + { + Num = r.Num + i * (r.Size / r.Div), + Size = r.Size / r.Div, + Div = r.Div + }, context.Self); + } + + return Actor.Done; + } + if (msg is Int64) + { + Sum += (Int64) msg; + Replies--; + if (Replies == 0) + { + ReplyTo.Tell(Sum); + } + return Actor.Done; + } + return Actor.Done; + } + } + + internal class Program + { + private static void Main() + { + Console.WriteLine($"Is Server GC {GCSettings.IsServerGC}"); + + var pid = Actor.Spawn(MyActor.props); + var sw = Stopwatch.StartNew(); + var t = pid.RequestAsync(new Request + { + Num = 0, + Size = 1000000, + Div = 10 + }); + t.ConfigureAwait(false); + var res = t.Result; + Console.WriteLine(sw.Elapsed); + Console.WriteLine(res); + // Console.ReadLine(); + } + } } \ No newline at end of file diff --git a/examples/SpawnBenchmark/SpawnBenchmark.csproj b/examples/SpawnBenchmark/SpawnBenchmark.csproj index e178f4fae5..d4e2ee8e84 100644 --- a/examples/SpawnBenchmark/SpawnBenchmark.csproj +++ b/examples/SpawnBenchmark/SpawnBenchmark.csproj @@ -1,17 +1,17 @@ - - - Exe - netcoreapp1.1 - - - - - - - - - - - - + + + Exe + netcoreapp1.1 + + + + + + + + + + + + \ No newline at end of file diff --git a/examples/SpawnBenchmark/runtimeconfig.template.json b/examples/SpawnBenchmark/runtimeconfig.template.json index ab9ecca168..0881eab7c0 100644 --- a/examples/SpawnBenchmark/runtimeconfig.template.json +++ b/examples/SpawnBenchmark/runtimeconfig.template.json @@ -1,6 +1,6 @@ -{ - "configProperties": { - "System.GC.Server": true, - "System.GC.Concurrent": true - } +{ + "configProperties": { + "System.GC.Server": true, + "System.GC.Concurrent": true + } } \ No newline at end of file diff --git a/runtimeconfig.template.dev.json b/runtimeconfig.template.dev.json index ab9ecca168..0881eab7c0 100644 --- a/runtimeconfig.template.dev.json +++ b/runtimeconfig.template.dev.json @@ -1,6 +1,6 @@ -{ - "configProperties": { - "System.GC.Server": true, - "System.GC.Concurrent": true - } +{ + "configProperties": { + "System.GC.Server": true, + "System.GC.Concurrent": true + } } \ No newline at end of file diff --git a/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProvider.cs b/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProvider.cs index 7225aa0f23..3b3a7924aa 100644 --- a/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProvider.cs +++ b/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProvider.cs @@ -1,28 +1,28 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Couchbase.Core; - -namespace Proto.Persistence.Couchbase -{ - public class CouchbaseProvider : IProvider - { - private readonly IBucket _bucket; - - public CouchbaseProvider(IBucket bucket, int snapshotInterval) - { - _bucket = bucket; - SnapshotInterval = snapshotInterval; - } - - public int SnapshotInterval { get; } - - public IProviderState GetState() - { - return new CouchbaseProviderState(_bucket, SnapshotInterval); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Couchbase.Core; + +namespace Proto.Persistence.Couchbase +{ + public class CouchbaseProvider : IProvider + { + private readonly IBucket _bucket; + + public CouchbaseProvider(IBucket bucket, int snapshotInterval) + { + _bucket = bucket; + SnapshotInterval = snapshotInterval; + } + + public int SnapshotInterval { get; } + + public IProviderState GetState() + { + return new CouchbaseProviderState(_bucket, SnapshotInterval); + } + } } \ No newline at end of file diff --git a/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProviderState.cs b/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProviderState.cs index 6a1f37aa03..173a9c2ce9 100644 --- a/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProviderState.cs +++ b/src/PersistenceProviders/Proto.Persistence.Couchbase/CouchbaseProviderState.cs @@ -1,83 +1,83 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Linq; -using Couchbase.Core; -using Couchbase.N1QL; -using Google.Protobuf; - -namespace Proto.Persistence.Couchbase -{ - internal class CouchbaseProviderState : IProviderState - { - private readonly IBucket _bucket; - private readonly int _snapshotInterval; - - public CouchbaseProviderState(IBucket bucket, int snapshotInterval) - { - _bucket = bucket; - _snapshotInterval = snapshotInterval; - } - - public void GetEvents(string actorName, int eventIndexStart, Action callback) - { - var q = - $"SELECT b.* FROM `{_bucket.Name}` b WHERE b.actorName='{actorName}' AND b.eventIndex>={eventIndexStart} AND b.type='event' ORDER BY b.eventIndex ASC"; - var req = QueryRequest.Create(q); - req.ScanConsistency(ScanConsistency.RequestPlus); - var res = _bucket.Query(req); - ThrowOnError(res); - var envelopes = res.Rows; - foreach (var envelope in envelopes) - { - callback(envelope.Event); - } - } - - public Tuple GetSnapshot(string actorName) - { - var q = - $"SELECT b.* FROM `{_bucket.Name}` b WHERE b.actorName={actorName} AND b.type=snapshot ORDER BY b.eventIndex DESC LIMIT 1"; - var req = QueryRequest.Create(q); - req.ScanConsistency(ScanConsistency.RequestPlus); - var res = _bucket.Query(req); - var envelope = res.Rows.FirstOrDefault(); - return envelope != null - ? Tuple.Create((object) envelope.Event, envelope.EventIndex) - : null; - } - - public int GetSnapshotInterval() - { - return _snapshotInterval; - } - - public void PersistEvent(string actorName, int eventIndex, IMessage @event) - { - var envelope = new Envelope(actorName, eventIndex, @event, "event"); - var res = _bucket.Insert(envelope.Key, envelope); - } - - public void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot) - { - var envelope = new Envelope(actorName, eventIndex, snapshot, "snapshot"); - var res = _bucket.Insert(envelope.Key, envelope); - } - - public void Restart() - { - } - - static void ThrowOnError(IQueryResult res) - { - if (!res.Success) - { - throw new Exception($"Couchbase query failed: {res}"); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Linq; +using Couchbase.Core; +using Couchbase.N1QL; +using Google.Protobuf; + +namespace Proto.Persistence.Couchbase +{ + internal class CouchbaseProviderState : IProviderState + { + private readonly IBucket _bucket; + private readonly int _snapshotInterval; + + public CouchbaseProviderState(IBucket bucket, int snapshotInterval) + { + _bucket = bucket; + _snapshotInterval = snapshotInterval; + } + + public void GetEvents(string actorName, int eventIndexStart, Action callback) + { + var q = + $"SELECT b.* FROM `{_bucket.Name}` b WHERE b.actorName='{actorName}' AND b.eventIndex>={eventIndexStart} AND b.type='event' ORDER BY b.eventIndex ASC"; + var req = QueryRequest.Create(q); + req.ScanConsistency(ScanConsistency.RequestPlus); + var res = _bucket.Query(req); + ThrowOnError(res); + var envelopes = res.Rows; + foreach (var envelope in envelopes) + { + callback(envelope.Event); + } + } + + public Tuple GetSnapshot(string actorName) + { + var q = + $"SELECT b.* FROM `{_bucket.Name}` b WHERE b.actorName={actorName} AND b.type=snapshot ORDER BY b.eventIndex DESC LIMIT 1"; + var req = QueryRequest.Create(q); + req.ScanConsistency(ScanConsistency.RequestPlus); + var res = _bucket.Query(req); + var envelope = res.Rows.FirstOrDefault(); + return envelope != null + ? Tuple.Create((object) envelope.Event, envelope.EventIndex) + : null; + } + + public int GetSnapshotInterval() + { + return _snapshotInterval; + } + + public void PersistEvent(string actorName, int eventIndex, IMessage @event) + { + var envelope = new Envelope(actorName, eventIndex, @event, "event"); + var res = _bucket.Insert(envelope.Key, envelope); + } + + public void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot) + { + var envelope = new Envelope(actorName, eventIndex, snapshot, "snapshot"); + var res = _bucket.Insert(envelope.Key, envelope); + } + + public void Restart() + { + } + + static void ThrowOnError(IQueryResult res) + { + if (!res.Success) + { + throw new Exception($"Couchbase query failed: {res}"); + } + } + } } \ No newline at end of file diff --git a/src/PersistenceProviders/Proto.Persistence.Couchbase/Envelope.cs b/src/PersistenceProviders/Proto.Persistence.Couchbase/Envelope.cs index 4a6fcc70b7..7a6efcb38d 100644 --- a/src/PersistenceProviders/Proto.Persistence.Couchbase/Envelope.cs +++ b/src/PersistenceProviders/Proto.Persistence.Couchbase/Envelope.cs @@ -1,31 +1,31 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Google.Protobuf; -using Newtonsoft.Json; - -namespace Proto.Persistence.Couchbase -{ - internal class Envelope - { - public Envelope(string actorName, int eventIndex, IMessage @event, string type) - { - ActorName = actorName; - EventIndex = eventIndex; - Event = @event; - Type = type; - Key = $"{actorName}-event-{eventIndex}"; - } - - public string ActorName { get; } - public int EventIndex { get; } - public IMessage Event { get; } - public string Type { get; } - - [JsonIgnore] - public string Key { get; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Google.Protobuf; +using Newtonsoft.Json; + +namespace Proto.Persistence.Couchbase +{ + internal class Envelope + { + public Envelope(string actorName, int eventIndex, IMessage @event, string type) + { + ActorName = actorName; + EventIndex = eventIndex; + Event = @event; + Type = type; + Key = $"{actorName}-event-{eventIndex}"; + } + + public string ActorName { get; } + public int EventIndex { get; } + public IMessage Event { get; } + public string Type { get; } + + [JsonIgnore] + public string Key { get; } + } } \ No newline at end of file diff --git a/src/PersistenceProviders/Proto.Persistence.Couchbase/Proto.Persistence.Couchbase.csproj b/src/PersistenceProviders/Proto.Persistence.Couchbase/Proto.Persistence.Couchbase.csproj index 28bb60ca21..64b6a9a0f8 100644 --- a/src/PersistenceProviders/Proto.Persistence.Couchbase/Proto.Persistence.Couchbase.csproj +++ b/src/PersistenceProviders/Proto.Persistence.Couchbase/Proto.Persistence.Couchbase.csproj @@ -1,13 +1,13 @@ - - - netstandard1.6 - - - - - - - - - + + + netstandard1.6 + + + + + + + + + \ No newline at end of file diff --git a/src/Proto.Actor/Actor.cs b/src/Proto.Actor/Actor.cs index 98c3929385..5c26280183 100644 --- a/src/Proto.Actor/Actor.cs +++ b/src/Proto.Actor/Actor.cs @@ -1,77 +1,77 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; - -namespace Proto -{ - public delegate Task Receive(IContext context); - - public class EmptyActor : IActor - { - private readonly Receive _receive; - - public EmptyActor(Receive receive) - { - _receive = receive; - } - - public Task ReceiveAsync(IContext context) - { - return _receive(context); - } - } - - public static class Actor - { - public static readonly Task Done = Task.CompletedTask; - - public static EventStream EventStream => EventStream.Instance; - - public static Props FromProducer(Func producer) - { - return new Props().WithProducer(producer); - } - - public static Props FromFunc(Receive receive) - { - return FromProducer(() => new EmptyActor(receive)); - } - - public static PID Spawn(Props props) - { - var name = ProcessRegistry.Instance.NextId(); - return SpawnNamed(props, name); - } - - public static PID SpawnPrefix(Props props, string prefix) - { - var name = prefix + ProcessRegistry.Instance.NextId(); - return SpawnNamed(props, name); - } - - public static PID SpawnNamed(Props props, string name) - { - return props.Spawn(name, null); - } - } - - public class ProcessNameExistException : Exception - { - private string _name; - - public ProcessNameExistException(string name) - { - _name = name; - } - } - - public interface IActor - { - Task ReceiveAsync(IContext context); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; + +namespace Proto +{ + public delegate Task Receive(IContext context); + + public class EmptyActor : IActor + { + private readonly Receive _receive; + + public EmptyActor(Receive receive) + { + _receive = receive; + } + + public Task ReceiveAsync(IContext context) + { + return _receive(context); + } + } + + public static class Actor + { + public static readonly Task Done = Task.CompletedTask; + + public static EventStream EventStream => EventStream.Instance; + + public static Props FromProducer(Func producer) + { + return new Props().WithProducer(producer); + } + + public static Props FromFunc(Receive receive) + { + return FromProducer(() => new EmptyActor(receive)); + } + + public static PID Spawn(Props props) + { + var name = ProcessRegistry.Instance.NextId(); + return SpawnNamed(props, name); + } + + public static PID SpawnPrefix(Props props, string prefix) + { + var name = prefix + ProcessRegistry.Instance.NextId(); + return SpawnNamed(props, name); + } + + public static PID SpawnNamed(Props props, string name) + { + return props.Spawn(name, null); + } + } + + public class ProcessNameExistException : Exception + { + private string _name; + + public ProcessNameExistException(string name) + { + _name = name; + } + } + + public interface IActor + { + Task ReceiveAsync(IContext context); + } } \ No newline at end of file diff --git a/src/Proto.Actor/Context.cs b/src/Proto.Actor/Context.cs index ce61805cd2..442f3256f1 100644 --- a/src/Proto.Actor/Context.cs +++ b/src/Proto.Actor/Context.cs @@ -1,121 +1,121 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Proto -{ - public interface IContext - { - /// - /// Gets the PID for the parent of the current actor. - /// - PID Parent { get; } - - /// - /// Gets the PID for the current actor. - /// - PID Self { get; } - - /// - /// The current message to be processed. - /// - object Message { get; } - - /// - /// Gets the PID of the actor that sent the currently processed message. - /// - PID Sender { get; } - - /// - /// Gets the actor associated with this context. - /// - IActor Actor { get; } - - /// - /// Gets the receive timeout. - /// - TimeSpan ReceiveTimeout { get; } - - /// - /// Gets the PIDs of the actor's children. - /// - IReadOnlyCollection Children { get; } - - /// - /// Sends a response to the current Sender. If the Sender is null, the actor will panic. - /// - /// The message to send - void Respond(object message); - - /// - /// Stashes the current message on a stack for re-processing when the actor restarts. - /// - void Stash(); - - /// - /// Spawns a new child actor based on props and named with a unique ID. - /// - /// The Props used to spawn the actor - /// The PID of the child actor - PID Spawn(Props props); - - /// - /// Spawns a new child actor based on props and named using a prefix followed by a unique ID. - /// - /// The Props used to spawn the actor - /// The prefix for the actor name - /// The PID of the child actor - PID SpawnPrefix(Props props, string prefix); - - /// - /// Spawns a new child actor based on props and named using the specified name. - /// - /// The Props used to spawn the actor - /// The actor name - /// The PID of the child actor - PID SpawnNamed(Props props, string name); - - /// - /// Replaces the current behavior stack with the new behavior. - /// - void SetBehavior(Receive behavior); - - /// - /// Pushes the behavior onto the current behavior stack and sets the current Receive handler to the new behavior. - /// - void PushBehavior(Receive behavior); - - /// - /// Reverts to the previous Receive handler. - /// - void PopBehavior(); - - /// - /// Registers the actor as a watcher for the specified PID. - /// - /// The PID to watch - void Watch(PID pid); - - /// - /// Unregisters the actor as a watcher for the specified PID. - /// - /// The PID to unwatch - void Unwatch(PID pid); - - /// - /// Sets the receive timeout. If no message is received for the given duration, a ReceiveTimeout message will be sent - /// to the actor. If a message is received within the given duration, the timer is reset, unless the message implements - /// INotInfluenceReceiveTimeout. Setting a duration of less than 1ms will disable the timer. - /// - /// The receive timeout duration - void SetReceiveTimeout(TimeSpan duration); - - Task ReceiveAsync(object message); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Proto +{ + public interface IContext + { + /// + /// Gets the PID for the parent of the current actor. + /// + PID Parent { get; } + + /// + /// Gets the PID for the current actor. + /// + PID Self { get; } + + /// + /// The current message to be processed. + /// + object Message { get; } + + /// + /// Gets the PID of the actor that sent the currently processed message. + /// + PID Sender { get; } + + /// + /// Gets the actor associated with this context. + /// + IActor Actor { get; } + + /// + /// Gets the receive timeout. + /// + TimeSpan ReceiveTimeout { get; } + + /// + /// Gets the PIDs of the actor's children. + /// + IReadOnlyCollection Children { get; } + + /// + /// Sends a response to the current Sender. If the Sender is null, the actor will panic. + /// + /// The message to send + void Respond(object message); + + /// + /// Stashes the current message on a stack for re-processing when the actor restarts. + /// + void Stash(); + + /// + /// Spawns a new child actor based on props and named with a unique ID. + /// + /// The Props used to spawn the actor + /// The PID of the child actor + PID Spawn(Props props); + + /// + /// Spawns a new child actor based on props and named using a prefix followed by a unique ID. + /// + /// The Props used to spawn the actor + /// The prefix for the actor name + /// The PID of the child actor + PID SpawnPrefix(Props props, string prefix); + + /// + /// Spawns a new child actor based on props and named using the specified name. + /// + /// The Props used to spawn the actor + /// The actor name + /// The PID of the child actor + PID SpawnNamed(Props props, string name); + + /// + /// Replaces the current behavior stack with the new behavior. + /// + void SetBehavior(Receive behavior); + + /// + /// Pushes the behavior onto the current behavior stack and sets the current Receive handler to the new behavior. + /// + void PushBehavior(Receive behavior); + + /// + /// Reverts to the previous Receive handler. + /// + void PopBehavior(); + + /// + /// Registers the actor as a watcher for the specified PID. + /// + /// The PID to watch + void Watch(PID pid); + + /// + /// Unregisters the actor as a watcher for the specified PID. + /// + /// The PID to unwatch + void Unwatch(PID pid); + + /// + /// Sets the receive timeout. If no message is received for the given duration, a ReceiveTimeout message will be sent + /// to the actor. If a message is received within the given duration, the timer is reset, unless the message implements + /// INotInfluenceReceiveTimeout. Setting a duration of less than 1ms will disable the timer. + /// + /// The receive timeout duration + void SetReceiveTimeout(TimeSpan duration); + + Task ReceiveAsync(object message); + } } \ No newline at end of file diff --git a/src/Proto.Actor/DeadLetter.cs b/src/Proto.Actor/DeadLetter.cs index e5195ea890..9452640c47 100644 --- a/src/Proto.Actor/DeadLetter.cs +++ b/src/Proto.Actor/DeadLetter.cs @@ -1,37 +1,37 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto -{ - public class DeadLetterEvent - { - public DeadLetterEvent(PID pid, object message, PID sender) - { - Pid = pid; - Message = message; - Sender = sender; - } - - public PID Pid { get; } - public object Message { get; } - public PID Sender { get; } - } - - public class DeadLetterProcess : Process - { - public static readonly DeadLetterProcess Instance = new DeadLetterProcess(); - - public override void SendUserMessage(PID pid, object message, PID sender) - { - EventStream.Instance.Publish(new DeadLetterEvent(pid, message, sender)); - } - - public override void SendSystemMessage(PID pid, object message) - { - EventStream.Instance.Publish(new DeadLetterEvent(pid, message, null)); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto +{ + public class DeadLetterEvent + { + public DeadLetterEvent(PID pid, object message, PID sender) + { + Pid = pid; + Message = message; + Sender = sender; + } + + public PID Pid { get; } + public object Message { get; } + public PID Sender { get; } + } + + public class DeadLetterProcess : Process + { + public static readonly DeadLetterProcess Instance = new DeadLetterProcess(); + + public override void SendUserMessage(PID pid, object message, PID sender) + { + EventStream.Instance.Publish(new DeadLetterEvent(pid, message, sender)); + } + + public override void SendSystemMessage(PID pid, object message) + { + EventStream.Instance.Publish(new DeadLetterEvent(pid, message, null)); + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/EventStream.cs b/src/Proto.Actor/EventStream.cs index c4fba68bf8..f41ccc3ce2 100644 --- a/src/Proto.Actor/EventStream.cs +++ b/src/Proto.Actor/EventStream.cs @@ -1,45 +1,45 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Concurrent; - -namespace Proto -{ - public class EventStream - { - public static readonly EventStream Instance = new EventStream(); - - private readonly ConcurrentDictionary> _subscriptions = - new ConcurrentDictionary>(); - - public EventStream() - { - Subscribe(msg => - { - if (msg is DeadLetterEvent letter) - { - Console.WriteLine("[DeadLetter] '{0}' got '{1}:{2}' from '{3}'", letter.Pid.ToShortString(), - letter.Message.GetType().Name, letter.Message, letter.Sender?.ToShortString()); - } - }); - } - - public void Subscribe(Action action) - { - var sub = Guid.NewGuid(); - _subscriptions.TryAdd(sub, action); - } - - public void Publish(object msg) - { - foreach (var sub in _subscriptions) - { - sub.Value(msg); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Concurrent; + +namespace Proto +{ + public class EventStream + { + public static readonly EventStream Instance = new EventStream(); + + private readonly ConcurrentDictionary> _subscriptions = + new ConcurrentDictionary>(); + + public EventStream() + { + Subscribe(msg => + { + if (msg is DeadLetterEvent letter) + { + Console.WriteLine("[DeadLetter] '{0}' got '{1}:{2}' from '{3}'", letter.Pid.ToShortString(), + letter.Message.GetType().Name, letter.Message, letter.Sender?.ToShortString()); + } + }); + } + + public void Subscribe(Action action) + { + var sub = Guid.NewGuid(); + _subscriptions.TryAdd(sub, action); + } + + public void Publish(object msg) + { + foreach (var sub in _subscriptions) + { + sub.Value(msg); + } + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/Futures.cs b/src/Proto.Actor/Futures.cs index 0aeeab51eb..d025a51dd5 100644 --- a/src/Proto.Actor/Futures.cs +++ b/src/Proto.Actor/Futures.cs @@ -1,33 +1,33 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Threading.Tasks; - -namespace Proto -{ - public class FutureProcess : Process - { - private readonly TaskCompletionSource _tcs; - - public FutureProcess(TaskCompletionSource tcs) - { - _tcs = tcs; - } - - public override void SendUserMessage(PID pid, object message, PID sender) - { - if (message is T) - { - _tcs.TrySetResult((T) message); - pid.Stop(); - } - } - - public override void SendSystemMessage(PID pid, object message) - { - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Threading.Tasks; + +namespace Proto +{ + public class FutureProcess : Process + { + private readonly TaskCompletionSource _tcs; + + public FutureProcess(TaskCompletionSource tcs) + { + _tcs = tcs; + } + + public override void SendUserMessage(PID pid, object message, PID sender) + { + if (message is T) + { + _tcs.TrySetResult((T) message); + pid.Stop(); + } + } + + public override void SendSystemMessage(PID pid, object message) + { + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/HashedConcurrentDictionary.cs b/src/Proto.Actor/HashedConcurrentDictionary.cs index 1dd71ea730..c240940cfa 100644 --- a/src/Proto.Actor/HashedConcurrentDictionary.cs +++ b/src/Proto.Actor/HashedConcurrentDictionary.cs @@ -1,75 +1,75 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; - -namespace Proto -{ - public class HashedConcurrentDictionary - { - private const int HashSize = 1024; - private readonly Partition[] _partitions = new Partition[HashSize]; - - public HashedConcurrentDictionary() - { - for (var i = 0; i < _partitions.Length; i++) - { - _partitions[i] = new Partition(); - } - } - - static UInt64 CalculateHash(string read) - { - var hashedValue = 3074457345618258791ul; - for (var i = 0; i < read.Length; i++) - { - hashedValue += read[i]; - hashedValue *= 3074457345618258799ul; - } - return hashedValue; - } - - private Partition GetPartition(string key) - { - var hash = Math.Abs(key.GetHashCode()) % HashSize; - var p = _partitions[hash]; - return p; - } - - public bool TryAdd(string key, Process reff) - { - var p = GetPartition(key); - lock (p) - { - p.Add(key, reff); - return true; - } - } - - public bool TryGetValue(string key, out Process aref) - { - var p = GetPartition(key); - lock (p) - { - return p.TryGetValue(key, out aref); - } - } - - public void Remove(string key) - { - var p = GetPartition(key); - lock (p) - { - p.Remove(key); - } - } - - public class Partition : Dictionary - { - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; + +namespace Proto +{ + public class HashedConcurrentDictionary + { + private const int HashSize = 1024; + private readonly Partition[] _partitions = new Partition[HashSize]; + + public HashedConcurrentDictionary() + { + for (var i = 0; i < _partitions.Length; i++) + { + _partitions[i] = new Partition(); + } + } + + static UInt64 CalculateHash(string read) + { + var hashedValue = 3074457345618258791ul; + for (var i = 0; i < read.Length; i++) + { + hashedValue += read[i]; + hashedValue *= 3074457345618258799ul; + } + return hashedValue; + } + + private Partition GetPartition(string key) + { + var hash = Math.Abs(key.GetHashCode()) % HashSize; + var p = _partitions[hash]; + return p; + } + + public bool TryAdd(string key, Process reff) + { + var p = GetPartition(key); + lock (p) + { + p.Add(key, reff); + return true; + } + } + + public bool TryGetValue(string key, out Process aref) + { + var p = GetPartition(key); + lock (p) + { + return p.TryGetValue(key, out aref); + } + } + + public void Remove(string key) + { + var p = GetPartition(key); + lock (p) + { + p.Remove(key); + } + } + + public class Partition : Dictionary + { + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/LocalContext.cs b/src/Proto.Actor/LocalContext.cs index 0450d9d177..951c3e7434 100644 --- a/src/Proto.Actor/LocalContext.cs +++ b/src/Proto.Actor/LocalContext.cs @@ -1,437 +1,437 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Proto.Mailbox; - -namespace Proto -{ - public class Context : IMessageInvoker, IContext, ISupervisor - { - private readonly Stack _behavior; - private readonly Receive _middleware; - private readonly Func _producer; - private readonly ISupervisorStrategy _supervisorStrategy; - private HashSet _children; - private object _message; - private Receive _receive; - private Timer _receiveTimeoutTimer; - private bool _restarting; - private RestartStatistics _restartStatistics; - private Stack _stash; - private bool _stopping; - private HashSet _watchers; - private HashSet _watching; - - - public Context(Func producer, ISupervisorStrategy supervisorStrategy, Receive middleware, PID parent) - { - _producer = producer; - _supervisorStrategy = supervisorStrategy; - _middleware = middleware; - Parent = parent; - _behavior = new Stack(); - _behavior.Push(ActorReceive); - - IncarnateActor(); - } - - public IReadOnlyCollection Children => _children.ToList(); - public IActor Actor { get; private set; } - public PID Parent { get; } - public PID Self { get; internal set; } - - public object Message - { - get - { - var r = _message as MessageSender; - return r != null ? r.Message : _message; - } - private set { _message = value; } - } - - public PID Sender => (_message as MessageSender)?.Sender; - public TimeSpan ReceiveTimeout { get; private set; } - - - public void Stash() - { - if (_stash == null) - { - _stash = new Stack(); - } - _stash.Push(Message); - } - - public void Respond(object message) - { - Sender.Tell(message); - } - - public PID Spawn(Props props) - { - var id = ProcessRegistry.Instance.NextId(); - return SpawnNamed(props, id); - } - - public PID SpawnPrefix(Props props, string prefix) - { - var name = prefix + ProcessRegistry.Instance.NextId(); - return SpawnNamed(props, name); - } - - public PID SpawnNamed(Props props, string name) - { - var pid = props.Spawn($"{Self.Id}/{name}", Self); - if (_children == null) - { - _children = new HashSet(); - } - _children.Add(pid); - Watch(pid); - return pid; - } - - public void SetBehavior(Receive receive) - { - _behavior.Clear(); - _behavior.Push(receive); - _receive = receive; - } - - public void PushBehavior(Receive receive) - { - _behavior.Push(receive); - _receive = receive; - } - - public void PopBehavior() - { - if (_behavior.Count <= 1) - { - throw new Exception("Can not unbecome actor base behavior"); - } - _receive = _behavior.Pop(); - } - - public void Watch(PID pid) - { - pid.SendSystemMessage(new Watch(Self)); - if (_watching == null) - { - _watching = new HashSet(); - } - _watching.Add(pid); - } - - public void Unwatch(PID pid) - { - pid.SendSystemMessage(new Unwatch(Self)); - if (_watching == null) - { - _watching = new HashSet(); - } - _watching.Remove(pid); - } - - public void SetReceiveTimeout(TimeSpan duration) - { - if (duration == ReceiveTimeout) - { - return; - } - if (duration > TimeSpan.Zero) - { - StopReceiveTimeout(); - } - if (duration < TimeSpan.FromMilliseconds(1)) - { - duration = TimeSpan.FromMilliseconds(1); - } - ReceiveTimeout = duration; - if (ReceiveTimeout > TimeSpan.Zero) - { - if (_receiveTimeoutTimer == null) - { - _receiveTimeoutTimer = new Timer(ReceiveTimeoutCallback, null, ReceiveTimeout, ReceiveTimeout); - } - else - { - ResetReceiveTimeout(); - } - } - } - - public Task ReceiveAsync(object message) - { - return ProcessMessageAsync(message); - } - - public Task InvokeSystemMessageAsync(object msg) - { - try - { - switch (msg) - { - case Started s: - return InvokeUserMessageAsync(s); - case Stop _: - return HandleStopAsync(); - case Terminated t: - return HandleTerminatedAsync(t); - case Watch w: - HandleWatch(w); - return Task.CompletedTask; - case Unwatch uw: - HandleUnwatch(uw); - return Task.CompletedTask; - case Failure f: - HandleFailure(f); - return Task.CompletedTask; - case Restart r: - return HandleRestartAsync(); - case SuspendMailbox sm: - return Task.CompletedTask; - case ResumeMailbox rm: - return Task.CompletedTask; - default: - Console.WriteLine("Unknown system message {0}", msg); - return Task.CompletedTask; - } - } - catch (Exception x) - { - Console.WriteLine("Error handling SystemMessage {0}", x); - return Task.CompletedTask; - } - } - - public Task InvokeUserMessageAsync(object msg) - { - var influenceTimeout = true; - if (ReceiveTimeout > TimeSpan.Zero) - { - var notInfluenceTimeout = msg is INotInfluenceReceiveTimeout; - influenceTimeout = !notInfluenceTimeout; - if (influenceTimeout) - { - StopReceiveTimeout(); - } - } - - var res = ProcessMessageAsync(msg); - - if (ReceiveTimeout != TimeSpan.Zero && influenceTimeout) - { - //special handle non completed tasks that need to reset ReceiveTimout - if (!res.IsCompleted) - { - return res.ContinueWith(_ => ResetReceiveTimeout()); - } - - ResetReceiveTimeout(); - } - return res; - } - - public void EscalateFailure(Exception reason, object message) - { - if (_restartStatistics == null) - { - _restartStatistics = new RestartStatistics(1, null); - } - var failure = new Failure(Self, reason, _restartStatistics); - if (Parent == null) - { - HandleRootFailure(failure); - } - else - { - Self.SendSystemMessage(SuspendMailbox.Instance); - Parent.SendSystemMessage(failure); - } - } - - public void EscalateFailure(PID who, Exception reason) - { - Self.SendSystemMessage(SuspendMailbox.Instance); - Parent.SendSystemMessage(new Failure(who, reason, _restartStatistics)); - } - - internal static Task DefaultReceive(IContext context) - { - var c = (Context) context; - if (c.Message is PoisonPill) - { - c.Self.Stop(); - return Proto.Actor.Done; - } - return c._receive(context); - } - - private Task ProcessMessageAsync(object msg) - { - Message = msg; - if (_middleware != null) - { - return _middleware(this); - } - return DefaultReceive(this); - } - - private void IncarnateActor() - { - _restarting = false; - _stopping = false; - Actor = _producer(); - SetBehavior(ActorReceive); - } - - private async Task HandleRestartAsync() - { - _stopping = false; - _restarting = true; - - await InvokeUserMessageAsync(Restarting.Instance); - if (_children != null) - { - foreach (var child in _children) - { - child.Stop(); - } - } - await TryRestartOrTerminateAsync(); - } - - private void HandleUnwatch(Unwatch uw) - { - _watchers?.Remove(uw.Watcher); - } - - private void HandleWatch(Watch w) - { - if (_watchers == null) - { - _watchers = new HashSet(); - } - _watchers.Add(w.Watcher); - } - - private void HandleFailure(Failure msg) - { - if (Actor is ISupervisorStrategy supervisor) - { - supervisor.HandleFailure(this, msg.Who, msg.RestartStatistics, msg.Reason); - return; - } - _supervisorStrategy.HandleFailure(this, msg.Who, msg.RestartStatistics, msg.Reason); - } - - private async Task HandleTerminatedAsync(Terminated msg) - { - _children.Remove(msg.Who); - _watching.Remove(msg.Who); - await InvokeUserMessageAsync(msg); - await TryRestartOrTerminateAsync(); - } - - private void HandleRootFailure(Failure failure) - { - Supervision.DefaultStrategy.HandleFailure(this, failure.Who, failure.RestartStatistics, failure.Reason); - } - - private async Task HandleStopAsync() - { - _restarting = false; - _stopping = true; - //this is intentional - await InvokeUserMessageAsync(Stopping.Instance); - if (_children != null) - { - foreach (var child in _children) - { - child.Stop(); - } - } - await TryRestartOrTerminateAsync(); - } - - private async Task TryRestartOrTerminateAsync() - { - if (_receiveTimeoutTimer != null) - { - StopReceiveTimeout(); - _receiveTimeoutTimer = null; - ReceiveTimeout = TimeSpan.Zero; - } - - if (_children?.Count > 0) - { - return; - } - - if (_restarting) - { - await RestartAsync(); - return; - } - - if (_stopping) - { - await StopAsync(); - } - } - - private async Task StopAsync() - { - ProcessRegistry.Instance.Remove(Self); - //This is intentional - await InvokeUserMessageAsync(Stopped.Instance); - //Notify watchers - } - - private async Task RestartAsync() - { - IncarnateActor(); - Self.SendSystemMessage(ResumeMailbox.Instance); - - await InvokeUserMessageAsync(Started.Instance); - if (_stash != null) - { - while (_stash.Any()) - { - var msg = _stash.Pop(); - await InvokeUserMessageAsync(msg); - } - } - } - - private Task ActorReceive(IContext ctx) - { - return Actor.ReceiveAsync(ctx); - } - - private void ResetReceiveTimeout() - { - _receiveTimeoutTimer?.Change(ReceiveTimeout, ReceiveTimeout); - } - - private void StopReceiveTimeout() - { - _receiveTimeoutTimer?.Change(-1, -1); - } - - private void ReceiveTimeoutCallback(object state) - { - Self.Request(Proto.ReceiveTimeout.Instance, null); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Proto.Mailbox; + +namespace Proto +{ + public class Context : IMessageInvoker, IContext, ISupervisor + { + private readonly Stack _behavior; + private readonly Receive _middleware; + private readonly Func _producer; + private readonly ISupervisorStrategy _supervisorStrategy; + private HashSet _children; + private object _message; + private Receive _receive; + private Timer _receiveTimeoutTimer; + private bool _restarting; + private RestartStatistics _restartStatistics; + private Stack _stash; + private bool _stopping; + private HashSet _watchers; + private HashSet _watching; + + + public Context(Func producer, ISupervisorStrategy supervisorStrategy, Receive middleware, PID parent) + { + _producer = producer; + _supervisorStrategy = supervisorStrategy; + _middleware = middleware; + Parent = parent; + _behavior = new Stack(); + _behavior.Push(ActorReceive); + + IncarnateActor(); + } + + public IReadOnlyCollection Children => _children.ToList(); + public IActor Actor { get; private set; } + public PID Parent { get; } + public PID Self { get; internal set; } + + public object Message + { + get + { + var r = _message as MessageSender; + return r != null ? r.Message : _message; + } + private set { _message = value; } + } + + public PID Sender => (_message as MessageSender)?.Sender; + public TimeSpan ReceiveTimeout { get; private set; } + + + public void Stash() + { + if (_stash == null) + { + _stash = new Stack(); + } + _stash.Push(Message); + } + + public void Respond(object message) + { + Sender.Tell(message); + } + + public PID Spawn(Props props) + { + var id = ProcessRegistry.Instance.NextId(); + return SpawnNamed(props, id); + } + + public PID SpawnPrefix(Props props, string prefix) + { + var name = prefix + ProcessRegistry.Instance.NextId(); + return SpawnNamed(props, name); + } + + public PID SpawnNamed(Props props, string name) + { + var pid = props.Spawn($"{Self.Id}/{name}", Self); + if (_children == null) + { + _children = new HashSet(); + } + _children.Add(pid); + Watch(pid); + return pid; + } + + public void SetBehavior(Receive receive) + { + _behavior.Clear(); + _behavior.Push(receive); + _receive = receive; + } + + public void PushBehavior(Receive receive) + { + _behavior.Push(receive); + _receive = receive; + } + + public void PopBehavior() + { + if (_behavior.Count <= 1) + { + throw new Exception("Can not unbecome actor base behavior"); + } + _receive = _behavior.Pop(); + } + + public void Watch(PID pid) + { + pid.SendSystemMessage(new Watch(Self)); + if (_watching == null) + { + _watching = new HashSet(); + } + _watching.Add(pid); + } + + public void Unwatch(PID pid) + { + pid.SendSystemMessage(new Unwatch(Self)); + if (_watching == null) + { + _watching = new HashSet(); + } + _watching.Remove(pid); + } + + public void SetReceiveTimeout(TimeSpan duration) + { + if (duration == ReceiveTimeout) + { + return; + } + if (duration > TimeSpan.Zero) + { + StopReceiveTimeout(); + } + if (duration < TimeSpan.FromMilliseconds(1)) + { + duration = TimeSpan.FromMilliseconds(1); + } + ReceiveTimeout = duration; + if (ReceiveTimeout > TimeSpan.Zero) + { + if (_receiveTimeoutTimer == null) + { + _receiveTimeoutTimer = new Timer(ReceiveTimeoutCallback, null, ReceiveTimeout, ReceiveTimeout); + } + else + { + ResetReceiveTimeout(); + } + } + } + + public Task ReceiveAsync(object message) + { + return ProcessMessageAsync(message); + } + + public Task InvokeSystemMessageAsync(object msg) + { + try + { + switch (msg) + { + case Started s: + return InvokeUserMessageAsync(s); + case Stop _: + return HandleStopAsync(); + case Terminated t: + return HandleTerminatedAsync(t); + case Watch w: + HandleWatch(w); + return Task.CompletedTask; + case Unwatch uw: + HandleUnwatch(uw); + return Task.CompletedTask; + case Failure f: + HandleFailure(f); + return Task.CompletedTask; + case Restart r: + return HandleRestartAsync(); + case SuspendMailbox sm: + return Task.CompletedTask; + case ResumeMailbox rm: + return Task.CompletedTask; + default: + Console.WriteLine("Unknown system message {0}", msg); + return Task.CompletedTask; + } + } + catch (Exception x) + { + Console.WriteLine("Error handling SystemMessage {0}", x); + return Task.CompletedTask; + } + } + + public Task InvokeUserMessageAsync(object msg) + { + var influenceTimeout = true; + if (ReceiveTimeout > TimeSpan.Zero) + { + var notInfluenceTimeout = msg is INotInfluenceReceiveTimeout; + influenceTimeout = !notInfluenceTimeout; + if (influenceTimeout) + { + StopReceiveTimeout(); + } + } + + var res = ProcessMessageAsync(msg); + + if (ReceiveTimeout != TimeSpan.Zero && influenceTimeout) + { + //special handle non completed tasks that need to reset ReceiveTimout + if (!res.IsCompleted) + { + return res.ContinueWith(_ => ResetReceiveTimeout()); + } + + ResetReceiveTimeout(); + } + return res; + } + + public void EscalateFailure(Exception reason, object message) + { + if (_restartStatistics == null) + { + _restartStatistics = new RestartStatistics(1, null); + } + var failure = new Failure(Self, reason, _restartStatistics); + if (Parent == null) + { + HandleRootFailure(failure); + } + else + { + Self.SendSystemMessage(SuspendMailbox.Instance); + Parent.SendSystemMessage(failure); + } + } + + public void EscalateFailure(PID who, Exception reason) + { + Self.SendSystemMessage(SuspendMailbox.Instance); + Parent.SendSystemMessage(new Failure(who, reason, _restartStatistics)); + } + + internal static Task DefaultReceive(IContext context) + { + var c = (Context) context; + if (c.Message is PoisonPill) + { + c.Self.Stop(); + return Proto.Actor.Done; + } + return c._receive(context); + } + + private Task ProcessMessageAsync(object msg) + { + Message = msg; + if (_middleware != null) + { + return _middleware(this); + } + return DefaultReceive(this); + } + + private void IncarnateActor() + { + _restarting = false; + _stopping = false; + Actor = _producer(); + SetBehavior(ActorReceive); + } + + private async Task HandleRestartAsync() + { + _stopping = false; + _restarting = true; + + await InvokeUserMessageAsync(Restarting.Instance); + if (_children != null) + { + foreach (var child in _children) + { + child.Stop(); + } + } + await TryRestartOrTerminateAsync(); + } + + private void HandleUnwatch(Unwatch uw) + { + _watchers?.Remove(uw.Watcher); + } + + private void HandleWatch(Watch w) + { + if (_watchers == null) + { + _watchers = new HashSet(); + } + _watchers.Add(w.Watcher); + } + + private void HandleFailure(Failure msg) + { + if (Actor is ISupervisorStrategy supervisor) + { + supervisor.HandleFailure(this, msg.Who, msg.RestartStatistics, msg.Reason); + return; + } + _supervisorStrategy.HandleFailure(this, msg.Who, msg.RestartStatistics, msg.Reason); + } + + private async Task HandleTerminatedAsync(Terminated msg) + { + _children.Remove(msg.Who); + _watching.Remove(msg.Who); + await InvokeUserMessageAsync(msg); + await TryRestartOrTerminateAsync(); + } + + private void HandleRootFailure(Failure failure) + { + Supervision.DefaultStrategy.HandleFailure(this, failure.Who, failure.RestartStatistics, failure.Reason); + } + + private async Task HandleStopAsync() + { + _restarting = false; + _stopping = true; + //this is intentional + await InvokeUserMessageAsync(Stopping.Instance); + if (_children != null) + { + foreach (var child in _children) + { + child.Stop(); + } + } + await TryRestartOrTerminateAsync(); + } + + private async Task TryRestartOrTerminateAsync() + { + if (_receiveTimeoutTimer != null) + { + StopReceiveTimeout(); + _receiveTimeoutTimer = null; + ReceiveTimeout = TimeSpan.Zero; + } + + if (_children?.Count > 0) + { + return; + } + + if (_restarting) + { + await RestartAsync(); + return; + } + + if (_stopping) + { + await StopAsync(); + } + } + + private async Task StopAsync() + { + ProcessRegistry.Instance.Remove(Self); + //This is intentional + await InvokeUserMessageAsync(Stopped.Instance); + //Notify watchers + } + + private async Task RestartAsync() + { + IncarnateActor(); + Self.SendSystemMessage(ResumeMailbox.Instance); + + await InvokeUserMessageAsync(Started.Instance); + if (_stash != null) + { + while (_stash.Any()) + { + var msg = _stash.Pop(); + await InvokeUserMessageAsync(msg); + } + } + } + + private Task ActorReceive(IContext ctx) + { + return Actor.ReceiveAsync(ctx); + } + + private void ResetReceiveTimeout() + { + _receiveTimeoutTimer?.Change(ReceiveTimeout, ReceiveTimeout); + } + + private void StopReceiveTimeout() + { + _receiveTimeoutTimer?.Change(-1, -1); + } + + private void ReceiveTimeoutCallback(object state) + { + Self.Request(Proto.ReceiveTimeout.Instance, null); + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/Messages.cs b/src/Proto.Actor/Messages.cs index 619a2b7c92..d7d9c134e4 100644 --- a/src/Proto.Actor/Messages.cs +++ b/src/Proto.Actor/Messages.cs @@ -1,127 +1,127 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; - -namespace Proto -{ - public abstract class SystemMessage - { - } - - public abstract class AutoReceiveMessage - { - } - - public sealed partial class Terminated : SystemMessage - { - } - - public sealed class Restarting - { - public static readonly Restarting Instance = new Restarting(); - - private Restarting() - { - } - } - - public class Failure : SystemMessage - { - public Failure(PID who, Exception reason, RestartStatistics crs) - { - Who = who; - Reason = reason; - RestartStatistics = crs; - } - - public Exception Reason { get; } - public PID Who { get; } - public RestartStatistics RestartStatistics { get; } - } - - public sealed partial class Watch : SystemMessage - { - public Watch(PID watcher) - { - Watcher = watcher; - } - } - - public sealed partial class Unwatch : SystemMessage - { - public Unwatch(PID watcher) - { - Watcher = watcher; - } - } - - public sealed class Restart : SystemMessage - { - public static readonly Restart Instance = new Restart(); - - private Restart() - { - } - } - - public partial class Stop : SystemMessage - { - public static readonly Stop Instance = new Stop(); - } - - public sealed class Stopping : AutoReceiveMessage - { - public static readonly Stopping Instance = new Stopping(); - - private Stopping() - { - } - } - - public sealed class Started : SystemMessage - { - public static readonly Started Instance = new Started(); - - private Started() - { - } - } - - public sealed class Stopped : AutoReceiveMessage - { - public static readonly Stopped Instance = new Stopped(); - - private Stopped() - { - } - } - - public class ReceiveTimeout : SystemMessage - { - public static readonly ReceiveTimeout Instance = new ReceiveTimeout(); - - private ReceiveTimeout() - { - } - } - - public sealed class MessageSender - { - public MessageSender(object message, PID sender) - { - Message = message; - Sender = sender; - } - - public object Message { get; } - public PID Sender { get; } - } - - public interface INotInfluenceReceiveTimeout - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; + +namespace Proto +{ + public abstract class SystemMessage + { + } + + public abstract class AutoReceiveMessage + { + } + + public sealed partial class Terminated : SystemMessage + { + } + + public sealed class Restarting + { + public static readonly Restarting Instance = new Restarting(); + + private Restarting() + { + } + } + + public class Failure : SystemMessage + { + public Failure(PID who, Exception reason, RestartStatistics crs) + { + Who = who; + Reason = reason; + RestartStatistics = crs; + } + + public Exception Reason { get; } + public PID Who { get; } + public RestartStatistics RestartStatistics { get; } + } + + public sealed partial class Watch : SystemMessage + { + public Watch(PID watcher) + { + Watcher = watcher; + } + } + + public sealed partial class Unwatch : SystemMessage + { + public Unwatch(PID watcher) + { + Watcher = watcher; + } + } + + public sealed class Restart : SystemMessage + { + public static readonly Restart Instance = new Restart(); + + private Restart() + { + } + } + + public partial class Stop : SystemMessage + { + public static readonly Stop Instance = new Stop(); + } + + public sealed class Stopping : AutoReceiveMessage + { + public static readonly Stopping Instance = new Stopping(); + + private Stopping() + { + } + } + + public sealed class Started : SystemMessage + { + public static readonly Started Instance = new Started(); + + private Started() + { + } + } + + public sealed class Stopped : AutoReceiveMessage + { + public static readonly Stopped Instance = new Stopped(); + + private Stopped() + { + } + } + + public class ReceiveTimeout : SystemMessage + { + public static readonly ReceiveTimeout Instance = new ReceiveTimeout(); + + private ReceiveTimeout() + { + } + } + + public sealed class MessageSender + { + public MessageSender(object message, PID sender) + { + Message = message; + Sender = sender; + } + + public object Message { get; } + public PID Sender { get; } + } + + public interface INotInfluenceReceiveTimeout + { + } } \ No newline at end of file diff --git a/src/Proto.Actor/PID.cs b/src/Proto.Actor/PID.cs index e36dcb29fd..4da675d8f1 100644 --- a/src/Proto.Actor/PID.cs +++ b/src/Proto.Actor/PID.cs @@ -1,64 +1,64 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Threading.Tasks; - -namespace Proto -{ - public partial class PID - { - public PID(string address, string id) - { - Address = address; - Id = id; - } - - internal Process Ref { get; set; } - - public void Tell(object message) - { - var reff = Ref ?? ProcessRegistry.Instance.Get(this); - reff.SendUserMessage(this, message, null); - } - - public void SendSystemMessage(object sys) - { - var reff = Ref ?? ProcessRegistry.Instance.Get(this); - reff.SendSystemMessage(this, sys); - } - - public void Request(object message, PID sender) - { - var reff = Ref ?? ProcessRegistry.Instance.Get(this); - reff.SendUserMessage(this, message, sender); - } - - public Task RequestAsync(object message) - { - var tsc = new TaskCompletionSource(); - var reff = new FutureProcess(tsc); - var name = ProcessRegistry.Instance.NextId(); - var (pid, absent) = ProcessRegistry.Instance.TryAdd(name, reff); - if (!absent) - { - throw new ProcessNameExistException(name); - } - Request(message, pid); - return tsc.Task; - } - - public void Stop() - { - var reff = ProcessRegistry.Instance.Get(this); - reff.Stop(this); - } - - public string ToShortString() - { - return Address + "/" + Id; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Threading.Tasks; + +namespace Proto +{ + public partial class PID + { + public PID(string address, string id) + { + Address = address; + Id = id; + } + + internal Process Ref { get; set; } + + public void Tell(object message) + { + var reff = Ref ?? ProcessRegistry.Instance.Get(this); + reff.SendUserMessage(this, message, null); + } + + public void SendSystemMessage(object sys) + { + var reff = Ref ?? ProcessRegistry.Instance.Get(this); + reff.SendSystemMessage(this, sys); + } + + public void Request(object message, PID sender) + { + var reff = Ref ?? ProcessRegistry.Instance.Get(this); + reff.SendUserMessage(this, message, sender); + } + + public Task RequestAsync(object message) + { + var tsc = new TaskCompletionSource(); + var reff = new FutureProcess(tsc); + var name = ProcessRegistry.Instance.NextId(); + var (pid, absent) = ProcessRegistry.Instance.TryAdd(name, reff); + if (!absent) + { + throw new ProcessNameExistException(name); + } + Request(message, pid); + return tsc.Task; + } + + public void Stop() + { + var reff = ProcessRegistry.Instance.Get(this); + reff.Stop(this); + } + + public string ToShortString() + { + return Address + "/" + Id; + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/Process.cs b/src/Proto.Actor/Process.cs index f9762f1646..159f6f31b4 100644 --- a/src/Proto.Actor/Process.cs +++ b/src/Proto.Actor/Process.cs @@ -1,48 +1,48 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Proto.Mailbox; - -namespace Proto -{ - public abstract class Process - { - public abstract void SendUserMessage(PID pid, object message, PID sender); - - public void Stop(PID pid) - { - SendSystemMessage(pid, new Stop()); - } - - public abstract void SendSystemMessage(PID pid, object message); - } - - public class LocalProcess : Process - { - public LocalProcess(IMailbox mailbox) - { - Mailbox = mailbox; - } - - public IMailbox Mailbox { get; } - - public override void SendUserMessage(PID pid, object message, PID sender) - { - if (sender != null) - { - Mailbox.PostUserMessage(new MessageSender(message, sender)); - return; - } - - Mailbox.PostUserMessage(message); - } - - public override void SendSystemMessage(PID pid, object message) - { - Mailbox.PostSystemMessage(message); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Proto.Mailbox; + +namespace Proto +{ + public abstract class Process + { + public abstract void SendUserMessage(PID pid, object message, PID sender); + + public void Stop(PID pid) + { + SendSystemMessage(pid, new Stop()); + } + + public abstract void SendSystemMessage(PID pid, object message); + } + + public class LocalProcess : Process + { + public LocalProcess(IMailbox mailbox) + { + Mailbox = mailbox; + } + + public IMailbox Mailbox { get; } + + public override void SendUserMessage(PID pid, object message, PID sender) + { + if (sender != null) + { + Mailbox.PostUserMessage(new MessageSender(message, sender)); + return; + } + + Mailbox.PostUserMessage(message); + } + + public override void SendSystemMessage(PID pid, object message) + { + Mailbox.PostSystemMessage(message); + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/ProcessRegistry.cs b/src/Proto.Actor/ProcessRegistry.cs index 8f73362cb1..bfc974a5a8 100644 --- a/src/Proto.Actor/ProcessRegistry.cs +++ b/src/Proto.Actor/ProcessRegistry.cs @@ -1,79 +1,79 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Threading; - -namespace Proto -{ - public class ProcessRegistry - { - private const string NoHost = "nonhost"; - private readonly IList> _hostResolvers = new List>(); - - private readonly HashedConcurrentDictionary _localActorRefs = - new HashedConcurrentDictionary(); - - private int _sequenceId; - public static ProcessRegistry Instance { get; } = new ProcessRegistry(); - - public string Address { get; set; } = NoHost; - - public void RegisterHostResolver(Func resolver) - { - _hostResolvers.Add(resolver); - } - - public Process Get(PID pid) - { - if (pid.Address != "nonhost" && pid.Address != Address) - { - foreach (var resolver in _hostResolvers) - { - var reff = resolver(pid); - if (reff == null) - { - continue; - } - //this is racy but it doesnt matter - pid.Ref = reff; - return reff; - } - throw new NotSupportedException("Unknown host"); - } - - if (_localActorRefs.TryGetValue(pid.Id, out var aref)) - { - return aref; - } - return DeadLetterProcess.Instance; - } - - public (PID pid, bool ok) TryAdd(string id, Process aref) - { - var pid = new PID - { - Id = id, - Ref = aref, //cache aref lookup - Address = Address // local - }; - var ok = _localActorRefs.TryAdd(pid.Id, aref); - return (pid, ok); - } - - public void Remove(PID pid) - { - _localActorRefs.Remove(pid.Id); - } - - public string NextId() - { - var counter = Interlocked.Increment(ref _sequenceId); - return "$" + counter; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Threading; + +namespace Proto +{ + public class ProcessRegistry + { + private const string NoHost = "nonhost"; + private readonly IList> _hostResolvers = new List>(); + + private readonly HashedConcurrentDictionary _localActorRefs = + new HashedConcurrentDictionary(); + + private int _sequenceId; + public static ProcessRegistry Instance { get; } = new ProcessRegistry(); + + public string Address { get; set; } = NoHost; + + public void RegisterHostResolver(Func resolver) + { + _hostResolvers.Add(resolver); + } + + public Process Get(PID pid) + { + if (pid.Address != "nonhost" && pid.Address != Address) + { + foreach (var resolver in _hostResolvers) + { + var reff = resolver(pid); + if (reff == null) + { + continue; + } + //this is racy but it doesnt matter + pid.Ref = reff; + return reff; + } + throw new NotSupportedException("Unknown host"); + } + + if (_localActorRefs.TryGetValue(pid.Id, out var aref)) + { + return aref; + } + return DeadLetterProcess.Instance; + } + + public (PID pid, bool ok) TryAdd(string id, Process aref) + { + var pid = new PID + { + Id = id, + Ref = aref, //cache aref lookup + Address = Address // local + }; + var ok = _localActorRefs.TryAdd(pid.Id, aref); + return (pid, ok); + } + + public void Remove(PID pid) + { + _localActorRefs.Remove(pid.Id); + } + + public string NextId() + { + var counter = Interlocked.Increment(ref _sequenceId); + return "$" + counter; + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/Props.cs b/src/Proto.Actor/Props.cs index cbb7c95131..3b3a725f34 100644 --- a/src/Proto.Actor/Props.cs +++ b/src/Proto.Actor/Props.cs @@ -1,113 +1,113 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Linq; -using Proto.Mailbox; - -namespace Proto -{ - public sealed class Props - { - public Func Producer { get; private set; } - - public Func MailboxProducer { get; private set; } = - () => new DefaultMailbox(new UnboundedMailboxQueue(), new UnboundedMailboxQueue()); - - public ISupervisorStrategy SupervisorStrategy { get; private set; } = Supervision.DefaultStrategy; - - public IDispatcher Dispatcher { get; private set; } = Dispatchers.DefaultDispatcher; - - public IList> Middleware { get; private set; } = new List>(); - - public Receive MiddlewareChain { get; set; } - - private Spawner _spawner = null; - public Spawner Spawner { - get => _spawner ?? DefaultSpawner; - private set => _spawner = value; - } - - public static Spawner DefaultSpawner = (name, props, parent) => - { - var ctx = new Context(props.Producer, props.SupervisorStrategy, props.MiddlewareChain, parent); - var mailbox = props.MailboxProducer(); - var dispatcher = props.Dispatcher; - var reff = new LocalProcess(mailbox); - var (pid, absent) = ProcessRegistry.Instance.TryAdd(name, reff); - if (!absent) - { - throw new ProcessNameExistException(name); - } - ctx.Self = pid; - mailbox.RegisterHandlers(ctx, dispatcher); - // ctx.InvokeUserMessageAsync(Started.Instance); - mailbox.PostSystemMessage(Started.Instance); - mailbox.Start(); - - return pid; - }; - - public Props WithProducer(Func producer) - { - return Copy(props => props.Producer = producer); - } - - public Props WithDispatcher(IDispatcher dispatcher) - { - return Copy(props => props.Dispatcher = dispatcher); - } - - public Props WithMailbox(Func mailboxProducer) - { - return Copy(props => props.MailboxProducer = mailboxProducer); - } - - public Props WithSupervisor(ISupervisorStrategy supervisor) - { - return Copy(props => props.SupervisorStrategy = supervisor); - } - - public Props WithMiddleware(params Func[] middleware) - { - return Copy(props => - { - props.Middleware = Middleware.Concat(middleware).ToList(); - props.MiddlewareChain = props.Middleware.Reverse() - .Aggregate((Receive) Context.DefaultReceive, (inner, outer) => outer(inner)); - }); - } - - public Props WithSpawner(Spawner spawner) - { - return Copy(props => props.Spawner = spawner); - } - - private Props Copy(Action mutator) - { - var props = new Props - { - Dispatcher = Dispatcher, - MailboxProducer = MailboxProducer, - Producer = Producer, - Middleware = Middleware, - MiddlewareChain = MiddlewareChain, - Spawner = Spawner, - SupervisorStrategy = SupervisorStrategy - }; - mutator(props); - return props; - } - - public PID Spawn(string name, PID parent) - { - return Spawner(name, this, parent); - } - } - - public delegate PID Spawner(string id, Props props, PID parent); +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using Proto.Mailbox; + +namespace Proto +{ + public sealed class Props + { + public Func Producer { get; private set; } + + public Func MailboxProducer { get; private set; } = + () => new DefaultMailbox(new UnboundedMailboxQueue(), new UnboundedMailboxQueue()); + + public ISupervisorStrategy SupervisorStrategy { get; private set; } = Supervision.DefaultStrategy; + + public IDispatcher Dispatcher { get; private set; } = Dispatchers.DefaultDispatcher; + + public IList> Middleware { get; private set; } = new List>(); + + public Receive MiddlewareChain { get; set; } + + private Spawner _spawner = null; + public Spawner Spawner { + get => _spawner ?? DefaultSpawner; + private set => _spawner = value; + } + + public static Spawner DefaultSpawner = (name, props, parent) => + { + var ctx = new Context(props.Producer, props.SupervisorStrategy, props.MiddlewareChain, parent); + var mailbox = props.MailboxProducer(); + var dispatcher = props.Dispatcher; + var reff = new LocalProcess(mailbox); + var (pid, absent) = ProcessRegistry.Instance.TryAdd(name, reff); + if (!absent) + { + throw new ProcessNameExistException(name); + } + ctx.Self = pid; + mailbox.RegisterHandlers(ctx, dispatcher); + // ctx.InvokeUserMessageAsync(Started.Instance); + mailbox.PostSystemMessage(Started.Instance); + mailbox.Start(); + + return pid; + }; + + public Props WithProducer(Func producer) + { + return Copy(props => props.Producer = producer); + } + + public Props WithDispatcher(IDispatcher dispatcher) + { + return Copy(props => props.Dispatcher = dispatcher); + } + + public Props WithMailbox(Func mailboxProducer) + { + return Copy(props => props.MailboxProducer = mailboxProducer); + } + + public Props WithSupervisor(ISupervisorStrategy supervisor) + { + return Copy(props => props.SupervisorStrategy = supervisor); + } + + public Props WithMiddleware(params Func[] middleware) + { + return Copy(props => + { + props.Middleware = Middleware.Concat(middleware).ToList(); + props.MiddlewareChain = props.Middleware.Reverse() + .Aggregate((Receive) Context.DefaultReceive, (inner, outer) => outer(inner)); + }); + } + + public Props WithSpawner(Spawner spawner) + { + return Copy(props => props.Spawner = spawner); + } + + private Props Copy(Action mutator) + { + var props = new Props + { + Dispatcher = Dispatcher, + MailboxProducer = MailboxProducer, + Producer = Producer, + Middleware = Middleware, + MiddlewareChain = MiddlewareChain, + Spawner = Spawner, + SupervisorStrategy = SupervisorStrategy + }; + mutator(props); + return props; + } + + public PID Spawn(string name, PID parent) + { + return Spawner(name, this, parent); + } + } + + public delegate PID Spawner(string id, Props props, PID parent); } \ No newline at end of file diff --git a/src/Proto.Actor/Proto.Actor.csproj b/src/Proto.Actor/Proto.Actor.csproj index e49432a235..d030719456 100644 --- a/src/Proto.Actor/Proto.Actor.csproj +++ b/src/Proto.Actor/Proto.Actor.csproj @@ -1,22 +1,22 @@ - - - Proto - - - netstandard1.6 - - - library - - - - - - - - - - - - + + + Proto + + + netstandard1.6 + + + library + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Proto.Actor/Protos.g.cs b/src/Proto.Actor/Protos.g.cs index 30cecdec7d..7455562581 100644 --- a/src/Proto.Actor/Protos.g.cs +++ b/src/Proto.Actor/Protos.g.cs @@ -1,776 +1,776 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: Protos.proto -#pragma warning disable 1591, 0612, 3021 -#region Designer generated code - -using pb = global::Google.Protobuf; -using pbc = global::Google.Protobuf.Collections; -using pbr = global::Google.Protobuf.Reflection; -using scg = global::System.Collections.Generic; -namespace Proto { - - /// Holder for reflection information generated from Protos.proto - public static partial class ProtosReflection { - - #region Descriptor - /// File descriptor for Protos.proto - public static pbr::FileDescriptor Descriptor { - get { return descriptor; } - } - private static pbr::FileDescriptor descriptor; - - static ProtosReflection() { - byte[] descriptorData = global::System.Convert.FromBase64String( - string.Concat( - "CgxQcm90b3MucHJvdG8SBWFjdG9yIiIKA1BJRBIPCgdBZGRyZXNzGAEgASgJ", - "EgoKAklkGAIgASgJIgwKClBvaXNvblBpbGwiJAoFV2F0Y2gSGwoHd2F0Y2hl", - "chgBIAEoCzIKLmFjdG9yLlBJRCImCgdVbndhdGNoEhsKB3dhdGNoZXIYASAB", - "KAsyCi5hY3Rvci5QSUQiQAoKVGVybWluYXRlZBIXCgN3aG8YASABKAsyCi5h", - "Y3Rvci5QSUQSGQoRQWRkcmVzc1Rlcm1pbmF0ZWQYAiABKAgiBgoEU3RvcEII", - "qgIFUHJvdG9iBnByb3RvMw==")); - descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { }, - new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.PID), global::Proto.PID.Parser, new[]{ "Address", "Id" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.PoisonPill), global::Proto.PoisonPill.Parser, null, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Watch), global::Proto.Watch.Parser, new[]{ "Watcher" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Unwatch), global::Proto.Unwatch.Parser, new[]{ "Watcher" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Terminated), global::Proto.Terminated.Parser, new[]{ "Who", "AddressTerminated" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Stop), global::Proto.Stop.Parser, null, null, null, null) - })); - } - #endregion - - } - #region Messages - public sealed partial class PID : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PID()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[0]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PID() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PID(PID other) : this() { - address_ = other.address_; - id_ = other.id_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PID Clone() { - return new PID(this); - } - - /// Field number for the "Address" field. - public const int AddressFieldNumber = 1; - private string address_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Address { - get { return address_; } - set { - address_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - /// Field number for the "Id" field. - public const int IdFieldNumber = 2; - private string id_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string Id { - get { return id_; } - set { - id_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as PID); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(PID other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (Address != other.Address) return false; - if (Id != other.Id) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (Address.Length != 0) hash ^= Address.GetHashCode(); - if (Id.Length != 0) hash ^= Id.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (Address.Length != 0) { - output.WriteRawTag(10); - output.WriteString(Address); - } - if (Id.Length != 0) { - output.WriteRawTag(18); - output.WriteString(Id); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (Address.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Address); - } - if (Id.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(Id); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(PID other) { - if (other == null) { - return; - } - if (other.Address.Length != 0) { - Address = other.Address; - } - if (other.Id.Length != 0) { - Id = other.Id; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - Address = input.ReadString(); - break; - } - case 18: { - Id = input.ReadString(); - break; - } - } - } - } - - } - - /// - /// user messages - /// - public sealed partial class PoisonPill : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PoisonPill()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[1]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PoisonPill() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PoisonPill(PoisonPill other) : this() { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public PoisonPill Clone() { - return new PoisonPill(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as PoisonPill); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(PoisonPill other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(PoisonPill other) { - if (other == null) { - return; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - } - } - } - - } - - /// - /// system messages - /// - public sealed partial class Watch : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Watch()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[2]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Watch() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Watch(Watch other) : this() { - Watcher = other.watcher_ != null ? other.Watcher.Clone() : null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Watch Clone() { - return new Watch(this); - } - - /// Field number for the "watcher" field. - public const int WatcherFieldNumber = 1; - private global::Proto.PID watcher_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Watcher { - get { return watcher_; } - set { - watcher_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Watch); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Watch other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Watcher, other.Watcher)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (watcher_ != null) hash ^= Watcher.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (watcher_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Watcher); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (watcher_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Watcher); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Watch other) { - if (other == null) { - return; - } - if (other.watcher_ != null) { - if (watcher_ == null) { - watcher_ = new global::Proto.PID(); - } - Watcher.MergeFrom(other.Watcher); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - if (watcher_ == null) { - watcher_ = new global::Proto.PID(); - } - input.ReadMessage(watcher_); - break; - } - } - } - } - - } - - public sealed partial class Unwatch : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Unwatch()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Unwatch() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Unwatch(Unwatch other) : this() { - Watcher = other.watcher_ != null ? other.Watcher.Clone() : null; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Unwatch Clone() { - return new Unwatch(this); - } - - /// Field number for the "watcher" field. - public const int WatcherFieldNumber = 1; - private global::Proto.PID watcher_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Watcher { - get { return watcher_; } - set { - watcher_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Unwatch); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Unwatch other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Watcher, other.Watcher)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (watcher_ != null) hash ^= Watcher.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (watcher_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Watcher); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (watcher_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Watcher); - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Unwatch other) { - if (other == null) { - return; - } - if (other.watcher_ != null) { - if (watcher_ == null) { - watcher_ = new global::Proto.PID(); - } - Watcher.MergeFrom(other.Watcher); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - if (watcher_ == null) { - watcher_ = new global::Proto.PID(); - } - input.ReadMessage(watcher_); - break; - } - } - } - } - - } - - public sealed partial class Terminated : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Terminated()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[4]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Terminated() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Terminated(Terminated other) : this() { - Who = other.who_ != null ? other.Who.Clone() : null; - addressTerminated_ = other.addressTerminated_; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Terminated Clone() { - return new Terminated(this); - } - - /// Field number for the "who" field. - public const int WhoFieldNumber = 1; - private global::Proto.PID who_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Who { - get { return who_; } - set { - who_ = value; - } - } - - /// Field number for the "AddressTerminated" field. - public const int AddressTerminatedFieldNumber = 2; - private bool addressTerminated_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool AddressTerminated { - get { return addressTerminated_; } - set { - addressTerminated_ = value; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Terminated); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Terminated other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if (!object.Equals(Who, other.Who)) return false; - if (AddressTerminated != other.AddressTerminated) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - if (who_ != null) hash ^= Who.GetHashCode(); - if (AddressTerminated != false) hash ^= AddressTerminated.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - if (who_ != null) { - output.WriteRawTag(10); - output.WriteMessage(Who); - } - if (AddressTerminated != false) { - output.WriteRawTag(16); - output.WriteBool(AddressTerminated); - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - if (who_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Who); - } - if (AddressTerminated != false) { - size += 1 + 1; - } - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Terminated other) { - if (other == null) { - return; - } - if (other.who_ != null) { - if (who_ == null) { - who_ = new global::Proto.PID(); - } - Who.MergeFrom(other.Who); - } - if (other.AddressTerminated != false) { - AddressTerminated = other.AddressTerminated; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - if (who_ == null) { - who_ = new global::Proto.PID(); - } - input.ReadMessage(who_); - break; - } - case 16: { - AddressTerminated = input.ReadBool(); - break; - } - } - } - } - - } - - public sealed partial class Stop : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Stop()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[5]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Stop() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Stop(Stop other) : this() { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public Stop Clone() { - return new Stop(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as Stop); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(Stop other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(Stop other) { - if (other == null) { - return; - } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - } - } - } - - } - - #endregion - -} - -#endregion Designer generated code +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: Protos.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Proto { + + /// Holder for reflection information generated from Protos.proto + public static partial class ProtosReflection { + + #region Descriptor + /// File descriptor for Protos.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ProtosReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CgxQcm90b3MucHJvdG8SBWFjdG9yIiIKA1BJRBIPCgdBZGRyZXNzGAEgASgJ", + "EgoKAklkGAIgASgJIgwKClBvaXNvblBpbGwiJAoFV2F0Y2gSGwoHd2F0Y2hl", + "chgBIAEoCzIKLmFjdG9yLlBJRCImCgdVbndhdGNoEhsKB3dhdGNoZXIYASAB", + "KAsyCi5hY3Rvci5QSUQiQAoKVGVybWluYXRlZBIXCgN3aG8YASABKAsyCi5h", + "Y3Rvci5QSUQSGQoRQWRkcmVzc1Rlcm1pbmF0ZWQYAiABKAgiBgoEU3RvcEII", + "qgIFUHJvdG9iBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.PID), global::Proto.PID.Parser, new[]{ "Address", "Id" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.PoisonPill), global::Proto.PoisonPill.Parser, null, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Watch), global::Proto.Watch.Parser, new[]{ "Watcher" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Unwatch), global::Proto.Unwatch.Parser, new[]{ "Watcher" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Terminated), global::Proto.Terminated.Parser, new[]{ "Who", "AddressTerminated" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Stop), global::Proto.Stop.Parser, null, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class PID : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PID()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PID() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PID(PID other) : this() { + address_ = other.address_; + id_ = other.id_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PID Clone() { + return new PID(this); + } + + /// Field number for the "Address" field. + public const int AddressFieldNumber = 1; + private string address_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Address { + get { return address_; } + set { + address_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "Id" field. + public const int IdFieldNumber = 2; + private string id_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Id { + get { return id_; } + set { + id_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PID); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PID other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Address != other.Address) return false; + if (Id != other.Id) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Address.Length != 0) hash ^= Address.GetHashCode(); + if (Id.Length != 0) hash ^= Id.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Address.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Address); + } + if (Id.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Id); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Address.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Address); + } + if (Id.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Id); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PID other) { + if (other == null) { + return; + } + if (other.Address.Length != 0) { + Address = other.Address; + } + if (other.Id.Length != 0) { + Id = other.Id; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Address = input.ReadString(); + break; + } + case 18: { + Id = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// user messages + /// + public sealed partial class PoisonPill : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new PoisonPill()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PoisonPill() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PoisonPill(PoisonPill other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public PoisonPill Clone() { + return new PoisonPill(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as PoisonPill); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(PoisonPill other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(PoisonPill other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + /// + /// system messages + /// + public sealed partial class Watch : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Watch()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Watch() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Watch(Watch other) : this() { + Watcher = other.watcher_ != null ? other.Watcher.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Watch Clone() { + return new Watch(this); + } + + /// Field number for the "watcher" field. + public const int WatcherFieldNumber = 1; + private global::Proto.PID watcher_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Proto.PID Watcher { + get { return watcher_; } + set { + watcher_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Watch); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Watch other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Watcher, other.Watcher)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (watcher_ != null) hash ^= Watcher.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (watcher_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Watcher); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (watcher_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Watcher); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Watch other) { + if (other == null) { + return; + } + if (other.watcher_ != null) { + if (watcher_ == null) { + watcher_ = new global::Proto.PID(); + } + Watcher.MergeFrom(other.Watcher); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (watcher_ == null) { + watcher_ = new global::Proto.PID(); + } + input.ReadMessage(watcher_); + break; + } + } + } + } + + } + + public sealed partial class Unwatch : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Unwatch()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unwatch() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unwatch(Unwatch other) : this() { + Watcher = other.watcher_ != null ? other.Watcher.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Unwatch Clone() { + return new Unwatch(this); + } + + /// Field number for the "watcher" field. + public const int WatcherFieldNumber = 1; + private global::Proto.PID watcher_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Proto.PID Watcher { + get { return watcher_; } + set { + watcher_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Unwatch); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Unwatch other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Watcher, other.Watcher)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (watcher_ != null) hash ^= Watcher.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (watcher_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Watcher); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (watcher_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Watcher); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Unwatch other) { + if (other == null) { + return; + } + if (other.watcher_ != null) { + if (watcher_ == null) { + watcher_ = new global::Proto.PID(); + } + Watcher.MergeFrom(other.Watcher); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (watcher_ == null) { + watcher_ = new global::Proto.PID(); + } + input.ReadMessage(watcher_); + break; + } + } + } + } + + } + + public sealed partial class Terminated : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Terminated()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Terminated() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Terminated(Terminated other) : this() { + Who = other.who_ != null ? other.Who.Clone() : null; + addressTerminated_ = other.addressTerminated_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Terminated Clone() { + return new Terminated(this); + } + + /// Field number for the "who" field. + public const int WhoFieldNumber = 1; + private global::Proto.PID who_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Proto.PID Who { + get { return who_; } + set { + who_ = value; + } + } + + /// Field number for the "AddressTerminated" field. + public const int AddressTerminatedFieldNumber = 2; + private bool addressTerminated_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool AddressTerminated { + get { return addressTerminated_; } + set { + addressTerminated_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Terminated); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Terminated other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (!object.Equals(Who, other.Who)) return false; + if (AddressTerminated != other.AddressTerminated) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (who_ != null) hash ^= Who.GetHashCode(); + if (AddressTerminated != false) hash ^= AddressTerminated.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (who_ != null) { + output.WriteRawTag(10); + output.WriteMessage(Who); + } + if (AddressTerminated != false) { + output.WriteRawTag(16); + output.WriteBool(AddressTerminated); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (who_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Who); + } + if (AddressTerminated != false) { + size += 1 + 1; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Terminated other) { + if (other == null) { + return; + } + if (other.who_ != null) { + if (who_ == null) { + who_ = new global::Proto.PID(); + } + Who.MergeFrom(other.Who); + } + if (other.AddressTerminated != false) { + AddressTerminated = other.AddressTerminated; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + if (who_ == null) { + who_ = new global::Proto.PID(); + } + input.ReadMessage(who_); + break; + } + case 16: { + AddressTerminated = input.ReadBool(); + break; + } + } + } + } + + } + + public sealed partial class Stop : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Stop()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.ProtosReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Stop() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Stop(Stop other) : this() { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public Stop Clone() { + return new Stop(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as Stop); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(Stop other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(Stop other) { + if (other == null) { + return; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/Proto.Actor/Protos.proto b/src/Proto.Actor/Protos.proto index 392e77f1cc..0deff9d666 100644 --- a/src/Proto.Actor/Protos.proto +++ b/src/Proto.Actor/Protos.proto @@ -1,27 +1,27 @@ -syntax = "proto3"; -package actor; -option csharp_namespace = "Proto"; - -message PID { - string Address = 1; - string Id = 2; -} - -//user messages -message PoisonPill {} - -//system messages -message Watch { - PID watcher = 1; -} - -message Unwatch { - PID watcher = 1; -} - -message Terminated { - PID who = 1; - bool AddressTerminated = 2; -} - -message Stop {} +syntax = "proto3"; +package actor; +option csharp_namespace = "Proto"; + +message PID { + string Address = 1; + string Id = 2; +} + +//user messages +message PoisonPill {} + +//system messages +message Watch { + PID watcher = 1; +} + +message Unwatch { + PID watcher = 1; +} + +message Terminated { + PID who = 1; + bool AddressTerminated = 2; +} + +message Stop {} diff --git a/src/Proto.Actor/RestartStatistics.cs b/src/Proto.Actor/RestartStatistics.cs index 87113e586f..8840a97984 100644 --- a/src/Proto.Actor/RestartStatistics.cs +++ b/src/Proto.Actor/RestartStatistics.cs @@ -1,49 +1,49 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; - -namespace Proto -{ - public class RestartStatistics - { - public RestartStatistics(int failureCount, DateTime? lastFailuretime) - { - FailureCount = failureCount; - LastFailureTime = lastFailuretime; - } - - public int FailureCount { get; set; } - public DateTime? LastFailureTime { get; set; } - - - public bool RequestRestartPermission(int maxNrOfRetries, TimeSpan? withinTimeSpan) - { - if (maxNrOfRetries == 0) - { - return false; - } - - FailureCount++; - - //supervisor says child may restart, and we don't care about any timewindow - if (withinTimeSpan == null) - { - return FailureCount <= maxNrOfRetries; - } - - var max = DateTime.Now - withinTimeSpan; - if (LastFailureTime > max) - { - return FailureCount <= maxNrOfRetries; - } - - //we are past the time limit, we can safely reset the failure count and restart - FailureCount = 0; - return true; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; + +namespace Proto +{ + public class RestartStatistics + { + public RestartStatistics(int failureCount, DateTime? lastFailuretime) + { + FailureCount = failureCount; + LastFailureTime = lastFailuretime; + } + + public int FailureCount { get; set; } + public DateTime? LastFailureTime { get; set; } + + + public bool RequestRestartPermission(int maxNrOfRetries, TimeSpan? withinTimeSpan) + { + if (maxNrOfRetries == 0) + { + return false; + } + + FailureCount++; + + //supervisor says child may restart, and we don't care about any timewindow + if (withinTimeSpan == null) + { + return FailureCount <= maxNrOfRetries; + } + + var max = DateTime.Now - withinTimeSpan; + if (LastFailureTime > max) + { + return FailureCount <= maxNrOfRetries; + } + + //we are past the time limit, we can safely reset the failure count and restart + FailureCount = 0; + return true; + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/Supervision.cs b/src/Proto.Actor/Supervision.cs index 3067f8bff9..225c07766e 100644 --- a/src/Proto.Actor/Supervision.cs +++ b/src/Proto.Actor/Supervision.cs @@ -1,114 +1,114 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2016 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using Proto.Mailbox; - -namespace Proto -{ - public enum SupervisorDirective - { - Resume, - Restart, - Stop, - Escalate - } - - public interface ISupervisor - { - IReadOnlyCollection Children { get; } - void EscalateFailure(PID who, Exception reason); - } - - public static class Supervision - { - public static ISupervisorStrategy DefaultStrategy { get; } = - new OneForOneStrategy((who, reason) => SupervisorDirective.Restart,10, TimeSpan.FromSeconds(10)); - } - - public interface ISupervisorStrategy - { - void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics crs, Exception cause); - } - - public delegate SupervisorDirective Decider(PID pid, Exception reason); - - public class OneForOneStrategy : ISupervisorStrategy - { - private readonly int _maxNrOfRetries; - private readonly TimeSpan? _withinTimeSpan; - private readonly Decider _decider; - - public OneForOneStrategy(Decider decider, int maxNrOfRetries, TimeSpan? withinTimeSpan) - { - _decider = decider; - _maxNrOfRetries = maxNrOfRetries; - _withinTimeSpan = withinTimeSpan; - } - - //public bool RequestRestartPermission(int maxNrOfRetries, TimeSpan? withinTimeSpan) - //{ - // if (maxNrOfRetries == 0) - // { - // return false; - // } - - // FailureCount++; - - // //supervisor says child may restart, and we don't care about any timewindow - // if (withinTimeSpan == null) - // { - // return FailureCount <= maxNrOfRetries; - // } - - // var max = DateTime.Now - withinTimeSpan; - // if (LastFailureTime > max) - // { - // return FailureCount <= maxNrOfRetries; - // } - - // //we are past the time limit, we can safely reset the failure count and restart - // FailureCount = 0; - // return true; - //} - - public void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics crs, Exception reason) - { - var directive = _decider(child, reason); - switch (directive) - { - case SupervisorDirective.Resume: - //resume the failing child - child.SendSystemMessage(ResumeMailbox.Instance); - break; - case SupervisorDirective.Restart: - //restart the failing child - if (crs.RequestRestartPermission(_maxNrOfRetries, _withinTimeSpan)) - { - Console.WriteLine($"Restarting {child.ToShortString()} Reason {reason}"); - child.SendSystemMessage(Restart.Instance); - } - else - { - Console.WriteLine($"Stopping {child.ToShortString()} Reason { reason}"); - child.Stop(); - } - break; - case SupervisorDirective.Stop: - //stop the failing child - Console.WriteLine($"Stopping {child.ToShortString()} Reason {reason}"); - child.Stop(); - break; - case SupervisorDirective.Escalate: - supervisor.EscalateFailure(child, reason); - break; - default: - throw new ArgumentOutOfRangeException(); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2016 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using Proto.Mailbox; + +namespace Proto +{ + public enum SupervisorDirective + { + Resume, + Restart, + Stop, + Escalate + } + + public interface ISupervisor + { + IReadOnlyCollection Children { get; } + void EscalateFailure(PID who, Exception reason); + } + + public static class Supervision + { + public static ISupervisorStrategy DefaultStrategy { get; } = + new OneForOneStrategy((who, reason) => SupervisorDirective.Restart,10, TimeSpan.FromSeconds(10)); + } + + public interface ISupervisorStrategy + { + void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics crs, Exception cause); + } + + public delegate SupervisorDirective Decider(PID pid, Exception reason); + + public class OneForOneStrategy : ISupervisorStrategy + { + private readonly int _maxNrOfRetries; + private readonly TimeSpan? _withinTimeSpan; + private readonly Decider _decider; + + public OneForOneStrategy(Decider decider, int maxNrOfRetries, TimeSpan? withinTimeSpan) + { + _decider = decider; + _maxNrOfRetries = maxNrOfRetries; + _withinTimeSpan = withinTimeSpan; + } + + //public bool RequestRestartPermission(int maxNrOfRetries, TimeSpan? withinTimeSpan) + //{ + // if (maxNrOfRetries == 0) + // { + // return false; + // } + + // FailureCount++; + + // //supervisor says child may restart, and we don't care about any timewindow + // if (withinTimeSpan == null) + // { + // return FailureCount <= maxNrOfRetries; + // } + + // var max = DateTime.Now - withinTimeSpan; + // if (LastFailureTime > max) + // { + // return FailureCount <= maxNrOfRetries; + // } + + // //we are past the time limit, we can safely reset the failure count and restart + // FailureCount = 0; + // return true; + //} + + public void HandleFailure(ISupervisor supervisor, PID child, RestartStatistics crs, Exception reason) + { + var directive = _decider(child, reason); + switch (directive) + { + case SupervisorDirective.Resume: + //resume the failing child + child.SendSystemMessage(ResumeMailbox.Instance); + break; + case SupervisorDirective.Restart: + //restart the failing child + if (crs.RequestRestartPermission(_maxNrOfRetries, _withinTimeSpan)) + { + Console.WriteLine($"Restarting {child.ToShortString()} Reason {reason}"); + child.SendSystemMessage(Restart.Instance); + } + else + { + Console.WriteLine($"Stopping {child.ToShortString()} Reason { reason}"); + child.Stop(); + } + break; + case SupervisorDirective.Stop: + //stop the failing child + Console.WriteLine($"Stopping {child.ToShortString()} Reason {reason}"); + child.Stop(); + break; + case SupervisorDirective.Escalate: + supervisor.EscalateFailure(child, reason); + break; + default: + throw new ArgumentOutOfRangeException(); + } + } + } } \ No newline at end of file diff --git a/src/Proto.Actor/build.bat b/src/Proto.Actor/build.bat index 5f4a83f4b0..7994256f14 100644 --- a/src/Proto.Actor/build.bat +++ b/src/Proto.Actor/build.bat @@ -1 +1 @@ -protoc Protos.proto -I. --csharp_out=. --csharp_opt=file_extension=.g.cs --grpc_out . --plugin=protoc-gen-grpc=%home%\.nuget\packages\Grpc.Tools\1.0.1\tools\windows_x64\grpc_csharp_plugin.exe \ No newline at end of file +protoc Protos.proto -I. --csharp_out=. --csharp_opt=file_extension=.g.cs --grpc_out . --plugin=protoc-gen-grpc=%USERPROFILE%\.nuget\packages\Grpc.Tools\1.0.1\tools\windows_x64\grpc_csharp_plugin.exe \ No newline at end of file diff --git a/src/Proto.Mailbox/BoundedMailboxQueue.cs b/src/Proto.Mailbox/BoundedMailboxQueue.cs index 902d328b14..c17f486392 100644 --- a/src/Proto.Mailbox/BoundedMailboxQueue.cs +++ b/src/Proto.Mailbox/BoundedMailboxQueue.cs @@ -1,32 +1,32 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Mailbox -{ - public class BoundedMailboxQueue : IMailboxQueue - { - private readonly MPMCQueue _messages; - - public BoundedMailboxQueue(int size) - { - _messages = new MPMCQueue(size); - } - - public void Push(object message) - { - _messages.Enqueue(message); - } - - public object Pop() - { - return _messages.TryDequeue(out var message) - ? message - : null; - } - - public bool HasMessages => _messages.Count > 0; - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Mailbox +{ + public class BoundedMailboxQueue : IMailboxQueue + { + private readonly MPMCQueue _messages; + + public BoundedMailboxQueue(int size) + { + _messages = new MPMCQueue(size); + } + + public void Push(object message) + { + _messages.Enqueue(message); + } + + public object Pop() + { + return _messages.TryDequeue(out var message) + ? message + : null; + } + + public bool HasMessages => _messages.Count > 0; + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/Dispatcher.cs b/src/Proto.Mailbox/Dispatcher.cs index f789ff686d..d94056530d 100644 --- a/src/Proto.Mailbox/Dispatcher.cs +++ b/src/Proto.Mailbox/Dispatcher.cs @@ -1,45 +1,45 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading.Tasks; - -namespace Proto.Mailbox -{ - public interface IMessageInvoker - { - Task InvokeSystemMessageAsync(object msg); - Task InvokeUserMessageAsync(object msg); - void EscalateFailure(Exception reason, object message); - } - - - public interface IDispatcher - { - int Throughput { get; } - void Schedule(Func runner); - } - - public static class Dispatchers - { - public static ThreadPoolDispatcher DefaultDispatcher { get; } = new ThreadPoolDispatcher(); - } - - public sealed class ThreadPoolDispatcher : IDispatcher - { - public ThreadPoolDispatcher() - { - Throughput = 300; - } - - public void Schedule(Func runner) - { - Task.Factory.StartNew(runner, TaskCreationOptions.None); - } - - public int Throughput { get; set; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading.Tasks; + +namespace Proto.Mailbox +{ + public interface IMessageInvoker + { + Task InvokeSystemMessageAsync(object msg); + Task InvokeUserMessageAsync(object msg); + void EscalateFailure(Exception reason, object message); + } + + + public interface IDispatcher + { + int Throughput { get; } + void Schedule(Func runner); + } + + public static class Dispatchers + { + public static ThreadPoolDispatcher DefaultDispatcher { get; } = new ThreadPoolDispatcher(); + } + + public sealed class ThreadPoolDispatcher : IDispatcher + { + public ThreadPoolDispatcher() + { + Throughput = 300; + } + + public void Schedule(Func runner) + { + Task.Factory.StartNew(runner, TaskCreationOptions.None); + } + + public int Throughput { get; set; } + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/MPMCQueue.cs b/src/Proto.Mailbox/MPMCQueue.cs index d0d142b81d..702193f6b4 100644 --- a/src/Proto.Mailbox/MPMCQueue.cs +++ b/src/Proto.Mailbox/MPMCQueue.cs @@ -1,145 +1,145 @@ -// Based on MPMCQueue.NET by Alexandr Nikitin -// https://github.com/alexandrnikitin/MPMCQueue.NET -// -// Original license: -// -// MIT License -// -// Copyright(c) 2016 Alexandr Nikitin -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. - -using System; -using System.Runtime.InteropServices; -using System.Threading; - -namespace Proto.Mailbox -{ - [StructLayout(LayoutKind.Explicit, Size = 192, CharSet = CharSet.Ansi)] - public class MPMCQueue - { - [FieldOffset(0)] - private readonly Cell[] _buffer; - [FieldOffset(8)] - private readonly int _bufferMask; - [FieldOffset(64)] - private int _enqueuePos; - [FieldOffset(128)] - private int _dequeuePos; - - public int Count => _enqueuePos - _dequeuePos; - - public MPMCQueue(int bufferSize) - { - if (bufferSize < 2) throw new ArgumentException($"{nameof(bufferSize)} should be greater than 2"); - if ((bufferSize & (bufferSize - 1)) != 0) throw new ArgumentException($"{nameof(bufferSize)} should be a power of 2"); - - _bufferMask = bufferSize - 1; - _buffer = new Cell[bufferSize]; - - for (var i = 0; i < bufferSize; i++) - { - _buffer[i] = new Cell(i, null); - } - - _enqueuePos = 0; - _dequeuePos = 0; - } - - public bool TryEnqueue(object item) - { - do - { - var buffer = _buffer; - var pos = _enqueuePos; - var index = pos & _bufferMask; - var cell = buffer[index]; - if (cell.Sequence == pos && Interlocked.CompareExchange(ref _enqueuePos, pos + 1, pos) == pos) - { - Volatile.Write(ref buffer[index].Element, item); - buffer[index].Sequence = pos + 1; - return true; - } - - if (cell.Sequence < pos) - { - return false; - } - } while (true); - } - - public void Enqueue(object item) - { - while(true) - { - if (TryEnqueue(item)) - break; - } - } - - public bool TryDequeue(out object result) - { - do - { - var buffer = _buffer; - var bufferMask = _bufferMask; - var pos = _dequeuePos; - var index = pos & bufferMask; - var cell = buffer[index]; - if (cell.Sequence == pos + 1 && Interlocked.CompareExchange(ref _dequeuePos, pos + 1, pos) == pos) - { - result = Volatile.Read(ref cell.Element); - buffer[index] = new Cell(pos + bufferMask + 1, null); - return true; - } - - if (cell.Sequence < pos + 1) - { - result = default(object); - return false; - } - } while (true); - } - - public object Dequeue() - { - while (true) - { - object o; - if (TryDequeue(out o)) - return o; - } - } - - [StructLayout(LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi)] - private struct Cell - { - [FieldOffset(0)] - public int Sequence; - [FieldOffset(8)] - public object Element; - - public Cell(int sequence, object element) - { - Sequence = sequence; - Element = element; - } - } - } +// Based on MPMCQueue.NET by Alexandr Nikitin +// https://github.com/alexandrnikitin/MPMCQueue.NET +// +// Original license: +// +// MIT License +// +// Copyright(c) 2016 Alexandr Nikitin +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +using System; +using System.Runtime.InteropServices; +using System.Threading; + +namespace Proto.Mailbox +{ + [StructLayout(LayoutKind.Explicit, Size = 192, CharSet = CharSet.Ansi)] + public class MPMCQueue + { + [FieldOffset(0)] + private readonly Cell[] _buffer; + [FieldOffset(8)] + private readonly int _bufferMask; + [FieldOffset(64)] + private int _enqueuePos; + [FieldOffset(128)] + private int _dequeuePos; + + public int Count => _enqueuePos - _dequeuePos; + + public MPMCQueue(int bufferSize) + { + if (bufferSize < 2) throw new ArgumentException($"{nameof(bufferSize)} should be greater than 2"); + if ((bufferSize & (bufferSize - 1)) != 0) throw new ArgumentException($"{nameof(bufferSize)} should be a power of 2"); + + _bufferMask = bufferSize - 1; + _buffer = new Cell[bufferSize]; + + for (var i = 0; i < bufferSize; i++) + { + _buffer[i] = new Cell(i, null); + } + + _enqueuePos = 0; + _dequeuePos = 0; + } + + public bool TryEnqueue(object item) + { + do + { + var buffer = _buffer; + var pos = _enqueuePos; + var index = pos & _bufferMask; + var cell = buffer[index]; + if (cell.Sequence == pos && Interlocked.CompareExchange(ref _enqueuePos, pos + 1, pos) == pos) + { + Volatile.Write(ref buffer[index].Element, item); + buffer[index].Sequence = pos + 1; + return true; + } + + if (cell.Sequence < pos) + { + return false; + } + } while (true); + } + + public void Enqueue(object item) + { + while(true) + { + if (TryEnqueue(item)) + break; + } + } + + public bool TryDequeue(out object result) + { + do + { + var buffer = _buffer; + var bufferMask = _bufferMask; + var pos = _dequeuePos; + var index = pos & bufferMask; + var cell = buffer[index]; + if (cell.Sequence == pos + 1 && Interlocked.CompareExchange(ref _dequeuePos, pos + 1, pos) == pos) + { + result = Volatile.Read(ref cell.Element); + buffer[index] = new Cell(pos + bufferMask + 1, null); + return true; + } + + if (cell.Sequence < pos + 1) + { + result = default(object); + return false; + } + } while (true); + } + + public object Dequeue() + { + while (true) + { + object o; + if (TryDequeue(out o)) + return o; + } + } + + [StructLayout(LayoutKind.Explicit, Size = 16, CharSet = CharSet.Ansi)] + private struct Cell + { + [FieldOffset(0)] + public int Sequence; + [FieldOffset(8)] + public object Element; + + public Cell(int sequence, object element) + { + Sequence = sequence; + Element = element; + } + } + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/Mailbox.cs b/src/Proto.Mailbox/Mailbox.cs index 58c5941ef4..32a121ed4f 100644 --- a/src/Proto.Mailbox/Mailbox.cs +++ b/src/Proto.Mailbox/Mailbox.cs @@ -1,168 +1,168 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Threading; -using System.Threading.Tasks; - -namespace Proto.Mailbox -{ - internal static class MailboxStatus - { - public const int Idle = 0; - public const int Busy = 1; - } - - public interface IMailbox - { - void PostUserMessage(object msg); - void PostSystemMessage(object msg); - void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher); - void Start(); - } - - public class DefaultMailbox : IMailbox - { - private readonly IMailboxStatistics[] _stats; - private readonly IMailboxQueue _systemMessages; - private readonly IMailboxQueue _userMailbox; - private IDispatcher _dispatcher; - private IMessageInvoker _invoker; - - private int _status = MailboxStatus.Idle; - private bool _suspended; - - public DefaultMailbox(IMailboxQueue systemMessages, IMailboxQueue userMailbox, params IMailboxStatistics[] stats) - { - _systemMessages = systemMessages; - _userMailbox = userMailbox; - _stats = stats ?? Array.Empty(); - } - - public void PostUserMessage(object msg) - { - _userMailbox.Push(msg); - for (var i = 0; i < _stats.Length; i++) - { - _stats[i].MessagePosted(msg); - } - Schedule(); - } - - public void PostSystemMessage(object msg) - { - _systemMessages.Push(msg); - Schedule(); - } - - public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) - { - _invoker = invoker; - _dispatcher = dispatcher; - } - - public void Start() - { - for (var i = 0; i < _stats.Length; i++) - { - _stats[i].MailboxStarted(); - } - } - - private async Task RunAsync() - { - //we follow the Go model for consistency. - process: - await ProcessMessages(); - - Interlocked.Exchange(ref _status, MailboxStatus.Idle); - - if (_systemMessages.HasMessages || !_suspended && _userMailbox.HasMessages) - { - if (Interlocked.CompareExchange(ref _status, MailboxStatus.Busy, MailboxStatus.Idle) == - MailboxStatus.Idle) - { - await Task.Yield(); - goto process; - } - } - else - { - for (var i = 0; i < _stats.Length; i++) - { - _stats[i].MailboxEmpty(); - } - } - } - - //TODO: we can gain a good 10% perf by not having async here. - //but then we need some way to deal with non completed tasks, and handle mailbox idle/busy state for those - private async Task ProcessMessages() - { - var t = _dispatcher.Throughput; - object message = null; - try - { - for (var i = 0; i < t; i++) - { - var sys = _systemMessages.Pop(); - message = sys; - if (sys != null) - { - if (sys is SuspendMailbox) - { - _suspended = true; - } - if (sys is ResumeMailbox) - { - _suspended = false; - } - await _invoker.InvokeSystemMessageAsync(sys); - continue; - } - if (_suspended) - { - break; - } - var msg = _userMailbox.Pop(); - if (msg != null) - { - message = msg; - await _invoker.InvokeUserMessageAsync(msg); - for (var si = 0; si < _stats.Length; si++) - { - _stats[si].MessageReceived(msg); - } - } - else - { - break; - } - } - } - catch (Exception x) - { - _invoker.EscalateFailure(x, message); - } - } - - protected void Schedule() - { - if (Interlocked.CompareExchange(ref _status, MailboxStatus.Busy, MailboxStatus.Idle) == MailboxStatus.Idle) - { - _dispatcher.Schedule(RunAsync); - } - } - } - - public interface IMailboxStatistics - { - void MailboxStarted(); - void MessagePosted(object message); - void MessageReceived(object message); - void MailboxEmpty(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Threading; +using System.Threading.Tasks; + +namespace Proto.Mailbox +{ + internal static class MailboxStatus + { + public const int Idle = 0; + public const int Busy = 1; + } + + public interface IMailbox + { + void PostUserMessage(object msg); + void PostSystemMessage(object msg); + void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher); + void Start(); + } + + public class DefaultMailbox : IMailbox + { + private readonly IMailboxStatistics[] _stats; + private readonly IMailboxQueue _systemMessages; + private readonly IMailboxQueue _userMailbox; + private IDispatcher _dispatcher; + private IMessageInvoker _invoker; + + private int _status = MailboxStatus.Idle; + private bool _suspended; + + public DefaultMailbox(IMailboxQueue systemMessages, IMailboxQueue userMailbox, params IMailboxStatistics[] stats) + { + _systemMessages = systemMessages; + _userMailbox = userMailbox; + _stats = stats ?? Array.Empty(); + } + + public void PostUserMessage(object msg) + { + _userMailbox.Push(msg); + for (var i = 0; i < _stats.Length; i++) + { + _stats[i].MessagePosted(msg); + } + Schedule(); + } + + public void PostSystemMessage(object msg) + { + _systemMessages.Push(msg); + Schedule(); + } + + public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) + { + _invoker = invoker; + _dispatcher = dispatcher; + } + + public void Start() + { + for (var i = 0; i < _stats.Length; i++) + { + _stats[i].MailboxStarted(); + } + } + + private async Task RunAsync() + { + //we follow the Go model for consistency. + process: + await ProcessMessages(); + + Interlocked.Exchange(ref _status, MailboxStatus.Idle); + + if (_systemMessages.HasMessages || !_suspended && _userMailbox.HasMessages) + { + if (Interlocked.CompareExchange(ref _status, MailboxStatus.Busy, MailboxStatus.Idle) == + MailboxStatus.Idle) + { + await Task.Yield(); + goto process; + } + } + else + { + for (var i = 0; i < _stats.Length; i++) + { + _stats[i].MailboxEmpty(); + } + } + } + + //TODO: we can gain a good 10% perf by not having async here. + //but then we need some way to deal with non completed tasks, and handle mailbox idle/busy state for those + private async Task ProcessMessages() + { + var t = _dispatcher.Throughput; + object message = null; + try + { + for (var i = 0; i < t; i++) + { + var sys = _systemMessages.Pop(); + message = sys; + if (sys != null) + { + if (sys is SuspendMailbox) + { + _suspended = true; + } + if (sys is ResumeMailbox) + { + _suspended = false; + } + await _invoker.InvokeSystemMessageAsync(sys); + continue; + } + if (_suspended) + { + break; + } + var msg = _userMailbox.Pop(); + if (msg != null) + { + message = msg; + await _invoker.InvokeUserMessageAsync(msg); + for (var si = 0; si < _stats.Length; si++) + { + _stats[si].MessageReceived(msg); + } + } + else + { + break; + } + } + } + catch (Exception x) + { + _invoker.EscalateFailure(x, message); + } + } + + protected void Schedule() + { + if (Interlocked.CompareExchange(ref _status, MailboxStatus.Busy, MailboxStatus.Idle) == MailboxStatus.Idle) + { + _dispatcher.Schedule(RunAsync); + } + } + } + + public interface IMailboxStatistics + { + void MailboxStarted(); + void MessagePosted(object message); + void MessageReceived(object message); + void MailboxEmpty(); + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/Messages.cs b/src/Proto.Mailbox/Messages.cs index 2bf0d7578f..0de81ad198 100644 --- a/src/Proto.Mailbox/Messages.cs +++ b/src/Proto.Mailbox/Messages.cs @@ -1,26 +1,26 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Mailbox -{ - public sealed class SuspendMailbox - { - public static readonly SuspendMailbox Instance = new SuspendMailbox(); - - private SuspendMailbox() - { - } - } - - public sealed class ResumeMailbox - { - public static readonly ResumeMailbox Instance = new ResumeMailbox(); - - private ResumeMailbox() - { - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Mailbox +{ + public sealed class SuspendMailbox + { + public static readonly SuspendMailbox Instance = new SuspendMailbox(); + + private SuspendMailbox() + { + } + } + + public sealed class ResumeMailbox + { + public static readonly ResumeMailbox Instance = new ResumeMailbox(); + + private ResumeMailbox() + { + } + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/Proto.Mailbox.csproj b/src/Proto.Mailbox/Proto.Mailbox.csproj index 271db691f5..351f1c4741 100644 --- a/src/Proto.Mailbox/Proto.Mailbox.csproj +++ b/src/Proto.Mailbox/Proto.Mailbox.csproj @@ -1,11 +1,11 @@ - - - Proto.Mailbox - - - netstandard1.6 - - - library - + + + Proto.Mailbox + + + netstandard1.6 + + + library + \ No newline at end of file diff --git a/src/Proto.Mailbox/Queue.cs b/src/Proto.Mailbox/Queue.cs index 9fd5c6fd4a..d87e311ed6 100644 --- a/src/Proto.Mailbox/Queue.cs +++ b/src/Proto.Mailbox/Queue.cs @@ -1,15 +1,15 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Mailbox -{ - public interface IMailboxQueue - { - bool HasMessages { get; } - void Push(object message); - object Pop(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Mailbox +{ + public interface IMailboxQueue + { + bool HasMessages { get; } + void Push(object message); + object Pop(); + } } \ No newline at end of file diff --git a/src/Proto.Mailbox/UnboundedMailboxQueue.cs b/src/Proto.Mailbox/UnboundedMailboxQueue.cs index 0162df141b..bba36caa37 100644 --- a/src/Proto.Mailbox/UnboundedMailboxQueue.cs +++ b/src/Proto.Mailbox/UnboundedMailboxQueue.cs @@ -1,28 +1,28 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Concurrent; - -namespace Proto.Mailbox -{ - public class UnboundedMailboxQueue : IMailboxQueue - { - private readonly ConcurrentQueue _messages = new ConcurrentQueue(); - - public void Push(object message) - { - _messages.Enqueue(message); - } - - public object Pop() - { - object message; - return _messages.TryDequeue(out message) ? message : null; - } - - public bool HasMessages => _messages.Count > 0; - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Concurrent; + +namespace Proto.Mailbox +{ + public class UnboundedMailboxQueue : IMailboxQueue + { + private readonly ConcurrentQueue _messages = new ConcurrentQueue(); + + public void Push(object message) + { + _messages.Enqueue(message); + } + + public object Pop() + { + object message; + return _messages.TryDequeue(out message) ? message : null; + } + + public bool HasMessages => _messages.Count > 0; + } } \ No newline at end of file diff --git a/src/Proto.Persistence/IPersistentActor.cs b/src/Proto.Persistence/IPersistentActor.cs index 78311e78e6..f2750de3fd 100644 --- a/src/Proto.Persistence/IPersistentActor.cs +++ b/src/Proto.Persistence/IPersistentActor.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Persistence -{ - public interface IPersistentActor : IActor - { - Persistence Persistence { get; set; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Persistence +{ + public interface IPersistentActor : IActor + { + Persistence Persistence { get; set; } + } } \ No newline at end of file diff --git a/src/Proto.Persistence/IProvider.cs b/src/Proto.Persistence/IProvider.cs index cb8496ce71..e3907d785a 100644 --- a/src/Proto.Persistence/IProvider.cs +++ b/src/Proto.Persistence/IProvider.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Persistence -{ - public interface IProvider - { - IProviderState GetState(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Persistence +{ + public interface IProvider + { + IProviderState GetState(); + } } \ No newline at end of file diff --git a/src/Proto.Persistence/IProviderState.cs b/src/Proto.Persistence/IProviderState.cs index 640a35fcf2..e2bab3aed2 100644 --- a/src/Proto.Persistence/IProviderState.cs +++ b/src/Proto.Persistence/IProviderState.cs @@ -1,21 +1,21 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Google.Protobuf; - -namespace Proto.Persistence -{ - public interface IProviderState - { - void GetEvents(string actorName, int eventIndexStart, Action callback); - Tuple GetSnapshot(string actorName); - int GetSnapshotInterval(); - void PersistEvent(string actorName, int eventIndex, IMessage @event); - void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot); - void Restart(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Google.Protobuf; + +namespace Proto.Persistence +{ + public interface IProviderState + { + void GetEvents(string actorName, int eventIndexStart, Action callback); + Tuple GetSnapshot(string actorName); + int GetSnapshotInterval(); + void PersistEvent(string actorName, int eventIndex, IMessage @event); + void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot); + void Restart(); + } } \ No newline at end of file diff --git a/src/Proto.Persistence/InMemoryProvider.cs b/src/Proto.Persistence/InMemoryProvider.cs index ca086dc456..5880fb0b8c 100644 --- a/src/Proto.Persistence/InMemoryProvider.cs +++ b/src/Proto.Persistence/InMemoryProvider.cs @@ -1,16 +1,16 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Persistence -{ - public class InMemoryProvider : IProvider - { - public IProviderState GetState() - { - return new InMemoryProviderState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Persistence +{ + public class InMemoryProvider : IProvider + { + public IProviderState GetState() + { + return new InMemoryProviderState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Persistence/InMemoryProviderState.cs b/src/Proto.Persistence/InMemoryProviderState.cs index 4d693a48eb..2856b6da3d 100644 --- a/src/Proto.Persistence/InMemoryProviderState.cs +++ b/src/Proto.Persistence/InMemoryProviderState.cs @@ -1,64 +1,64 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using Google.Protobuf; - -namespace Proto.Persistence -{ - internal class InMemoryProviderState : IProviderState - { - private readonly IDictionary> _events = new ConcurrentDictionary>(); - - private readonly IDictionary> _snapshots = - new Dictionary>(); - - public void Restart() - { - } - - public int GetSnapshotInterval() - { - return 0; - } - - public Tuple GetSnapshot(string actorName) - { - Tuple snapshot; - return _snapshots.TryGetValue(actorName, out snapshot) - ? snapshot - : null; - } - - public void GetEvents(string actorName, int eventIndexStart, Action callback) - { - List events; - if (_events.TryGetValue(actorName, out events)) - { - foreach (var e in events) - { - callback(e); - } - } - } - - public void PersistEvent(string actorName, int eventIndex, IMessage @event) - { - List events; - if (_events.TryGetValue(actorName, out events)) - { - events.Add(@event); - } - } - - public void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot) - { - _snapshots[actorName] = Tuple.Create((object) snapshot, eventIndex); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using Google.Protobuf; + +namespace Proto.Persistence +{ + internal class InMemoryProviderState : IProviderState + { + private readonly IDictionary> _events = new ConcurrentDictionary>(); + + private readonly IDictionary> _snapshots = + new Dictionary>(); + + public void Restart() + { + } + + public int GetSnapshotInterval() + { + return 0; + } + + public Tuple GetSnapshot(string actorName) + { + Tuple snapshot; + return _snapshots.TryGetValue(actorName, out snapshot) + ? snapshot + : null; + } + + public void GetEvents(string actorName, int eventIndexStart, Action callback) + { + List events; + if (_events.TryGetValue(actorName, out events)) + { + foreach (var e in events) + { + callback(e); + } + } + } + + public void PersistEvent(string actorName, int eventIndex, IMessage @event) + { + List events; + if (_events.TryGetValue(actorName, out events)) + { + events.Add(@event); + } + } + + public void PersistSnapshot(string actorName, int eventIndex, IMessage snapshot) + { + _snapshots[actorName] = Tuple.Create((object) snapshot, eventIndex); + } + } } \ No newline at end of file diff --git a/src/Proto.Persistence/Persistence.cs b/src/Proto.Persistence/Persistence.cs index eb4c1d45d1..419c38ba7a 100644 --- a/src/Proto.Persistence/Persistence.cs +++ b/src/Proto.Persistence/Persistence.cs @@ -1,85 +1,85 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Google.Protobuf; - -namespace Proto.Persistence -{ - public class Persistence - { - public IProviderState State { get; set; } - public int EventIndex { get; set; } - public IContext Context { get; set; } - public bool Recovering { get; set; } - public string Name => Context.Self.Id; - - public void Init(IProvider provider, IContext context) - { - State = provider.GetState(); - Context = context; - Recovering = true; - - State.Restart(); - var t = State.GetSnapshot(Name); - if (t != null) - { - EventIndex = t.Item2; - Context.ReceiveAsync(t.Item1).Wait(); - } - State.GetEvents(Name, EventIndex, e => - { - Context.ReceiveAsync(e).Wait(); - EventIndex++; - }); - } - - public void PersistReceive(IMessage message) - { - State.PersistEvent(Name, EventIndex, message); - EventIndex++; - Context.ReceiveAsync(message).Wait(); - if (State.GetSnapshotInterval() == 0) - { - Context.ReceiveAsync(new RequestSnapshot()).Wait(); - } - } - - public void PersistSnapshot(IMessage snapshot) - { - State.PersistSnapshot(Name, EventIndex, snapshot); - } - - public static Func Using(IProvider provider) - { - return next => async context => - { - switch (context.Message) - { - case Started started: - await next(context); - context.Self.Tell(new Replay()); - break; - case Replay replay: - var p = context.Actor as IPersistentActor; - if (p != null) - { - p.Persistence = new Persistence(); - p.Persistence.Init(provider, context); - } - break; - default: - await next(context); - break; - } - }; - } - } - - public class RequestSnapshot - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Google.Protobuf; + +namespace Proto.Persistence +{ + public class Persistence + { + public IProviderState State { get; set; } + public int EventIndex { get; set; } + public IContext Context { get; set; } + public bool Recovering { get; set; } + public string Name => Context.Self.Id; + + public void Init(IProvider provider, IContext context) + { + State = provider.GetState(); + Context = context; + Recovering = true; + + State.Restart(); + var t = State.GetSnapshot(Name); + if (t != null) + { + EventIndex = t.Item2; + Context.ReceiveAsync(t.Item1).Wait(); + } + State.GetEvents(Name, EventIndex, e => + { + Context.ReceiveAsync(e).Wait(); + EventIndex++; + }); + } + + public void PersistReceive(IMessage message) + { + State.PersistEvent(Name, EventIndex, message); + EventIndex++; + Context.ReceiveAsync(message).Wait(); + if (State.GetSnapshotInterval() == 0) + { + Context.ReceiveAsync(new RequestSnapshot()).Wait(); + } + } + + public void PersistSnapshot(IMessage snapshot) + { + State.PersistSnapshot(Name, EventIndex, snapshot); + } + + public static Func Using(IProvider provider) + { + return next => async context => + { + switch (context.Message) + { + case Started started: + await next(context); + context.Self.Tell(new Replay()); + break; + case Replay replay: + var p = context.Actor as IPersistentActor; + if (p != null) + { + p.Persistence = new Persistence(); + p.Persistence.Init(provider, context); + } + break; + default: + await next(context); + break; + } + }; + } + } + + public class RequestSnapshot + { + } } \ No newline at end of file diff --git a/src/Proto.Persistence/Proto.Persistence.csproj b/src/Proto.Persistence/Proto.Persistence.csproj index a350addfdf..3dfeb10817 100644 --- a/src/Proto.Persistence/Proto.Persistence.csproj +++ b/src/Proto.Persistence/Proto.Persistence.csproj @@ -1,9 +1,9 @@ - - - netstandard1.6 - - - - - + + + netstandard1.6 + + + + + \ No newline at end of file diff --git a/src/Proto.Persistence/Replay.cs b/src/Proto.Persistence/Replay.cs index 6157d616e8..d3f9a8e1b1 100644 --- a/src/Proto.Persistence/Replay.cs +++ b/src/Proto.Persistence/Replay.cs @@ -1,12 +1,12 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Persistence -{ - internal class Replay - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Persistence +{ + internal class Replay + { + } } \ No newline at end of file diff --git a/src/Proto.Remote/EndpointManager.cs b/src/Proto.Remote/EndpointManager.cs index c216202a67..03cd4601ed 100644 --- a/src/Proto.Remote/EndpointManager.cs +++ b/src/Proto.Remote/EndpointManager.cs @@ -1,106 +1,106 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Proto.Remote -{ - public class Endpoint - { - public Endpoint(PID writer, PID watcher) - { - Writer = writer; - Watcher = watcher; - } - - public PID Writer { get; } - public PID Watcher { get; } - } - - public class EndpointManager : IActor - { - private readonly Dictionary _connections = new Dictionary(); - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case Started _: - { - Console.WriteLine("[REMOTING] Started EndpointManager"); - return Actor.Done; - } - case EndpointTerminatedEvent msg: - { - var endpoint = EnsureConnected(msg.Address, context); - endpoint.Watcher.Tell(msg); - return Actor.Done; - } - case RemoteTerminate msg: - { - var endpoint = EnsureConnected(msg.Watchee.Address, context); - endpoint.Watcher.Tell(msg); - return Actor.Done; - } - case RemoteWatch msg: - { - var endpoint = EnsureConnected(msg.Watchee.Address, context); - endpoint.Watcher.Tell(msg); - return Actor.Done; - } - case RemoteUnwatch msg: - { - var endpoint = EnsureConnected(msg.Watchee.Address, context); - endpoint.Watcher.Tell(msg); - return Actor.Done; - } - case MessageEnvelope msg: - { - var endpoint = EnsureConnected(msg.Target.Address, context); - endpoint.Writer.Tell(msg); - return Actor.Done; - } - default: - return Actor.Done; - } - } - - - private Endpoint EnsureConnected(string address, IContext context) - { - var ok = _connections.TryGetValue(address, out var endpoint); - if (!ok) - { - var writer = SpawnWriter(address, context); - - var watcher = SpawnWatcher(address, context); - - endpoint = new Endpoint(writer, watcher); - _connections.Add(address, endpoint); - } - - return endpoint; - } - - private static PID SpawnWatcher(string address, IContext context) - { - var watcherProps = Actor.FromProducer(() => new EndpointWatcher(address)); - var watcher = context.Spawn(watcherProps); - return watcher; - } - - private static PID SpawnWriter(string address, IContext context) - { - var writerProps = - Actor.FromProducer(() => new EndpointWriter(address)) - .WithMailbox(() => new EndpointWriterMailbox()); - var writer = context.Spawn(writerProps); - return writer; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Proto.Remote +{ + public class Endpoint + { + public Endpoint(PID writer, PID watcher) + { + Writer = writer; + Watcher = watcher; + } + + public PID Writer { get; } + public PID Watcher { get; } + } + + public class EndpointManager : IActor + { + private readonly Dictionary _connections = new Dictionary(); + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case Started _: + { + Console.WriteLine("[REMOTING] Started EndpointManager"); + return Actor.Done; + } + case EndpointTerminatedEvent msg: + { + var endpoint = EnsureConnected(msg.Address, context); + endpoint.Watcher.Tell(msg); + return Actor.Done; + } + case RemoteTerminate msg: + { + var endpoint = EnsureConnected(msg.Watchee.Address, context); + endpoint.Watcher.Tell(msg); + return Actor.Done; + } + case RemoteWatch msg: + { + var endpoint = EnsureConnected(msg.Watchee.Address, context); + endpoint.Watcher.Tell(msg); + return Actor.Done; + } + case RemoteUnwatch msg: + { + var endpoint = EnsureConnected(msg.Watchee.Address, context); + endpoint.Watcher.Tell(msg); + return Actor.Done; + } + case RemoteDeliver msg: + { + var endpoint = EnsureConnected(msg.Target.Address, context); + endpoint.Writer.Tell(msg); + return Actor.Done; + } + default: + return Actor.Done; + } + } + + + private Endpoint EnsureConnected(string address, IContext context) + { + var ok = _connections.TryGetValue(address, out var endpoint); + if (!ok) + { + var writer = SpawnWriter(address, context); + + var watcher = SpawnWatcher(address, context); + + endpoint = new Endpoint(writer, watcher); + _connections.Add(address, endpoint); + } + + return endpoint; + } + + private static PID SpawnWatcher(string address, IContext context) + { + var watcherProps = Actor.FromProducer(() => new EndpointWatcher(address)); + var watcher = context.Spawn(watcherProps); + return watcher; + } + + private static PID SpawnWriter(string address, IContext context) + { + var writerProps = + Actor.FromProducer(() => new EndpointWriter(address)) + .WithMailbox(() => new EndpointWriterMailbox()); + var writer = context.Spawn(writerProps); + return writer; + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/EndpointReader.cs b/src/Proto.Remote/EndpointReader.cs index 09bab43634..cfabeb2de0 100644 --- a/src/Proto.Remote/EndpointReader.cs +++ b/src/Proto.Remote/EndpointReader.cs @@ -1,44 +1,51 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Threading.Tasks; -using Grpc.Core; -using Grpc.Core.Utils; - -namespace Proto.Remote -{ - public class EndpointReader : Remoting.RemotingBase - { - public override async Task Receive(IAsyncStreamReader requestStream, - IServerStreamWriter responseStream, ServerCallContext context) - { - await requestStream.ForEachAsync(batch => - { - foreach (var envelope in batch.Envelopes) - { - var target = envelope.Target; - var sender = envelope.Sender; - var message = Serialization.Deserialize(envelope.TypeName, envelope.MessageData); - if (message is Terminated msg) - { - var rt = new RemoteTerminate(target, msg.Who); - RemotingSystem.EndpointManagerPid.Tell(rt); - } - if (message is SystemMessage sys) - { - target.SendSystemMessage(sys); - } - else - { - target.Request(message, sender); - } - } - - return Actor.Done; - }); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Utils; +using System.Collections.Generic; + +namespace Proto.Remote +{ + public class EndpointReader : Remoting.RemotingBase + { + public override async Task Receive(IAsyncStreamReader requestStream, + IServerStreamWriter responseStream, ServerCallContext context) + { + await requestStream.ForEachAsync(batch => + { + var targetNames = new List(batch.TargetNames); + var typeNames = new List(batch.TypeNames); + foreach (var envelope in batch.Envelopes) + { + + var targetName = targetNames[envelope.Target]; + var target = new PID(ProcessRegistry.Instance.Address, targetName); + var sender = envelope.Sender; + var typeName = typeNames[envelope.TypeId]; + var message = Serialization.Deserialize(typeName, envelope.MessageData); + + if (message is Terminated msg) + { + var rt = new RemoteTerminate(target, msg.Who); + RemotingSystem.EndpointManagerPid.Tell(rt); + } + if (message is SystemMessage sys) + { + target.SendSystemMessage(sys); + } + else + { + target.Request(message, sender); + } + } + + return Actor.Done; + }); + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/EndpointWatcher.cs b/src/Proto.Remote/EndpointWatcher.cs index 1a5cec1bc6..2069995113 100644 --- a/src/Proto.Remote/EndpointWatcher.cs +++ b/src/Proto.Remote/EndpointWatcher.cs @@ -1,87 +1,87 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Threading.Tasks; - -namespace Proto.Remote -{ - public class EndpointWatcher : IActor - { - private readonly Dictionary _watched = new Dictionary(); - private readonly Dictionary _watcher = new Dictionary(); - private string _address; //for logging - - public EndpointWatcher(string address) - { - _address = address; - } - - public Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case RemoteTerminate msg: - { - _watched.Remove(msg.Watcher.Id); - _watcher.Remove(msg.Watchee.Id); - //create a terminated event for the Watched actor - var t = new Terminated - { - Who = msg.Watchee, - AddressTerminated = true - }; - //send the address Terminated event to the Watcher - msg.Watcher.SendSystemMessage(t); - break; - } - case EndpointTerminatedEvent _: - { - foreach (var kvp in _watched) - { - var id = kvp.Key; - var pid = kvp.Value; - - //create a terminated event for the Watched actor - var t = new Terminated - { - Who = pid, - AddressTerminated = true - }; - var watcher = new PID(ProcessRegistry.Instance.Address, id); - //send the address Terminated event to the Watcher - watcher.SendSystemMessage(t); - } - break; - } - case RemoteUnwatch msg: - { - _watched[msg.Watcher.Id] = null; - _watcher[msg.Watchee.Id] = null; - - var w = new Unwatch(msg.Watcher); - msg.Watchee.SendSystemMessage(w); - - break; - } - case RemoteWatch msg: - { - _watched[msg.Watcher.Id] = msg.Watchee; - _watcher[msg.Watchee.Id] = msg.Watcher; - - var w = new Watch(msg.Watcher); - msg.Watchee.SendSystemMessage(w); - - break; - } - - default: - break; - } - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace Proto.Remote +{ + public class EndpointWatcher : IActor + { + private readonly Dictionary _watched = new Dictionary(); + private readonly Dictionary _watcher = new Dictionary(); + private string _address; //for logging + + public EndpointWatcher(string address) + { + _address = address; + } + + public Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case RemoteTerminate msg: + { + _watched.Remove(msg.Watcher.Id); + _watcher.Remove(msg.Watchee.Id); + //create a terminated event for the Watched actor + var t = new Terminated + { + Who = msg.Watchee, + AddressTerminated = true + }; + //send the address Terminated event to the Watcher + msg.Watcher.SendSystemMessage(t); + break; + } + case EndpointTerminatedEvent _: + { + foreach (var kvp in _watched) + { + var id = kvp.Key; + var pid = kvp.Value; + + //create a terminated event for the Watched actor + var t = new Terminated + { + Who = pid, + AddressTerminated = true + }; + var watcher = new PID(ProcessRegistry.Instance.Address, id); + //send the address Terminated event to the Watcher + watcher.SendSystemMessage(t); + } + break; + } + case RemoteUnwatch msg: + { + _watched[msg.Watcher.Id] = null; + _watcher[msg.Watchee.Id] = null; + + var w = new Unwatch(msg.Watcher); + msg.Watchee.SendSystemMessage(w); + + break; + } + case RemoteWatch msg: + { + _watched[msg.Watcher.Id] = msg.Watchee; + _watcher[msg.Watchee.Id] = msg.Watcher; + + var w = new Watch(msg.Watcher); + msg.Watchee.SendSystemMessage(w); + + break; + } + + default: + break; + } + return Actor.Done; + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/EndpointWriter.cs b/src/Proto.Remote/EndpointWriter.cs index c93862210c..01202d569c 100644 --- a/src/Proto.Remote/EndpointWriter.cs +++ b/src/Proto.Remote/EndpointWriter.cs @@ -1,110 +1,139 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Grpc.Core; -using Grpc.Core.Utils; - -namespace Proto.Remote -{ - public class EndpointWriter : IActor - { - private readonly string _address; - private Channel _channel; - private Remoting.RemotingClient _client; - private AsyncDuplexStreamingCall _stream; - private IClientStreamWriter _streamWriter; - - public EndpointWriter(string address) - { - _address = address; - } - - public async Task ReceiveAsync(IContext context) - { - switch (context.Message) - { - case Started m: - // Console.WriteLine("EndpointWriter Started"); - await StartedAsync(); - break; - case Stopped m: - await StoppedAsync(); - break; - case Restarting m: - // Console.WriteLine("EndpointWriter Restarting"); - await RestartingAsync(); - break; - case IEnumerable m: - var envelopes = m; - await SendEnvelopesAsync(envelopes, context); - break; - } - } - - private async Task SendEnvelopesAsync(IEnumerable envelopes, IContext context) - { - var batch = new MessageBatch(); - batch.Envelopes.AddRange(envelopes); - - try - { - await _streamWriter.WriteAsync(batch); - } - catch (Exception x) - { - context.Stash(); - Console.WriteLine($"[REMOTING] gRPC Failed to send to address {_address}, reason {x.Message}"); - throw; - } - } - - private async Task RestartingAsync() - { - await _channel.ShutdownAsync(); - } - - private async Task StoppedAsync() - { - await _channel.ShutdownAsync(); - } - - private Task StartedAsync() - { - Console.WriteLine("[REMOTING] Started EndpointWriter for address {0}", _address); - - Console.WriteLine("[REMOTING] EndpointWriter connecting to address {0}", _address); - _channel = new Channel(_address, ChannelCredentials.Insecure); - _client = new Remoting.RemotingClient(_channel); - _stream = _client.Receive(); - - Task.Factory.StartNew(async () => - { - try - { - await _stream.ResponseStream.ForEachAsync(i => Actor.Done); - } - catch (Exception x) - { - Console.WriteLine( - $"[REMOTING] EndpointWriter lost connection to address {_address}, reason {x.Message}"); - var terminated = new EndpointTerminatedEvent - { - Address = _address - }; - Actor.EventStream.Publish(terminated); - } - }); - - _streamWriter = _stream.RequestStream; - - Console.WriteLine("[REMOTING] EndpointWriter connected to address {0}", _address); - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Grpc.Core; +using Grpc.Core.Utils; + +namespace Proto.Remote +{ + public class EndpointWriter : IActor + { + private readonly string _address; + private Channel _channel; + private Remoting.RemotingClient _client; + private AsyncDuplexStreamingCall _stream; + private IClientStreamWriter _streamWriter; + + public EndpointWriter(string address) + { + _address = address; + } + + public async Task ReceiveAsync(IContext context) + { + switch (context.Message) + { + case Started m: + await StartedAsync(); + break; + case Stopped m: + await StoppedAsync(); + break; + case Restarting m: + await RestartingAsync(); + break; + case IEnumerable m: + var envelopes = new List(); + var typeNames = new SortedDictionary(); + var targetNames = new SortedDictionary(); + foreach(var rd in m) + { + var targetName = rd.Target.Id; + if (!targetNames.ContainsKey(targetName)) + { + targetNames.Add(targetName, typeNames.Count); + } + var targetId = targetNames[targetName]; + + var typeName = rd.Message.Descriptor.File.Package + "." + rd.Message.Descriptor.Name; + if (!typeNames.ContainsKey(typeName)) + { + typeNames.Add(typeName, typeNames.Count); + } + var typeId = typeNames[typeName]; + + var bytes = Serialization.Serialize(rd.Message); + var envelope = new MessageEnvelope + { + MessageData = bytes, + Sender = rd.Sender, + Target = targetId, + TypeId = typeId, + }; + envelopes.Add(envelope); + } + + var batch = new MessageBatch(); + batch.TargetNames.AddRange(targetNames.Keys); + batch.TypeNames.AddRange(typeNames.Keys); + batch.Envelopes.AddRange(envelopes); + + await SendEnvelopesAsync(batch, context); + break; + } + } + + private async Task SendEnvelopesAsync(MessageBatch batch, IContext context) + { + try + { + await _streamWriter.WriteAsync(batch); + } + catch (Exception x) + { + context.Stash(); + Console.WriteLine($"[REMOTING] gRPC Failed to send to address {_address}, reason {x.Message}"); + throw; + } + } + + private async Task RestartingAsync() + { + await _channel.ShutdownAsync(); + } + + private async Task StoppedAsync() + { + await _channel.ShutdownAsync(); + } + + private Task StartedAsync() + { + Console.WriteLine("[REMOTING] Started EndpointWriter for address {0}", _address); + + Console.WriteLine("[REMOTING] EndpointWriter connecting to address {0}", _address); + _channel = new Channel(_address, ChannelCredentials.Insecure); + _client = new Remoting.RemotingClient(_channel); + _stream = _client.Receive(); + + Task.Factory.StartNew(async () => + { + try + { + await _stream.ResponseStream.ForEachAsync(i => Actor.Done); + } + catch (Exception x) + { + Console.WriteLine( + $"[REMOTING] EndpointWriter lost connection to address {_address}, reason {x.Message}"); + var terminated = new EndpointTerminatedEvent + { + Address = _address + }; + Actor.EventStream.Publish(terminated); + } + }); + + _streamWriter = _stream.RequestStream; + + Console.WriteLine("[REMOTING] EndpointWriter connected to address {0}", _address); + return Actor.Done; + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/EndpointWriterMailbox.cs b/src/Proto.Remote/EndpointWriterMailbox.cs index 3e008802de..8531bbdb64 100644 --- a/src/Proto.Remote/EndpointWriterMailbox.cs +++ b/src/Proto.Remote/EndpointWriterMailbox.cs @@ -1,105 +1,105 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; -using Proto.Mailbox; - -namespace Proto.Remote -{ - internal static class MailboxStatus - { - public const int Idle = 0; - public const int Busy = 1; - } - - public class EndpointWriterMailbox : IMailbox - { - private readonly IMailboxQueue _systemMessages = new UnboundedMailboxQueue(); - private readonly IMailboxQueue _userMessages = new UnboundedMailboxQueue(); - private IDispatcher _dispatcher; - private IMessageInvoker _invoker; - - private int _status = MailboxStatus.Idle; - private bool _suspended; - - public void PostUserMessage(object msg) - { - _userMessages.Push(msg); - Schedule(); - } - - public void PostSystemMessage(object msg) - { - _systemMessages.Push(msg); - Schedule(); - } - - public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) - { - _invoker = invoker; - _dispatcher = dispatcher; - } - - public void Start() - { - } - - private async Task RunAsync() - { - var t = _dispatcher.Throughput; - var batch = new List(); - var sys = _systemMessages.Pop(); - if (sys != null) - { - if (sys is SuspendMailbox) - { - _suspended = true; - } - if (sys is ResumeMailbox) - { - _suspended = false; - } - await _invoker.InvokeSystemMessageAsync(sys); - } - if (!_suspended) - { - batch.Clear(); - object msg; - while ((msg = _userMessages.Pop()) != null) - { - batch.Add((MessageEnvelope) msg); - if (batch.Count > 1000) - { - break; - } - } - - if (batch.Count > 0) - { - await _invoker.InvokeUserMessageAsync(batch); - } - } - - - Interlocked.Exchange(ref _status, MailboxStatus.Idle); - - if (_userMessages.HasMessages || _systemMessages.HasMessages) - { - Schedule(); - } - } - - protected void Schedule() - { - if (Interlocked.Exchange(ref _status, MailboxStatus.Busy) == MailboxStatus.Idle) - { - _dispatcher.Schedule(RunAsync); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Proto.Mailbox; + +namespace Proto.Remote +{ + internal static class MailboxStatus + { + public const int Idle = 0; + public const int Busy = 1; + } + + public class EndpointWriterMailbox : IMailbox + { + private readonly IMailboxQueue _systemMessages = new UnboundedMailboxQueue(); + private readonly IMailboxQueue _userMessages = new UnboundedMailboxQueue(); + private IDispatcher _dispatcher; + private IMessageInvoker _invoker; + + private int _status = MailboxStatus.Idle; + private bool _suspended; + + public void PostUserMessage(object msg) + { + _userMessages.Push(msg); + Schedule(); + } + + public void PostSystemMessage(object msg) + { + _systemMessages.Push(msg); + Schedule(); + } + + public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) + { + _invoker = invoker; + _dispatcher = dispatcher; + } + + public void Start() + { + } + + private async Task RunAsync() + { + var t = _dispatcher.Throughput; + var batch = new List(); + var sys = _systemMessages.Pop(); + if (sys != null) + { + if (sys is SuspendMailbox) + { + _suspended = true; + } + if (sys is ResumeMailbox) + { + _suspended = false; + } + await _invoker.InvokeSystemMessageAsync(sys); + } + if (!_suspended) + { + batch.Clear(); + object msg; + while ((msg = _userMessages.Pop()) != null) + { + batch.Add((RemoteDeliver) msg); + if (batch.Count > 1000) + { + break; + } + } + + if (batch.Count > 0) + { + await _invoker.InvokeUserMessageAsync(batch); + } + } + + + Interlocked.Exchange(ref _status, MailboxStatus.Idle); + + if (_userMessages.HasMessages || _systemMessages.HasMessages) + { + Schedule(); + } + } + + protected void Schedule() + { + if (Interlocked.Exchange(ref _status, MailboxStatus.Busy) == MailboxStatus.Idle) + { + _dispatcher.Schedule(RunAsync); + } + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/Messages.cs b/src/Proto.Remote/Messages.cs index 9f733ad5e3..f195a5edf0 100644 --- a/src/Proto.Remote/Messages.cs +++ b/src/Proto.Remote/Messages.cs @@ -1,49 +1,49 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Remote -{ - public sealed class EndpointTerminatedEvent - { - public string Address { get; set; } - } - - public class RemoteTerminate - { - public RemoteTerminate(PID watcher, PID watchee) - { - Watcher = watcher; - Watchee = watchee; - } - - public PID Watcher { get; } - public PID Watchee { get; } - } - - public class RemoteWatch - { - public RemoteWatch(PID watcher, PID watchee) - { - Watcher = watcher; - Watchee = watchee; - } - - public PID Watcher { get; } - public PID Watchee { get; } - } - - public class RemoteUnwatch - { - public RemoteUnwatch(PID watcher, PID watchee) - { - Watcher = watcher; - Watchee = watchee; - } - - public PID Watcher { get; } - public PID Watchee { get; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Remote +{ + public sealed class EndpointTerminatedEvent + { + public string Address { get; set; } + } + + public class RemoteTerminate + { + public RemoteTerminate(PID watcher, PID watchee) + { + Watcher = watcher; + Watchee = watchee; + } + + public PID Watcher { get; } + public PID Watchee { get; } + } + + public class RemoteWatch + { + public RemoteWatch(PID watcher, PID watchee) + { + Watcher = watcher; + Watchee = watchee; + } + + public PID Watcher { get; } + public PID Watchee { get; } + } + + public class RemoteUnwatch + { + public RemoteUnwatch(PID watcher, PID watchee) + { + Watcher = watcher; + Watchee = watchee; + } + + public PID Watcher { get; } + public PID Watchee { get; } + } } \ No newline at end of file diff --git a/src/Proto.Remote/Proto.Remote.csproj b/src/Proto.Remote/Proto.Remote.csproj index 0329462580..764afb09b6 100644 --- a/src/Proto.Remote/Proto.Remote.csproj +++ b/src/Proto.Remote/Proto.Remote.csproj @@ -1,18 +1,18 @@ - - - netstandard1.6 - - - library - - - - - - - - - - - + + + netstandard1.6 + + + library + + + + + + + + + + + \ No newline at end of file diff --git a/src/Proto.Remote/Protos.g.cs b/src/Proto.Remote/Protos.g.cs index 64e2829e61..c15059e874 100644 --- a/src/Proto.Remote/Protos.g.cs +++ b/src/Proto.Remote/Protos.g.cs @@ -23,22 +23,22 @@ static ProtosReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CgxQcm90b3MucHJvdG8SBnJlbW90ZRoYUHJvdG8uQWN0b3IvcHJvdG9zLnBy", - "b3RvInIKD01lc3NhZ2VFbnZlbG9wZRIRCgl0eXBlX25hbWUYASABKAkSFAoM", - "bWVzc2FnZV9kYXRhGAIgASgMEhoKBnRhcmdldBgDIAEoCzIKLmFjdG9yLlBJ", - "RBIaCgZzZW5kZXIYBCABKAsyCi5hY3Rvci5QSUQiLQoPQWN0b3JQaWRSZXF1", - "ZXN0EgwKBG5hbWUYASABKAkSDAoEa2luZBgCIAEoCSIrChBBY3RvclBpZFJl", - "c3BvbnNlEhcKA3BpZBgBIAEoCzIKLmFjdG9yLlBJRCI6CgxNZXNzYWdlQmF0", - "Y2gSKgoJZW52ZWxvcGVzGAEgAygLMhcucmVtb3RlLk1lc3NhZ2VFbnZlbG9w", - "ZSIGCgRVbml0Mj8KCFJlbW90aW5nEjMKB1JlY2VpdmUSFC5yZW1vdGUuTWVz", - "c2FnZUJhdGNoGgwucmVtb3RlLlVuaXQiACgBMAFCD6oCDFByb3RvLlJlbW90", - "ZWIGcHJvdG8z")); + "b3RvImQKDE1lc3NhZ2VCYXRjaBISCgp0eXBlX25hbWVzGAEgAygJEhQKDHRh", + "cmdldF9uYW1lcxgCIAMoCRIqCgllbnZlbG9wZXMYAyADKAsyFy5yZW1vdGUu", + "TWVzc2FnZUVudmVsb3BlImQKD01lc3NhZ2VFbnZlbG9wZRIPCgd0eXBlX2lk", + "GAEgASgFEhQKDG1lc3NhZ2VfZGF0YRgCIAEoDBIOCgZ0YXJnZXQYAyABKAUS", + "GgoGc2VuZGVyGAQgASgLMgouYWN0b3IuUElEIi0KD0FjdG9yUGlkUmVxdWVz", + "dBIMCgRuYW1lGAEgASgJEgwKBGtpbmQYAiABKAkiKwoQQWN0b3JQaWRSZXNw", + "b25zZRIXCgNwaWQYASABKAsyCi5hY3Rvci5QSUQiBgoEVW5pdDI/CghSZW1v", + "dGluZxIzCgdSZWNlaXZlEhQucmVtb3RlLk1lc3NhZ2VCYXRjaBoMLnJlbW90", + "ZS5Vbml0IgAoATABQg+qAgxQcm90by5SZW1vdGViBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Proto.ProtosReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.MessageEnvelope), global::Proto.Remote.MessageEnvelope.Parser, new[]{ "TypeName", "MessageData", "Target", "Sender" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.MessageBatch), global::Proto.Remote.MessageBatch.Parser, new[]{ "TypeNames", "TargetNames", "Envelopes" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.MessageEnvelope), global::Proto.Remote.MessageEnvelope.Parser, new[]{ "TypeId", "MessageData", "Target", "Sender" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.ActorPidRequest), global::Proto.Remote.ActorPidRequest.Parser, new[]{ "Name", "Kind" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.ActorPidResponse), global::Proto.Remote.ActorPidResponse.Parser, new[]{ "Pid" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.MessageBatch), global::Proto.Remote.MessageBatch.Parser, new[]{ "Envelopes" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Proto.Remote.Unit), global::Proto.Remote.Unit.Parser, null, null, null, null) })); } @@ -46,6 +46,155 @@ static ProtosReflection() { } #region Messages + public sealed partial class MessageBatch : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageBatch()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageBatch() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageBatch(MessageBatch other) : this() { + typeNames_ = other.typeNames_.Clone(); + targetNames_ = other.targetNames_.Clone(); + envelopes_ = other.envelopes_.Clone(); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public MessageBatch Clone() { + return new MessageBatch(this); + } + + /// Field number for the "type_names" field. + public const int TypeNamesFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_typeNames_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField typeNames_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField TypeNames { + get { return typeNames_; } + } + + /// Field number for the "target_names" field. + public const int TargetNamesFieldNumber = 2; + private static readonly pb::FieldCodec _repeated_targetNames_codec + = pb::FieldCodec.ForString(18); + private readonly pbc::RepeatedField targetNames_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField TargetNames { + get { return targetNames_; } + } + + /// Field number for the "envelopes" field. + public const int EnvelopesFieldNumber = 3; + private static readonly pb::FieldCodec _repeated_envelopes_codec + = pb::FieldCodec.ForMessage(26, global::Proto.Remote.MessageEnvelope.Parser); + private readonly pbc::RepeatedField envelopes_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField Envelopes { + get { return envelopes_; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as MessageBatch); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(MessageBatch other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!typeNames_.Equals(other.typeNames_)) return false; + if(!targetNames_.Equals(other.targetNames_)) return false; + if(!envelopes_.Equals(other.envelopes_)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= typeNames_.GetHashCode(); + hash ^= targetNames_.GetHashCode(); + hash ^= envelopes_.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + typeNames_.WriteTo(output, _repeated_typeNames_codec); + targetNames_.WriteTo(output, _repeated_targetNames_codec); + envelopes_.WriteTo(output, _repeated_envelopes_codec); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += typeNames_.CalculateSize(_repeated_typeNames_codec); + size += targetNames_.CalculateSize(_repeated_targetNames_codec); + size += envelopes_.CalculateSize(_repeated_envelopes_codec); + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(MessageBatch other) { + if (other == null) { + return; + } + typeNames_.Add(other.typeNames_); + targetNames_.Add(other.targetNames_); + envelopes_.Add(other.envelopes_); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + typeNames_.AddEntriesFrom(input, _repeated_typeNames_codec); + break; + } + case 18: { + targetNames_.AddEntriesFrom(input, _repeated_targetNames_codec); + break; + } + case 26: { + envelopes_.AddEntriesFrom(input, _repeated_envelopes_codec); + break; + } + } + } + } + + } + public sealed partial class MessageEnvelope : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageEnvelope()); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -53,7 +202,7 @@ public sealed partial class MessageEnvelope : pb::IMessage { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[0]; } + get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[1]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -70,9 +219,9 @@ public MessageEnvelope() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public MessageEnvelope(MessageEnvelope other) : this() { - typeName_ = other.typeName_; + typeId_ = other.typeId_; messageData_ = other.messageData_; - Target = other.target_ != null ? other.Target.Clone() : null; + target_ = other.target_; Sender = other.sender_ != null ? other.Sender.Clone() : null; } @@ -81,14 +230,14 @@ public MessageEnvelope Clone() { return new MessageEnvelope(this); } - /// Field number for the "type_name" field. - public const int TypeNameFieldNumber = 1; - private string typeName_ = ""; + /// Field number for the "type_id" field. + public const int TypeIdFieldNumber = 1; + private int typeId_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public string TypeName { - get { return typeName_; } + public int TypeId { + get { return typeId_; } set { - typeName_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + typeId_ = value; } } @@ -105,9 +254,9 @@ public string TypeName { /// Field number for the "target" field. public const int TargetFieldNumber = 3; - private global::Proto.PID target_; + private int target_; [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public global::Proto.PID Target { + public int Target { get { return target_; } set { target_ = value; @@ -138,9 +287,9 @@ public bool Equals(MessageEnvelope other) { if (ReferenceEquals(other, this)) { return true; } - if (TypeName != other.TypeName) return false; + if (TypeId != other.TypeId) return false; if (MessageData != other.MessageData) return false; - if (!object.Equals(Target, other.Target)) return false; + if (Target != other.Target) return false; if (!object.Equals(Sender, other.Sender)) return false; return true; } @@ -148,9 +297,9 @@ public bool Equals(MessageEnvelope other) { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; - if (TypeName.Length != 0) hash ^= TypeName.GetHashCode(); + if (TypeId != 0) hash ^= TypeId.GetHashCode(); if (MessageData.Length != 0) hash ^= MessageData.GetHashCode(); - if (target_ != null) hash ^= Target.GetHashCode(); + if (Target != 0) hash ^= Target.GetHashCode(); if (sender_ != null) hash ^= Sender.GetHashCode(); return hash; } @@ -162,17 +311,17 @@ public override string ToString() { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void WriteTo(pb::CodedOutputStream output) { - if (TypeName.Length != 0) { - output.WriteRawTag(10); - output.WriteString(TypeName); + if (TypeId != 0) { + output.WriteRawTag(8); + output.WriteInt32(TypeId); } if (MessageData.Length != 0) { output.WriteRawTag(18); output.WriteBytes(MessageData); } - if (target_ != null) { - output.WriteRawTag(26); - output.WriteMessage(Target); + if (Target != 0) { + output.WriteRawTag(24); + output.WriteInt32(Target); } if (sender_ != null) { output.WriteRawTag(34); @@ -183,14 +332,14 @@ public void WriteTo(pb::CodedOutputStream output) { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; - if (TypeName.Length != 0) { - size += 1 + pb::CodedOutputStream.ComputeStringSize(TypeName); + if (TypeId != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(TypeId); } if (MessageData.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeBytesSize(MessageData); } - if (target_ != null) { - size += 1 + pb::CodedOutputStream.ComputeMessageSize(Target); + if (Target != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Target); } if (sender_ != null) { size += 1 + pb::CodedOutputStream.ComputeMessageSize(Sender); @@ -203,17 +352,14 @@ public void MergeFrom(MessageEnvelope other) { if (other == null) { return; } - if (other.TypeName.Length != 0) { - TypeName = other.TypeName; + if (other.TypeId != 0) { + TypeId = other.TypeId; } if (other.MessageData.Length != 0) { MessageData = other.MessageData; } - if (other.target_ != null) { - if (target_ == null) { - target_ = new global::Proto.PID(); - } - Target.MergeFrom(other.Target); + if (other.Target != 0) { + Target = other.Target; } if (other.sender_ != null) { if (sender_ == null) { @@ -231,19 +377,16 @@ public void MergeFrom(pb::CodedInputStream input) { default: input.SkipLastField(); break; - case 10: { - TypeName = input.ReadString(); + case 8: { + TypeId = input.ReadInt32(); break; } case 18: { MessageData = input.ReadBytes(); break; } - case 26: { - if (target_ == null) { - target_ = new global::Proto.PID(); - } - input.ReadMessage(target_); + case 24: { + Target = input.ReadInt32(); break; } case 34: { @@ -266,7 +409,7 @@ public sealed partial class ActorPidRequest : pb::IMessage { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[1]; } + get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[2]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -411,7 +554,7 @@ public sealed partial class ActorPidResponse : pb::IMessage { [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[2]; } + get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[3]; } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -527,115 +670,6 @@ public void MergeFrom(pb::CodedInputStream input) { } - public sealed partial class MessageBatch : pb::IMessage { - private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new MessageBatch()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pb::MessageParser Parser { get { return _parser; } } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public static pbr::MessageDescriptor Descriptor { - get { return global::Proto.Remote.ProtosReflection.Descriptor.MessageTypes[3]; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - pbr::MessageDescriptor pb::IMessage.Descriptor { - get { return Descriptor; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MessageBatch() { - OnConstruction(); - } - - partial void OnConstruction(); - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MessageBatch(MessageBatch other) : this() { - envelopes_ = other.envelopes_.Clone(); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public MessageBatch Clone() { - return new MessageBatch(this); - } - - /// Field number for the "envelopes" field. - public const int EnvelopesFieldNumber = 1; - private static readonly pb::FieldCodec _repeated_envelopes_codec - = pb::FieldCodec.ForMessage(10, global::Proto.Remote.MessageEnvelope.Parser); - private readonly pbc::RepeatedField envelopes_ = new pbc::RepeatedField(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public pbc::RepeatedField Envelopes { - get { return envelopes_; } - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override bool Equals(object other) { - return Equals(other as MessageBatch); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool Equals(MessageBatch other) { - if (ReferenceEquals(other, null)) { - return false; - } - if (ReferenceEquals(other, this)) { - return true; - } - if(!envelopes_.Equals(other.envelopes_)) return false; - return true; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override int GetHashCode() { - int hash = 1; - hash ^= envelopes_.GetHashCode(); - return hash; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public override string ToString() { - return pb::JsonFormatter.ToDiagnosticString(this); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void WriteTo(pb::CodedOutputStream output) { - envelopes_.WriteTo(output, _repeated_envelopes_codec); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public int CalculateSize() { - int size = 0; - size += envelopes_.CalculateSize(_repeated_envelopes_codec); - return size; - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(MessageBatch other) { - if (other == null) { - return; - } - envelopes_.Add(other.envelopes_); - } - - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public void MergeFrom(pb::CodedInputStream input) { - uint tag; - while ((tag = input.ReadTag()) != 0) { - switch(tag) { - default: - input.SkipLastField(); - break; - case 10: { - envelopes_.AddEntriesFrom(input, _repeated_envelopes_codec); - break; - } - } - } - } - - } - public sealed partial class Unit : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Unit()); [global::System.Diagnostics.DebuggerNonUserCodeAttribute] diff --git a/src/Proto.Remote/Protos.proto b/src/Proto.Remote/Protos.proto index 3b343733e3..c8f8493595 100644 --- a/src/Proto.Remote/Protos.proto +++ b/src/Proto.Remote/Protos.proto @@ -1,32 +1,34 @@ - -syntax = "proto3"; -package remote; -option csharp_namespace = "Proto.Remote"; - -import "Proto.Actor/protos.proto"; - -message MessageEnvelope { - string type_name = 1; - bytes message_data = 2; - actor.PID target = 3; - actor.PID sender = 4; -} - -message ActorPidRequest { - string name = 1; - string kind = 2; -} - -message ActorPidResponse { - actor.PID pid = 1; -} - -message MessageBatch { - repeated MessageEnvelope envelopes = 1; -} - -message Unit {} - -service Remoting { - rpc Receive (stream MessageBatch) returns (stream Unit) {} -} + +syntax = "proto3"; +package remote; +option csharp_namespace = "Proto.Remote"; + +import "Proto.Actor/protos.proto"; + +message MessageBatch { + repeated string type_names=1; + repeated string target_names=2; + repeated MessageEnvelope envelopes = 3; +} + +message MessageEnvelope { + int32 type_id = 1; + bytes message_data = 2; + int32 target = 3; + actor.PID sender = 4; +} + +message ActorPidRequest { + string name = 1; + string kind = 2; +} + +message ActorPidResponse { + actor.PID pid = 1; +} + +message Unit {} + +service Remoting { + rpc Receive (stream MessageBatch) returns (stream Unit) {} +} diff --git a/src/Proto.Remote/RemoteProcess.cs b/src/Proto.Remote/RemoteProcess.cs index a51007c5ff..3b01118b81 100644 --- a/src/Proto.Remote/RemoteProcess.cs +++ b/src/Proto.Remote/RemoteProcess.cs @@ -1,69 +1,86 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Google.Protobuf; - -namespace Proto.Remote -{ - public class RemoteProcess : Process - { - private readonly PID _pid; - - public RemoteProcess(PID pid) - { - _pid = pid; - } - - public override void SendUserMessage(PID pid, object message, PID sender) - { - Send(pid, message, sender); - } - - public override void SendSystemMessage(PID pid, object message) - { - Send(pid, message, null); - } - - private void Send(PID pid, object msg, PID sender) - { - if (msg is Watch w) - { - var rw = new RemoteWatch(w.Watcher, _pid); - RemotingSystem.EndpointManagerPid.Tell(rw); - } - else if (msg is Unwatch uw) - { - var ruw = new RemoteUnwatch(uw.Watcher, _pid); - RemotingSystem.EndpointManagerPid.Tell(ruw); - } - else - { - SendRemoteMessage(_pid, msg, sender); - } - } - - public static void SendRemoteMessage(PID pid, object msg, PID sender) - { - if (msg is IMessage) - { - var imsg = (IMessage) msg; - var env = new MessageEnvelope - { - Target = pid, - Sender = sender, - MessageData = Serialization.Serialize(imsg), - TypeName = imsg.Descriptor.File.Package + "." + imsg.Descriptor.Name - }; - RemotingSystem.EndpointManagerPid.Tell(env); - } - else - { - throw new NotSupportedException("Non protobuf message"); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Google.Protobuf; + +namespace Proto.Remote +{ + public class RemoteProcess : Process + { + private readonly PID _pid; + + public RemoteProcess(PID pid) + { + _pid = pid; + } + + public override void SendUserMessage(PID pid, object message, PID sender) + { + Send(pid, message, sender); + } + + public override void SendSystemMessage(PID pid, object message) + { + Send(pid, message, null); + } + + private void Send(PID pid, object msg, PID sender) + { + if (msg is Watch w) + { + var rw = new RemoteWatch(w.Watcher, _pid); + RemotingSystem.EndpointManagerPid.Tell(rw); + } + else if (msg is Unwatch uw) + { + var ruw = new RemoteUnwatch(uw.Watcher, _pid); + RemotingSystem.EndpointManagerPid.Tell(ruw); + } + else + { + SendRemoteMessage(_pid, msg, sender); + } + } + + public static void SendRemoteMessage(PID pid, object msg, PID sender) + { + if (msg is IMessage) + { + var imsg = (IMessage) msg; + var env = new RemoteDeliver(imsg, pid, sender); + + /* + * + { + Target = pid, + Sender = sender, + MessageData = Serialization.Serialize(imsg), + TypeName = imsg.Descriptor.File.Package + "." + imsg.Descriptor.Name + }; + */ + RemotingSystem.EndpointManagerPid.Tell(env); + } + else + { + throw new NotSupportedException("Non protobuf message"); + } + } + } + + public class RemoteDeliver + { + public RemoteDeliver(IMessage message, PID target,PID sender) + { + Message = message; + Target = target; + Sender = sender; + } + public IMessage Message { get; } + public PID Target { get; } + public PID Sender { get; } + } } \ No newline at end of file diff --git a/src/Proto.Remote/RemotingSystem.cs b/src/Proto.Remote/RemotingSystem.cs index 8bd68a2483..12dff800a6 100644 --- a/src/Proto.Remote/RemotingSystem.cs +++ b/src/Proto.Remote/RemotingSystem.cs @@ -1,36 +1,36 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using Grpc.Core; - -namespace Proto.Remote -{ - public static class RemotingSystem - { - private static Server _server; - public static PID EndpointManagerPid { get; private set; } - - public static void Start(string host, int port) - { - var addr = host + ":" + port; - ProcessRegistry.Instance.Address = addr; - ProcessRegistry.Instance.RegisterHostResolver(pid => new RemoteProcess(pid)); - - _server = new Server - { - Services = {Remoting.BindService(new EndpointReader())}, - Ports = {new ServerPort(host, port, ServerCredentials.Insecure)} - }; - _server.Start(); - var emProps = - Actor.FromProducer(() => new EndpointManager()); - EndpointManagerPid = Actor.Spawn(emProps); - - Console.WriteLine($"[REMOTING] Starting Proto.Actor server on {addr}"); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using Grpc.Core; + +namespace Proto.Remote +{ + public static class RemotingSystem + { + private static Server _server; + public static PID EndpointManagerPid { get; private set; } + + public static void Start(string host, int port) + { + var addr = host + ":" + port; + ProcessRegistry.Instance.Address = addr; + ProcessRegistry.Instance.RegisterHostResolver(pid => new RemoteProcess(pid)); + + _server = new Server + { + Services = {Remoting.BindService(new EndpointReader())}, + Ports = {new ServerPort(host, port, ServerCredentials.Insecure)} + }; + _server.Start(); + var emProps = + Actor.FromProducer(() => new EndpointManager()); + EndpointManagerPid = Actor.Spawn(emProps); + + Console.WriteLine($"[REMOTING] Starting Proto.Actor server on {addr}"); + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/Serialization.cs b/src/Proto.Remote/Serialization.cs index 946572a60d..03b0922893 100644 --- a/src/Proto.Remote/Serialization.cs +++ b/src/Proto.Remote/Serialization.cs @@ -1,44 +1,44 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using Google.Protobuf; -using Google.Protobuf.Reflection; - -namespace Proto.Remote -{ - public static class Serialization - { - private static readonly Dictionary TypeLookup = new Dictionary(); - - static Serialization() - { - RegisterFileDescriptor(Proto.ProtosReflection.Descriptor); - RegisterFileDescriptor(ProtosReflection.Descriptor); - } - - public static void RegisterFileDescriptor(FileDescriptor fd) - { - foreach (var msg in fd.MessageTypes) - { - var name = fd.Package + "." + msg.Name; - TypeLookup.Add(name, msg.Parser); - } - } - - public static ByteString Serialize(IMessage message) - { - return message.ToByteString(); - } - - public static object Deserialize(string typeName, ByteString bytes) - { - var parser = TypeLookup[typeName]; - var o = parser.ParseFrom(bytes); - return o; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using Google.Protobuf; +using Google.Protobuf.Reflection; + +namespace Proto.Remote +{ + public static class Serialization + { + private static readonly Dictionary TypeLookup = new Dictionary(); + + static Serialization() + { + RegisterFileDescriptor(Proto.ProtosReflection.Descriptor); + RegisterFileDescriptor(ProtosReflection.Descriptor); + } + + public static void RegisterFileDescriptor(FileDescriptor fd) + { + foreach (var msg in fd.MessageTypes) + { + var name = fd.Package + "." + msg.Name; + TypeLookup.Add(name, msg.Parser); + } + } + + public static ByteString Serialize(IMessage message) + { + return message.ToByteString(); + } + + public static object Deserialize(string typeName, ByteString bytes) + { + var parser = TypeLookup[typeName]; + var o = parser.ParseFrom(bytes); + return o; + } + } } \ No newline at end of file diff --git a/src/Proto.Remote/build.bat b/src/Proto.Remote/build.bat index d91bfb7b30..2c8a2a3b33 100644 --- a/src/Proto.Remote/build.bat +++ b/src/Proto.Remote/build.bat @@ -1 +1 @@ -protoc Protos.proto -I. -I.. --csharp_out=. --csharp_opt=file_extension=.g.cs --grpc_out . --plugin=protoc-gen-grpc=%home%\.nuget\packages\Grpc.Tools\1.0.1\tools\windows_x64\grpc_csharp_plugin.exe \ No newline at end of file +protoc Protos.proto -I. -I.. --csharp_out=. --csharp_opt=file_extension=.g.cs --grpc_out . --plugin=protoc-gen-grpc=%USERPROFILE%\.nuget\packages\Grpc.Tools\1.0.1\tools\windows_x64\grpc_csharp_plugin.exe \ No newline at end of file diff --git a/src/Proto.Router/HashRing.cs b/src/Proto.Router/HashRing.cs index fcfa187257..e7a1eb0c50 100644 --- a/src/Proto.Router/HashRing.cs +++ b/src/Proto.Router/HashRing.cs @@ -1,49 +1,49 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Cryptography; -using System.Text; - -namespace Proto.Router -{ - public class HashRing - { - private const int ReplicaCount = 100; - private static readonly HashAlgorithm HashAlgorithm = MD5.Create(); - private readonly List> _ring; - - public HashRing(IEnumerable nodes) - { - _ring = nodes - .SelectMany(n => Enumerable.Range(0, ReplicaCount).Select(i => new - { - hashKey = i + n, - node = n - })) - .Select(a => Tuple.Create(Hash(a.hashKey), a.node)) - .OrderBy(t => t.Item1) - .ToList(); - } - - public string GetNode(string key) - { - return ( - _ring.FirstOrDefault(t => t.Item1 > Hash(key)) - ?? _ring.First() - ).Item2; - } - - private static uint Hash(string s) - { - var digest = HashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(s)); - var hash = BitConverter.ToUInt32(digest, 0); - return hash; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; + +namespace Proto.Router +{ + public class HashRing + { + private const int ReplicaCount = 100; + private static readonly HashAlgorithm HashAlgorithm = MD5.Create(); + private readonly List> _ring; + + public HashRing(IEnumerable nodes) + { + _ring = nodes + .SelectMany(n => Enumerable.Range(0, ReplicaCount).Select(i => new + { + hashKey = i + n, + node = n + })) + .Select(a => Tuple.Create(Hash(a.hashKey), a.node)) + .OrderBy(t => t.Item1) + .ToList(); + } + + public string GetNode(string key) + { + return ( + _ring.FirstOrDefault(t => t.Item1 > Hash(key)) + ?? _ring.First() + ).Item2; + } + + private static uint Hash(string s) + { + var digest = HashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(s)); + var hash = BitConverter.ToUInt32(digest, 0); + return hash; + } + } } \ No newline at end of file diff --git a/src/Proto.Router/IHashable.cs b/src/Proto.Router/IHashable.cs index b7154c00c5..c977fba89a 100644 --- a/src/Proto.Router/IHashable.cs +++ b/src/Proto.Router/IHashable.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router -{ - public interface IHashable - { - string HashBy(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router +{ + public interface IHashable + { + string HashBy(); + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/Routees.cs b/src/Proto.Router/Messages/Routees.cs index 1aeed441cc..43740d9cb9 100644 --- a/src/Proto.Router/Messages/Routees.cs +++ b/src/Proto.Router/Messages/Routees.cs @@ -1,20 +1,20 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Messages -{ - public class Routees - { - public Routees(List pids) - { - PIDs = pids; - } - - public List PIDs { get; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Messages +{ + public class Routees + { + public Routees(List pids) + { + PIDs = pids; + } + + public List PIDs { get; } + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/RouterAddRoutee.cs b/src/Proto.Router/Messages/RouterAddRoutee.cs index 320e9b9776..dfdf34911b 100644 --- a/src/Proto.Router/Messages/RouterAddRoutee.cs +++ b/src/Proto.Router/Messages/RouterAddRoutee.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Messages -{ - public class RouterAddRoutee : RouterManagementMessage - { - public PID PID { get; set; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Messages +{ + public class RouterAddRoutee : RouterManagementMessage + { + public PID PID { get; set; } + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/RouterBroadcastMessage.cs b/src/Proto.Router/Messages/RouterBroadcastMessage.cs index 77f469172a..41a2374ac8 100644 --- a/src/Proto.Router/Messages/RouterBroadcastMessage.cs +++ b/src/Proto.Router/Messages/RouterBroadcastMessage.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Messages -{ - public class RouterBroadcastMessage : RouterManagementMessage - { - public object Message { get; set; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Messages +{ + public class RouterBroadcastMessage : RouterManagementMessage + { + public object Message { get; set; } + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/RouterGetRoutees.cs b/src/Proto.Router/Messages/RouterGetRoutees.cs index d4a5e0e023..9063fab46d 100644 --- a/src/Proto.Router/Messages/RouterGetRoutees.cs +++ b/src/Proto.Router/Messages/RouterGetRoutees.cs @@ -1,12 +1,12 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Messages -{ - public class RouterGetRoutees : RouterManagementMessage - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Messages +{ + public class RouterGetRoutees : RouterManagementMessage + { + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/RouterManagementMessage.cs b/src/Proto.Router/Messages/RouterManagementMessage.cs index 01badddf55..2442753af5 100644 --- a/src/Proto.Router/Messages/RouterManagementMessage.cs +++ b/src/Proto.Router/Messages/RouterManagementMessage.cs @@ -1,12 +1,12 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Messages -{ - public abstract class RouterManagementMessage - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Messages +{ + public abstract class RouterManagementMessage + { + } } \ No newline at end of file diff --git a/src/Proto.Router/Messages/RouterRemoveRoutee.cs b/src/Proto.Router/Messages/RouterRemoveRoutee.cs index a7c19e7570..19a4e9a857 100644 --- a/src/Proto.Router/Messages/RouterRemoveRoutee.cs +++ b/src/Proto.Router/Messages/RouterRemoveRoutee.cs @@ -1,13 +1,13 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Messages -{ - public class RouterRemoveRoutee : RouterManagementMessage - { - public PID PID { get; set; } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Messages +{ + public class RouterRemoveRoutee : RouterManagementMessage + { + public PID PID { get; set; } + } } \ No newline at end of file diff --git a/src/Proto.Router/Proto.Router.csproj b/src/Proto.Router/Proto.Router.csproj index dd36298636..a91cd0af33 100644 --- a/src/Proto.Router/Proto.Router.csproj +++ b/src/Proto.Router/Proto.Router.csproj @@ -1,12 +1,12 @@ - - - netstandard1.6 - - - library - - - - - + + + netstandard1.6 + + + library + + + + + \ No newline at end of file diff --git a/src/Proto.Router/Router.cs b/src/Proto.Router/Router.cs index 16cab8dee5..efdb3af0e9 100644 --- a/src/Proto.Router/Router.cs +++ b/src/Proto.Router/Router.cs @@ -1,72 +1,72 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Threading; -using Proto.Router.Routers; - -namespace Proto.Router -{ - public static class Router - { - public static Props NewBroadcastGroup(Props props, params PID[] routees) - { - return props.WithSpawner(Spawner(new BroadcastGroupRouterConfig(routees))); - } - - public static Props NewConsistentHashGroup(Props props, params PID[] routees) - { - return props.WithSpawner(Spawner(new ConsistentHashGroupRouterConfig(routees))); - } - - public static Props NewRandomGroup(Props props, params PID[] routees) - { - return props.WithSpawner(Spawner(new RandomGroupRouterConfig(routees))); - } - - public static Props NewRoundRobinGroup(Props props, params PID[] routees) - { - return props.WithSpawner(Spawner(new RoundRobinGroupRouterConfig(routees))); - } - - public static Props NewBroadcastPool(Props props, int poolSize) - { - return props.WithSpawner(Spawner(new BroadcastPoolRouterConfig(poolSize))); - } - - public static Props NewConsistentHashPool(Props props, int poolSize) - { - return props.WithSpawner(Spawner(new ConsistentHashPoolRouterConfig(poolSize))); - } - - public static Props NewRandomPool(Props props, int poolSize) - { - return props.WithSpawner(Spawner(new RandomPoolRouterConfig(poolSize))); - } - - public static Props NewRoundRobinPool(Props props, int poolSize) - { - return props.WithSpawner(Spawner(new RoundRobinPoolRouterConfig(poolSize))); - } - - public static Spawner Spawner(IRouterConfig config) - { - return (id, props, parent) => - { - var routeeProps = props.WithSpawner(null); - var routerState = config.CreateRouterState(); - var wg = new AutoResetEvent(false); - var routerProps = Actor.FromProducer(() => new RouterActor(routeeProps, config, routerState, wg)); - var routerId = ProcessRegistry.Instance.NextId(); - var router = Props.DefaultSpawner(routerId + "/router" , routerProps, parent); - wg.WaitOne(); //wait for the router to start - - var reff = new RouterProcess(router, routerState); - var (pid,ok) = ProcessRegistry.Instance.TryAdd(routerId, reff); - return pid; - }; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Threading; +using Proto.Router.Routers; + +namespace Proto.Router +{ + public static class Router + { + public static Props NewBroadcastGroup(Props props, params PID[] routees) + { + return props.WithSpawner(Spawner(new BroadcastGroupRouterConfig(routees))); + } + + public static Props NewConsistentHashGroup(Props props, params PID[] routees) + { + return props.WithSpawner(Spawner(new ConsistentHashGroupRouterConfig(routees))); + } + + public static Props NewRandomGroup(Props props, params PID[] routees) + { + return props.WithSpawner(Spawner(new RandomGroupRouterConfig(routees))); + } + + public static Props NewRoundRobinGroup(Props props, params PID[] routees) + { + return props.WithSpawner(Spawner(new RoundRobinGroupRouterConfig(routees))); + } + + public static Props NewBroadcastPool(Props props, int poolSize) + { + return props.WithSpawner(Spawner(new BroadcastPoolRouterConfig(poolSize))); + } + + public static Props NewConsistentHashPool(Props props, int poolSize) + { + return props.WithSpawner(Spawner(new ConsistentHashPoolRouterConfig(poolSize))); + } + + public static Props NewRandomPool(Props props, int poolSize) + { + return props.WithSpawner(Spawner(new RandomPoolRouterConfig(poolSize))); + } + + public static Props NewRoundRobinPool(Props props, int poolSize) + { + return props.WithSpawner(Spawner(new RoundRobinPoolRouterConfig(poolSize))); + } + + public static Spawner Spawner(IRouterConfig config) + { + return (id, props, parent) => + { + var routeeProps = props.WithSpawner(null); + var routerState = config.CreateRouterState(); + var wg = new AutoResetEvent(false); + var routerProps = Actor.FromProducer(() => new RouterActor(routeeProps, config, routerState, wg)); + var routerId = ProcessRegistry.Instance.NextId(); + var router = Props.DefaultSpawner(routerId + "/router" , routerProps, parent); + wg.WaitOne(); //wait for the router to start + + var reff = new RouterProcess(router, routerState); + var (pid,ok) = ProcessRegistry.Instance.TryAdd(routerId, reff); + return pid; + }; + } + } } \ No newline at end of file diff --git a/src/Proto.Router/RouterActor.cs b/src/Proto.Router/RouterActor.cs index f642a9a297..dfd5451657 100644 --- a/src/Proto.Router/RouterActor.cs +++ b/src/Proto.Router/RouterActor.cs @@ -1,78 +1,78 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Proto.Router.Messages; -using Proto.Router.Routers; - -namespace Proto.Router -{ - public class RouterActor : IActor - { - private readonly IRouterConfig _config; - private readonly Props _routeeProps; - private readonly RouterState _routerState; - private readonly AutoResetEvent _wg; - - public RouterActor(Props routeeProps, IRouterConfig config, RouterState routerState, AutoResetEvent wg) - { - _routeeProps = routeeProps; - _config = config; - _routerState = routerState; - _wg = wg; - } - - public Task ReceiveAsync(IContext context) - { - if (context.Message is Started) - { - _config.OnStarted(context, _routeeProps, _routerState); - _wg.Set(); - return Actor.Done; - } - if (context.Message is RouterAddRoutee addRoutee) - { - var r = _routerState.GetRoutees(); - if (r.Contains(addRoutee.PID)) - { - return Actor.Done; - } - context.Watch(addRoutee.PID); - r.Add(addRoutee.PID); - _routerState.SetRoutees(r); - return Actor.Done; - } - if (context.Message is RouterRemoveRoutee removeRoutee) - { - var r = _routerState.GetRoutees(); - if (!r.Contains(removeRoutee.PID)) - { - return Actor.Done; - } - context.Unwatch(removeRoutee.PID); - r.Remove(removeRoutee.PID); - _routerState.SetRoutees(r); - return Actor.Done; - } - if (context.Message is RouterBroadcastMessage broadcastMessage) - { - foreach (var routee in _routerState.GetRoutees()) - { - routee.Request(broadcastMessage.Message, context.Sender); - } - return Actor.Done; - } - if (context.Message is RouterGetRoutees) - { - var r = _routerState.GetRoutees().ToList(); - context.Sender.Tell(new Routees(r)); - } - return Actor.Done; - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Proto.Router.Messages; +using Proto.Router.Routers; + +namespace Proto.Router +{ + public class RouterActor : IActor + { + private readonly IRouterConfig _config; + private readonly Props _routeeProps; + private readonly RouterState _routerState; + private readonly AutoResetEvent _wg; + + public RouterActor(Props routeeProps, IRouterConfig config, RouterState routerState, AutoResetEvent wg) + { + _routeeProps = routeeProps; + _config = config; + _routerState = routerState; + _wg = wg; + } + + public Task ReceiveAsync(IContext context) + { + if (context.Message is Started) + { + _config.OnStarted(context, _routeeProps, _routerState); + _wg.Set(); + return Actor.Done; + } + if (context.Message is RouterAddRoutee addRoutee) + { + var r = _routerState.GetRoutees(); + if (r.Contains(addRoutee.PID)) + { + return Actor.Done; + } + context.Watch(addRoutee.PID); + r.Add(addRoutee.PID); + _routerState.SetRoutees(r); + return Actor.Done; + } + if (context.Message is RouterRemoveRoutee removeRoutee) + { + var r = _routerState.GetRoutees(); + if (!r.Contains(removeRoutee.PID)) + { + return Actor.Done; + } + context.Unwatch(removeRoutee.PID); + r.Remove(removeRoutee.PID); + _routerState.SetRoutees(r); + return Actor.Done; + } + if (context.Message is RouterBroadcastMessage broadcastMessage) + { + foreach (var routee in _routerState.GetRoutees()) + { + routee.Request(broadcastMessage.Message, context.Sender); + } + return Actor.Done; + } + if (context.Message is RouterGetRoutees) + { + var r = _routerState.GetRoutees().ToList(); + context.Sender.Tell(new Routees(r)); + } + return Actor.Done; + } + } } \ No newline at end of file diff --git a/src/Proto.Router/RouterProcess.cs b/src/Proto.Router/RouterProcess.cs index 57942b8ab7..80e40bb3c9 100644 --- a/src/Proto.Router/RouterProcess.cs +++ b/src/Proto.Router/RouterProcess.cs @@ -1,41 +1,41 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Proto.Router.Messages; -using Proto.Router.Routers; - -namespace Proto.Router -{ - public class RouterProcess : Process - { - private readonly PID _router; - private readonly RouterState _state; - - public RouterProcess(PID router, RouterState state) - { - _router = router; - _state = state; - } - - public override void SendUserMessage(PID pid, object message, PID sender) - { - if (message is RouterManagementMessage) - { - var router = ProcessRegistry.Instance.Get(_router); - router.SendUserMessage(pid, message, sender); - } - else - { - _state.RouteMessage(message, sender); - } - } - - public override void SendSystemMessage(PID pid, object message) - { - _router.SendSystemMessage(message); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Proto.Router.Messages; +using Proto.Router.Routers; + +namespace Proto.Router +{ + public class RouterProcess : Process + { + private readonly PID _router; + private readonly RouterState _state; + + public RouterProcess(PID router, RouterState state) + { + _router = router; + _state = state; + } + + public override void SendUserMessage(PID pid, object message, PID sender) + { + if (message is RouterManagementMessage) + { + var router = ProcessRegistry.Instance.Get(_router); + router.SendUserMessage(pid, message, sender); + } + else + { + _state.RouteMessage(message, sender); + } + } + + public override void SendSystemMessage(PID pid, object message) + { + _router.SendSystemMessage(message); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/BroadcastGroupRouterConfig.cs b/src/Proto.Router/Routers/BroadcastGroupRouterConfig.cs index 29a4240637..3a0788770b 100644 --- a/src/Proto.Router/Routers/BroadcastGroupRouterConfig.cs +++ b/src/Proto.Router/Routers/BroadcastGroupRouterConfig.cs @@ -1,23 +1,23 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class BroadcastGroupRouterConfig : GroupRouterConfig - { - public BroadcastGroupRouterConfig(params PID[] routees) - { - Routees = new HashSet(routees); - } - - public override RouterState CreateRouterState() - { - return new BroadcastRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class BroadcastGroupRouterConfig : GroupRouterConfig + { + public BroadcastGroupRouterConfig(params PID[] routees) + { + Routees = new HashSet(routees); + } + + public override RouterState CreateRouterState() + { + return new BroadcastRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/BroadcastPoolRouterConfig.cs b/src/Proto.Router/Routers/BroadcastPoolRouterConfig.cs index 447f9bb46b..0cde661ef6 100644 --- a/src/Proto.Router/Routers/BroadcastPoolRouterConfig.cs +++ b/src/Proto.Router/Routers/BroadcastPoolRouterConfig.cs @@ -1,21 +1,21 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - internal class BroadcastPoolRouterConfig : PoolRouterConfig - { - public BroadcastPoolRouterConfig(int poolSize) - : base(poolSize) - { - } - - public override RouterState CreateRouterState() - { - return new BroadcastRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + internal class BroadcastPoolRouterConfig : PoolRouterConfig + { + public BroadcastPoolRouterConfig(int poolSize) + : base(poolSize) + { + } + + public override RouterState CreateRouterState() + { + return new BroadcastRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/BroadcastRouterState.cs b/src/Proto.Router/Routers/BroadcastRouterState.cs index 2a6a3c1f95..48712b238b 100644 --- a/src/Proto.Router/Routers/BroadcastRouterState.cs +++ b/src/Proto.Router/Routers/BroadcastRouterState.cs @@ -1,33 +1,33 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class BroadcastRouterState : RouterState - { - private HashSet _routees; - - public override HashSet GetRoutees() - { - return _routees; - } - - public override void SetRoutees(HashSet routees) - { - _routees = routees; - } - - public override void RouteMessage(object message, PID sender) - { - foreach (var pid in _routees) - { - pid.Request(message, sender); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class BroadcastRouterState : RouterState + { + private HashSet _routees; + + public override HashSet GetRoutees() + { + return _routees; + } + + public override void SetRoutees(HashSet routees) + { + _routees = routees; + } + + public override void RouteMessage(object message, PID sender) + { + foreach (var pid in _routees) + { + pid.Request(message, sender); + } + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/ConsistentHashGroupRouterConfig.cs b/src/Proto.Router/Routers/ConsistentHashGroupRouterConfig.cs index df3d80862e..b05cff52b7 100644 --- a/src/Proto.Router/Routers/ConsistentHashGroupRouterConfig.cs +++ b/src/Proto.Router/Routers/ConsistentHashGroupRouterConfig.cs @@ -1,23 +1,23 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class ConsistentHashGroupRouterConfig : GroupRouterConfig - { - public ConsistentHashGroupRouterConfig(params PID[] routees) - { - Routees = new HashSet(routees); - } - - public override RouterState CreateRouterState() - { - return new ConsistentHashRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class ConsistentHashGroupRouterConfig : GroupRouterConfig + { + public ConsistentHashGroupRouterConfig(params PID[] routees) + { + Routees = new HashSet(routees); + } + + public override RouterState CreateRouterState() + { + return new ConsistentHashRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/ConsistentHashPoolRouterConfig.cs b/src/Proto.Router/Routers/ConsistentHashPoolRouterConfig.cs index 57e1f9db24..ad407c0f32 100644 --- a/src/Proto.Router/Routers/ConsistentHashPoolRouterConfig.cs +++ b/src/Proto.Router/Routers/ConsistentHashPoolRouterConfig.cs @@ -1,21 +1,21 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - internal class ConsistentHashPoolRouterConfig : PoolRouterConfig - { - public ConsistentHashPoolRouterConfig(int poolSize) - : base(poolSize) - { - } - - public override RouterState CreateRouterState() - { - return new ConsistentHashRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + internal class ConsistentHashPoolRouterConfig : PoolRouterConfig + { + public ConsistentHashPoolRouterConfig(int poolSize) + : base(poolSize) + { + } + + public override RouterState CreateRouterState() + { + return new ConsistentHashRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/ConsistentHashRouterState.cs b/src/Proto.Router/Routers/ConsistentHashRouterState.cs index 6b3de6376c..be9d57eb03 100644 --- a/src/Proto.Router/Routers/ConsistentHashRouterState.cs +++ b/src/Proto.Router/Routers/ConsistentHashRouterState.cs @@ -1,46 +1,46 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class ConsistentHashRouterState : RouterState - { - private HashRing _hashRing; - private Dictionary _routeeMap; - - - public override HashSet GetRoutees() - { - return new HashSet(_routeeMap.Values); - } - - public override void SetRoutees(HashSet routees) - { - _routeeMap = new Dictionary(); - var nodes = new List(); - foreach (var pid in routees) - { - var nodeName = pid.Address + "@" + pid.Id; - nodes.Add(nodeName); - _routeeMap[nodeName] = pid; - } - _hashRing = new HashRing(nodes); - } - - public override void RouteMessage(object message, PID sender) - { - if (message is IHashable hashable) - { - var key = hashable.HashBy(); - var node = _hashRing.GetNode(key); - var routee = _routeeMap[node]; - routee.Request(message, sender); - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class ConsistentHashRouterState : RouterState + { + private HashRing _hashRing; + private Dictionary _routeeMap; + + + public override HashSet GetRoutees() + { + return new HashSet(_routeeMap.Values); + } + + public override void SetRoutees(HashSet routees) + { + _routeeMap = new Dictionary(); + var nodes = new List(); + foreach (var pid in routees) + { + var nodeName = pid.Address + "@" + pid.Id; + nodes.Add(nodeName); + _routeeMap[nodeName] = pid; + } + _hashRing = new HashRing(nodes); + } + + public override void RouteMessage(object message, PID sender) + { + if (message is IHashable hashable) + { + var key = hashable.HashBy(); + var node = _hashRing.GetNode(key); + var routee = _routeeMap[node]; + routee.Request(message, sender); + } + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/GroupRouterConfig.cs b/src/Proto.Router/Routers/GroupRouterConfig.cs index 332b517be8..18ceef09d2 100644 --- a/src/Proto.Router/Routers/GroupRouterConfig.cs +++ b/src/Proto.Router/Routers/GroupRouterConfig.cs @@ -1,26 +1,26 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - public abstract class GroupRouterConfig : IGroupRouterConfig - { - protected HashSet Routees; - - public virtual void OnStarted(IContext context, Props props, RouterState router) - { - foreach (var pid in Routees) - { - context.Watch(pid); - } - router.SetRoutees(Routees); - } - - public abstract RouterState CreateRouterState(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + public abstract class GroupRouterConfig : IGroupRouterConfig + { + protected HashSet Routees; + + public virtual void OnStarted(IContext context, Props props, RouterState router) + { + foreach (var pid in Routees) + { + context.Watch(pid); + } + router.SetRoutees(Routees); + } + + public abstract RouterState CreateRouterState(); + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/IGroupRouterConfig.cs b/src/Proto.Router/Routers/IGroupRouterConfig.cs index 7ea2abdfc3..a66c3bce8a 100644 --- a/src/Proto.Router/Routers/IGroupRouterConfig.cs +++ b/src/Proto.Router/Routers/IGroupRouterConfig.cs @@ -1,12 +1,12 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - public interface IGroupRouterConfig : IRouterConfig - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + public interface IGroupRouterConfig : IRouterConfig + { + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/IPoolRouterConfig.cs b/src/Proto.Router/Routers/IPoolRouterConfig.cs index d5339bd67d..250456e769 100644 --- a/src/Proto.Router/Routers/IPoolRouterConfig.cs +++ b/src/Proto.Router/Routers/IPoolRouterConfig.cs @@ -1,12 +1,12 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - public interface IPoolRouterConfig : IRouterConfig - { - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + public interface IPoolRouterConfig : IRouterConfig + { + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/IRouterConfig.cs b/src/Proto.Router/Routers/IRouterConfig.cs index 025a854daa..1a59894399 100644 --- a/src/Proto.Router/Routers/IRouterConfig.cs +++ b/src/Proto.Router/Routers/IRouterConfig.cs @@ -1,15 +1,15 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - public interface IRouterConfig - { - void OnStarted(IContext context, Props props, RouterState router); - - RouterState CreateRouterState(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + public interface IRouterConfig + { + void OnStarted(IContext context, Props props, RouterState router); + + RouterState CreateRouterState(); + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/PoolRouterConfig.cs b/src/Proto.Router/Routers/PoolRouterConfig.cs index 42963bfab2..9392d60115 100644 --- a/src/Proto.Router/Routers/PoolRouterConfig.cs +++ b/src/Proto.Router/Routers/PoolRouterConfig.cs @@ -1,29 +1,29 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Linq; - -namespace Proto.Router.Routers -{ - internal abstract class PoolRouterConfig : IPoolRouterConfig - { - private readonly int _poolSize; - - protected PoolRouterConfig(int poolSize) - { - _poolSize = poolSize; - } - - public virtual void OnStarted(IContext context, Props props, RouterState router) - { - var routees = Enumerable.Range(0, _poolSize).Select(x => context.Spawn(props)); - router.SetRoutees(new HashSet(routees)); - } - - public abstract RouterState CreateRouterState(); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Linq; + +namespace Proto.Router.Routers +{ + internal abstract class PoolRouterConfig : IPoolRouterConfig + { + private readonly int _poolSize; + + protected PoolRouterConfig(int poolSize) + { + _poolSize = poolSize; + } + + public virtual void OnStarted(IContext context, Props props, RouterState router) + { + var routees = Enumerable.Range(0, _poolSize).Select(x => context.Spawn(props)); + router.SetRoutees(new HashSet(routees)); + } + + public abstract RouterState CreateRouterState(); + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RandomGroupRouterConfig.cs b/src/Proto.Router/Routers/RandomGroupRouterConfig.cs index 7776a124b1..883caad929 100644 --- a/src/Proto.Router/Routers/RandomGroupRouterConfig.cs +++ b/src/Proto.Router/Routers/RandomGroupRouterConfig.cs @@ -1,23 +1,23 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class RandomGroupRouterConfig : GroupRouterConfig - { - public RandomGroupRouterConfig(params PID[] routees) - { - Routees = new HashSet(routees); - } - - public override RouterState CreateRouterState() - { - return new RandomRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class RandomGroupRouterConfig : GroupRouterConfig + { + public RandomGroupRouterConfig(params PID[] routees) + { + Routees = new HashSet(routees); + } + + public override RouterState CreateRouterState() + { + return new RandomRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RandomPoolRouterConfig.cs b/src/Proto.Router/Routers/RandomPoolRouterConfig.cs index b076d08cc9..cf583d20f7 100644 --- a/src/Proto.Router/Routers/RandomPoolRouterConfig.cs +++ b/src/Proto.Router/Routers/RandomPoolRouterConfig.cs @@ -1,21 +1,21 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - internal class RandomPoolRouterConfig : PoolRouterConfig - { - public RandomPoolRouterConfig(int poolSize) - : base(poolSize) - { - } - - public override RouterState CreateRouterState() - { - return new RandomRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + internal class RandomPoolRouterConfig : PoolRouterConfig + { + public RandomPoolRouterConfig(int poolSize) + : base(poolSize) + { + } + + public override RouterState CreateRouterState() + { + return new RandomRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RandomRouterState.cs b/src/Proto.Router/Routers/RandomRouterState.cs index fcdf77bb20..7edca125b3 100644 --- a/src/Proto.Router/Routers/RandomRouterState.cs +++ b/src/Proto.Router/Routers/RandomRouterState.cs @@ -1,37 +1,37 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Proto.Router.Routers -{ - internal class RandomRouterState : RouterState - { - private readonly Random _random = new Random(); - private HashSet _routees; - private PID[] _values; - - public override HashSet GetRoutees() - { - return _routees; - } - - public override void SetRoutees(HashSet routees) - { - _routees = routees; - _values = routees.ToArray(); - } - - public override void RouteMessage(object message, PID sender) - { - var i = _random.Next(_values.Length); - var pid = _values[i]; - pid.Request(message, sender); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Proto.Router.Routers +{ + internal class RandomRouterState : RouterState + { + private readonly Random _random = new Random(); + private HashSet _routees; + private PID[] _values; + + public override HashSet GetRoutees() + { + return _routees; + } + + public override void SetRoutees(HashSet routees) + { + _routees = routees; + _values = routees.ToArray(); + } + + public override void RouteMessage(object message, PID sender) + { + var i = _random.Next(_values.Length); + var pid = _values[i]; + pid.Request(message, sender); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RoundRobinGroupRouterConfig.cs b/src/Proto.Router/Routers/RoundRobinGroupRouterConfig.cs index 0c177f4176..7a391a942a 100644 --- a/src/Proto.Router/Routers/RoundRobinGroupRouterConfig.cs +++ b/src/Proto.Router/Routers/RoundRobinGroupRouterConfig.cs @@ -1,23 +1,23 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - internal class RoundRobinGroupRouterConfig : GroupRouterConfig - { - public RoundRobinGroupRouterConfig(params PID[] routees) - { - Routees = new HashSet(routees); - } - - public override RouterState CreateRouterState() - { - return new RoundRobinRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + internal class RoundRobinGroupRouterConfig : GroupRouterConfig + { + public RoundRobinGroupRouterConfig(params PID[] routees) + { + Routees = new HashSet(routees); + } + + public override RouterState CreateRouterState() + { + return new RoundRobinRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RoundRobinPoolRouterConfig.cs b/src/Proto.Router/Routers/RoundRobinPoolRouterConfig.cs index 2d448bfd81..e75d3ce0fa 100644 --- a/src/Proto.Router/Routers/RoundRobinPoolRouterConfig.cs +++ b/src/Proto.Router/Routers/RoundRobinPoolRouterConfig.cs @@ -1,21 +1,21 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -namespace Proto.Router.Routers -{ - internal class RoundRobinPoolRouterConfig : PoolRouterConfig - { - public RoundRobinPoolRouterConfig(int poolSize) - : base(poolSize) - { - } - - public override RouterState CreateRouterState() - { - return new RoundRobinRouterState(); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +namespace Proto.Router.Routers +{ + internal class RoundRobinPoolRouterConfig : PoolRouterConfig + { + public RoundRobinPoolRouterConfig(int poolSize) + : base(poolSize) + { + } + + public override RouterState CreateRouterState() + { + return new RoundRobinRouterState(); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RoundRobinRouterState.cs b/src/Proto.Router/Routers/RoundRobinRouterState.cs index 70de9e84fe..718895ac3e 100644 --- a/src/Proto.Router/Routers/RoundRobinRouterState.cs +++ b/src/Proto.Router/Routers/RoundRobinRouterState.cs @@ -1,38 +1,38 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using System.Linq; -using System.Threading; - -namespace Proto.Router.Routers -{ - internal class RoundRobinRouterState : RouterState - { - private int _currentIndex; - private HashSet _routees; - private List _values; - - public override HashSet GetRoutees() - { - return _routees; - } - - public override void SetRoutees(HashSet routees) - { - _routees = routees; - _values = routees.ToList(); - } - - public override void RouteMessage(object message, PID sender) - { - var i = _currentIndex % _values.Count; - var pid = _values[i]; - Interlocked.Add(ref _currentIndex, 1); - pid.Request(message, sender); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using System.Linq; +using System.Threading; + +namespace Proto.Router.Routers +{ + internal class RoundRobinRouterState : RouterState + { + private int _currentIndex; + private HashSet _routees; + private List _values; + + public override HashSet GetRoutees() + { + return _routees; + } + + public override void SetRoutees(HashSet routees) + { + _routees = routees; + _values = routees.ToList(); + } + + public override void RouteMessage(object message, PID sender) + { + var i = _currentIndex % _values.Count; + var pid = _values[i]; + Interlocked.Add(ref _currentIndex, 1); + pid.Request(message, sender); + } + } } \ No newline at end of file diff --git a/src/Proto.Router/Routers/RouterState.cs b/src/Proto.Router/Routers/RouterState.cs index 9a672d99af..b96b21e2e9 100644 --- a/src/Proto.Router/Routers/RouterState.cs +++ b/src/Proto.Router/Routers/RouterState.cs @@ -1,17 +1,17 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; - -namespace Proto.Router.Routers -{ - public abstract class RouterState - { - public abstract HashSet GetRoutees(); - public abstract void SetRoutees(HashSet routees); - public abstract void RouteMessage(object message, PID sender); - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; + +namespace Proto.Router.Routers +{ + public abstract class RouterState + { + public abstract HashSet GetRoutees(); + public abstract void SetRoutees(HashSet routees); + public abstract void RouteMessage(object message, PID sender); + } } \ No newline at end of file diff --git a/tests/Proto.Actor.Tests/ActorFixture.cs b/tests/Proto.Actor.Tests/ActorFixture.cs index 089a76fd58..d839133da9 100644 --- a/tests/Proto.Actor.Tests/ActorFixture.cs +++ b/tests/Proto.Actor.Tests/ActorFixture.cs @@ -1,40 +1,40 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Proto.Mailbox; - -namespace Proto.Tests -{ - static class ActorFixture - { - public static Receive EmptyReceive = c => Actor.Done; - - public class TestMailbox : IMailbox - { - private IDispatcher _dispatcher; - private IMessageInvoker _invoker; - - public void PostUserMessage(object msg) - { - _invoker.InvokeUserMessageAsync(msg).Wait(); - } - - public void PostSystemMessage(object msg) - { - _invoker.InvokeSystemMessageAsync(msg); - } - - public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) - { - _invoker = invoker; - } - - public void Start() - { - } - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Proto.Mailbox; + +namespace Proto.Tests +{ + static class ActorFixture + { + public static Receive EmptyReceive = c => Actor.Done; + + public class TestMailbox : IMailbox + { + private IDispatcher _dispatcher; + private IMessageInvoker _invoker; + + public void PostUserMessage(object msg) + { + _invoker.InvokeUserMessageAsync(msg).Wait(); + } + + public void PostSystemMessage(object msg) + { + _invoker.InvokeSystemMessageAsync(msg); + } + + public void RegisterHandlers(IMessageInvoker invoker, IDispatcher dispatcher) + { + _invoker = invoker; + } + + public void Start() + { + } + } + } } \ No newline at end of file diff --git a/tests/Proto.Actor.Tests/MiddlewareTests.cs b/tests/Proto.Actor.Tests/MiddlewareTests.cs index f3768c9dab..00f762806c 100644 --- a/tests/Proto.Actor.Tests/MiddlewareTests.cs +++ b/tests/Proto.Actor.Tests/MiddlewareTests.cs @@ -1,55 +1,55 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using System.Collections.Generic; -using Xunit; - -namespace Proto.Tests -{ - public class MiddlewareTests - { - [Fact] - public void Given_Middleware_Should_Call_In_Order_Then_Actor() - { - var logs = new List(); - var testMailbox = new ActorFixture.TestMailbox(); - var props = Actor.FromFunc(c => - { - if (c.Message is string) - { - logs.Add("actor"); - } - return Actor.Done; - }) - .WithMiddleware( - next => async c => - { - if (c.Message is string) - { - logs.Add("middleware 1"); - } - await next(c); - }, - next => async c => - { - if (c.Message is string) - { - logs.Add("middleware 2"); - } - await next(c); - }) - .WithMailbox(() => testMailbox); - var pid = Actor.Spawn(props); - - pid.Tell(""); - - Assert.Equal(3, logs.Count); - Assert.Equal("middleware 1", logs[0]); - Assert.Equal("middleware 2", logs[1]); - Assert.Equal("actor", logs[2]); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using System.Collections.Generic; +using Xunit; + +namespace Proto.Tests +{ + public class MiddlewareTests + { + [Fact] + public void Given_Middleware_Should_Call_In_Order_Then_Actor() + { + var logs = new List(); + var testMailbox = new ActorFixture.TestMailbox(); + var props = Actor.FromFunc(c => + { + if (c.Message is string) + { + logs.Add("actor"); + } + return Actor.Done; + }) + .WithMiddleware( + next => async c => + { + if (c.Message is string) + { + logs.Add("middleware 1"); + } + await next(c); + }, + next => async c => + { + if (c.Message is string) + { + logs.Add("middleware 2"); + } + await next(c); + }) + .WithMailbox(() => testMailbox); + var pid = Actor.Spawn(props); + + pid.Tell(""); + + Assert.Equal(3, logs.Count); + Assert.Equal("middleware 1", logs[0]); + Assert.Equal("middleware 2", logs[1]); + Assert.Equal("actor", logs[2]); + } + } } \ No newline at end of file diff --git a/tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj b/tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj index e5ce91d0c3..33f8a8d3b8 100644 --- a/tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj +++ b/tests/Proto.Actor.Tests/Proto.Actor.Tests.csproj @@ -1,21 +1,21 @@ - - - Proto.Tests - - - Exe - netcoreapp1.1 - - - - - - - - - - - - - + + + Proto.Tests + + + Exe + netcoreapp1.1 + + + + + + + + + + + + + \ No newline at end of file diff --git a/tests/Proto.Actor.Tests/SpawnTests.cs b/tests/Proto.Actor.Tests/SpawnTests.cs index badef8429a..4dbd1faa93 100644 --- a/tests/Proto.Actor.Tests/SpawnTests.cs +++ b/tests/Proto.Actor.Tests/SpawnTests.cs @@ -1,26 +1,26 @@ -// ----------------------------------------------------------------------- -// -// Copyright (C) 2015-2017 Asynkron HB All rights reserved -// -// ----------------------------------------------------------------------- - -using Xunit; -using static Proto.Tests.ActorFixture; - -namespace Proto.Tests -{ - public class SpawnTests - { - [Fact] - public void Given_PropsWithSpawner_SpawnShouldReturnPidCreatedBySpawner() - { - var spawnedPid = new PID("test", "test"); - var props = Actor.FromFunc(EmptyReceive) - .WithSpawner((id, p, parent) => spawnedPid); - - var pid = Actor.Spawn(props); - - Assert.Same(spawnedPid, pid); - } - } +// ----------------------------------------------------------------------- +// +// Copyright (C) 2015-2017 Asynkron HB All rights reserved +// +// ----------------------------------------------------------------------- + +using Xunit; +using static Proto.Tests.ActorFixture; + +namespace Proto.Tests +{ + public class SpawnTests + { + [Fact] + public void Given_PropsWithSpawner_SpawnShouldReturnPidCreatedBySpawner() + { + var spawnedPid = new PID("test", "test"); + var props = Actor.FromFunc(EmptyReceive) + .WithSpawner((id, p, parent) => spawnedPid); + + var pid = Actor.Spawn(props); + + Assert.Same(spawnedPid, pid); + } + } } \ No newline at end of file