GithubHelp home page GithubHelp logo

orleanscontrib / orleankka Goto Github PK

View Code? Open in Web Editor NEW
487.0 487.0 76.0 12.59 MB

Functional API for Microsoft Orleans http://orleanscontrib.github.io/Orleankka

License: Apache License 2.0

C# 99.89% JavaScript 0.05% Batchfile 0.04% Shell 0.01%
actors cqrs event-sourcing fsm functional orleans

orleankka's People

Contributors

andyhoyle avatar antyadev avatar aprooks avatar attilah avatar damianreeves avatar davidpodhola avatar dzoukr avatar elanhasson avatar forki avatar gitter-badger avatar jichang avatar jubast avatar kasperk81 avatar mbernard avatar mhertis avatar neftedollar avatar pkese avatar romanstetsenko avatar yevhen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

orleankka's Issues

Create Wiki with documentation

  • Basic concepts
  • Getting Started
  • Explanation for each provided sample
  • Documentation for features not being present in Orleans but present in Orleankka.

Support for Orleankka in Visual Studio 2015

When I build Orleankka in Microsoft Visual Studio Enterprise 2015 RC, I get the following error:

Unsupported

This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them.

For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after clicking OK.

 - Deployment, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Azure.Deployment\Deployment.ccproj"

No changes required

These projects can be opened in Visual Studio 2015, Visual Studio 2013, Visual Studio 2012, and Visual Studio 2010 SP1 without changing them.
- Orleankka, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka\Orleankka.csproj"
- Orleankka.Tests, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka.Tests\Orleankka.Tests.csproj"
- Orleankka.Core, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka.Core\Orleankka.Core.csproj"
- TestKit, "TestKit"
- Orleankka.TestKit, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka.TestKit\Orleankka.TestKit.csproj"
- Orleankka.TestKit.Tests, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka.TestKit.Tests\Orleankka.TestKit.Tests.csproj"
- Demo, "Demo"
- FSharp, "FSharp"
- Demo.App, "C:\Temp\Orleankka-master\Orleankka-master\Source\Demo.App\Demo.App.csproj"
- Demo.App.Tests, "C:\Temp\Orleankka-master\Orleankka-master\Source\Demo.App.Tests\Demo.App.Tests.csproj"
- Orleankka.FSharp, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Api\Orleankka.FSharp.fsproj"
- Orleankka.Azure, "C:\Temp\Orleankka-master\Orleankka-master\Source\Orleankka.Azure\Orleankka.Azure.csproj"
- Examples, "Examples"
- Reentrant, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Reentrant\Reentrant.csproj"
- DependencyInjection, "DependencyInjection"
- Azure, "Azure"
- Serialization, "Serialization"
- Bond, "Bond"
- HttpProtocol, "HttpProtocol"
- Client, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Azure.Client\Client.csproj"
- Cluster, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Azure.Cluster\Cluster.csproj"
- Chat, "Chat"
- Demo, "Demo"
- HelloWorld, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.HelloWorld\HelloWorld.fsproj"
- Shop, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.Shop\Shop.fsproj"
- Server, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.Chat.Server\Server.fsproj"
- Client, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.Chat.Client\Client.fsproj"
- Native, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Serialization.Native\Native.csproj"
- JSON, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.Serialization.JSON\JSON.csproj"
- EventSourcing, "EventSourcing"
- Idiomatic, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.EventSourcing.Idiomatic\Idiomatic.csproj"
- Typed, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.EventSourcing.Typed\Typed.csproj"
- Persistence, "Persistence"
- GES, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.EventSourcing.Persistence.GES\GES.csproj"
- Autofac, "C:\Temp\Orleankka-master\Orleankka-master\Source\Example.DependencyInjection.Autofac\Autofac.csproj"
- Reentrant, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.Reentrant\Reentrant.fsproj"
- Worker, "C:\Temp\Orleankka-master\Orleankka-master\Source\FSharp.Demo.Worker\Worker.fsproj"
- Examples, "Examples"
- Orleankka, "C:\Temp\Orleankka-master\Orleankka-master\Orleankka.sln"

Source\Example.Azure.Deployment\Deployment.ccproj: The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?LinkId=500718&projecttype=CC5FD16D-436D-48AD-A40C-5A424C6E3E79

query other actor at command handler of EventSourcedActor

I'm having difficulties of implementing following scenorio.

Right before receiving a payment for an item, I want to make a call to (for example ) warehouse service, via exposed API endpoint (I cannot make a reservation, just buy or check if available). The idea is to minimize probability of receiving a money for an item that was already sold. At first, I tried to create an Actor, that encapsulates actual API call, and returns availability via query. Like this:

public class Basket : EventSourcedActor{
   public IEnumerable<Event> Handle(Checkout cmd){
      var warehouse = System.ActorOf<Warehouse>(0);
      var itemAvailable = await warehouse.Ask(new IsAvailable(cmd.ItemId));  //async needed!
      if(!itemAvailable) throw Exception("we don't have this item!");
      //blabla
      yield return new ItemCheckedOut(cmd.ItemId);
   }
}

First questions, can we make an async command handler and does it really make sense?

If not, these are couple of workarounds I'm thinking of:

  1. make warehouse a simple service with a synchronous call.
  2. add an extra step with a checking actor
public class Basket : EventSourcedActor{
   public IEnumerable<Event> Handle(PrepaireForChecking cmd){
      var warehouse = System.ActorOf<Warehouse>(0);
      warehouse.Tell(new EnsureItemsAvailable(){
         ItemId = cmd.ItemId,
         onComplete  = this.Self
      });  //warehouse will send commands back to continue or cancel checking out
      yield return new ItemsArePrepairedForCheckingout();
   });

   public IEnumerable<Event> Handle(Checkout cmd){      
      //handle payment
      yield return new ItemPurchased();
   }

   public IEnumerable<Event> Handle(CancelCheckoutDueToItemUnavailability cmd){
      yield return new CheckingoutCancelled();
   }
}

The second approach seems to make more sense if such history is needed in domain model, otherwise first 1

Are there any other ideas? Am I doing something that makes sense with Event Sourcing?

Strong typed actor interface in client project

I've tryed Orlenkka, it is awesome but it lacks of 2 features (maybe there are but I haven't found these).

  1. The possibility to have a strong typed proxy in the client side project. I love intellisense, and an Ask or Tell method that take object as parameter doesn't help code writing, the same is for the return value of Ask.
  2. To have a common lib with only contracts shared between client and server. I need to share contracts with third parts without any server implementation detail.

In my public repo I've added an example on how to achieve this.
It requires some patches in Orleankka library (ActorAssembly, Dispatcher, ActorTypeCode and ActorPrototype) and some new interfaces.
The Client side uses Castle.DinamcProxy to generate on the fly a proxy that implements the actor interface. This proxy forwards messages to an internal ActorRef.
The server side uses the improved ActorTypeCode and 2 new interfaces (IActorProxyInterface, INonUniformActorProxyInterface). Patches in Dispatcher and ActorAssembly do the magic.

Is it the right way to reach my goal with Orleankka? There are other ways?

ETA for Orleans 1.0.10

Do you have any ETA for adding support of Orleans 1.0.10 and release a new nuget package of Orleankka?

streams in playground environment.

With current configs embedded with orleankka, it is impossible to use streams in playground() environment because configs are missing. I've made a custom build with provider settings and streams are working fine. Do you want me to create PR with these changes?

Reactive Extensions (RX) samples

On the home page of this repo you said "Reactive Extensions (RX) support (client-side observers only)". However I'm not sure how it should be used. Do you have any code samples using it?

Support for non-public Reentrant callback

Currently static callback method that can be provided in Reentrant attribute has to be public. Please change the binding definition so non-public methods can be provided.
StreamSubscription attribute supports non-public callbacks.

[EXAMPLE] FSMs with actors (C#)

Improvement of Greg's idiomatic CQRS/ES example with FSM. Also showcase how to deal with durable actor creation in a reliable and elegant way

BootstrapProviderConfiguration properties should check null

 public BootstrapProviderConfiguration(Type type, object properties)
        {
            this.type = type;
            this.properties.Add(BootstrapProvider.TypeKey, type.AssemblyQualifiedName);
            this.properties.Add(BootstrapProvider.PropertiesKey, Serialize(properties));
        }

Orleankka Support for Azure Gateway without using Cloud Services ?

We've recently move away from Cloud Services to TopShelf implemented exe's to allow us to deploy more rapidly.

If we configure to use Gateway Ports etc. everything connects up but I couldn't figure out why I couldn't just continue to use the Azure Gateway type without using AzureClientConfigurator / AzureServerConfigurator as they have a dependency on AzureSilo ?

I've had a dig through the source and I can see the AzureSilo is doing a bunch of additional work. So I thought I'd stop and ask if this is a supported configuration.

If it is support then the outlining code configuration settings for the silo and the client would be much appreciated.

NB. I've checked out the ServiceFabric Azure @ReubenBond built as that works he set's a bunch of settings on the SiloHost manually and I don't think I can get to the underlying SiloHost inside Orleankka can I ?

I've also asked this question over at the Orleans repo to see if it is a supported situation from an Orleans perspective.

Serialization pass-through option

This is useful for implementing custom protocols like Http/Tcp. Can have an endpoint which receives message serialized as JSON and if cluster also uses JSON serializer, incoming byte[] can then be passed as-is, without spending resources on unnecessary transcoding

Simplify configuration api [C#]

Currently, configuration api in Orleankka has the following shape:

ActorSystem.Configure()
.Client/Cluster/Embedded/Playground()
.From(config)
.Register(assemblies)
.Register<TBootstrapper>(props)
.Etc()
.Done()

It's uneccessary verbose and naming creates problems such as introduction of Interceptor led to overloading issues with Register<T>(object props) where T: ActorActivator and forced to use suffixes (ie RegisterInterceptor).

The proposed implrovement is to get rid of multi-layered configuration and RegisterXXX prefixes by moving to the following form:

ClusterActorSystem.Configure(config, x => x
    .Assemblies(...)
    .Bootstrap<TBootstrapper>(props)
    .Activator<TActivator>(props)
    .Interceptor<TInterceptor>(props)
    .StreamProvider<TInterceptor>(props));

No need to call Done(), no need to use RegisterXXX prefixes as everything is wrapped in Configure verb.

[BLOG] Scaling reminders

Storing reminder state in a distributed, partitioned fashion. Correlation, compensation, idempotency, etc. Useful for implementing highly scalable orchestration services (Saga/ProcessManager/Workflow)

Complete F# configuration api

I understand that fluent DSL used by C# version might not be usable in F# and so @AntyaDev created an alternative function-based api for F#. Unfortunately it's not feature complete with C# version: registration of stream providers / interceptors and some of the other things is missing.

Would be great if we can make it fully cover C# version (only with more convenient api).

TaskBuilder TryFinally bug

Just a quick FYI, I glanced at the TaskBuilder code briefly, and the current TryFinally implementation

   member this.TryFinally(m, compensation) =
      try this.ReturnFrom m
      finally compensation()

probably does not work as one might expect.

Stateful actors

This is one of the biggest omissions. Adding support for stateful actors will open up access to ready-made storage providers which were written by Olreans community. Could be useful fior newcomers.

Introduce OnMissing message handler

This is useful for handling situations when no handler method is registered for received message (its type). This is similar to Ruby/Smalltalk method _missing. Can then do logging, re-routing, throwing more descriptive exception, etc. Very useful for implementing FSMs.

Implementation details:

  • Implement as virtual method on Actor class
  • Ask prototype for registered dispatcher before do actual dispatch
  • Call OnMisssing method.
  • Default implementation should throw an exception

Nake: Spaces in directory confuses params passed to MSBuild

When runninng:

nake build

from the solution root I get the following:

MSBUILD : error MSB1008: Only one project can be specified.
Switch: Samples\Orleankka\Output;ReferencePath=C:\Users\a\Code

For switch syntax, type "MSBuild /help"
Process exited with code 1

Actual directory name was "Code Samples"

Silo/Actor-level interceptors

Currentlly, to achieve something similar, people use inheritance, which is a wrong way to tackle the problem. Orthogonal concerns should not be added via inheritance.

Interceptors should have access to Actor instance and its services. For example interceptor can auto deactivate actor on concurrent writes (split-brain).

This is also requried to be on par with Orleans functionality.

pattern matching GUID with declarative stream subscription

the following match fails to be recognized by Orleankka, though it is working fine when .Net regexp matcher.

let idMatcher = new Regex(@"(?<resortId>\b[0-9a-f]{8}[-]?([0-9a-f]{4}[-]?){3}[0-9a-f]{12}\b)");;
idMatcher.Match(guid.ToString()).Groups.["resortId"].Value;;
> val it : string = "fc5c3cde-a867-4238-a688-b3601f43253d"

failing test: aprooks@4ebafb3

Reentrant callback not invoked for Queries

I have provided a callback method using Reentrant attribute.
This method gets called only for messages that arrived through streams.
Queries sent directly to the actor do not invoke the callback method to check if they should be reentrant.

The expected behaviour is for all messages to invoke the callback.

Sequence is returning more than one element exception: MetadataToken is not unique across modules

Preface: I've been working with @yevhen on tracking down this issue and he is unable to reproduce as of yet. I can consistently reproduce with a single method on my machine.


In TypedActor.cs, line 20:

  var member = GetType()
                .GetMembers()
                .Single(x => 
                    x.Module.MetadataToken == invocation.ModuleToken && 
                    x.MetadataToken == invocation.MemberToken);

The code can throw an exception with the message of "Sequence is returning more than one element exception".

Initially, the code did did not filter the members by Module.MetadataToken, as the MetaDataToken is supposed to be unique within a CLR Module. @yevhen did modify the code to filter by Module and in my case I have two methods in different modules with the same Metadatatoken for both the member and the module.

image

Issue with Microsoft.CodeAnalysis.* packages

We use the current publish NuGet packages for Orleankka but we are getting some weirdness.

If we run our test suite using Visual Studio then everything is fine. If we use our VSO Build Agent Orleankka.TestKit complains about not being able to find Microsoft.CodeAnalysis.CSharp version 1.0.0.

Redirects are all configured so I pulled the latest source and surprised to see that already paket.dependencies already has entries for 1.1.1.

Our code was at 1.1.2 so I back revved it to 1.1.1 and still didn't work. So I back rev'd it to 1.0.0 and it complained about System.Collections.Immutable 1.1.36 so did this one and the tests on the build agent worked again.

The test worked all the time locally so still can't explain that. Are the nugget packages for Orleankka the same as the master branch ?

I've never used Paket before or Nake but I was wondering if I should try to submit a PR with all of the packages versions refreshed, I see most are pinned and for good reason no doubt, are they any that we already know will not work ?

F# helpers for Bootstrappers and Interceptors

I don't see a reason why Bootstrappers and Interceptors should be statefull and inherit C# object. We could have a simple function props ->Task<unit> or props -> IActorSystem -> Task<unit> registered as bootstrapper, and then wrapped internally as c# type. Not 100% sure it is possible though :)

something like:

assemblies
|> createCluster
|> bootstrapper (fun _ -> log "bootstrapped!")
|> complete
|> start

Don't use assembly references if not needed

I created a simple console application and added the following references. This project does not use Azure.

err1

When I run the application, I get the error:

Could not load file or assembly Microsoft.WindowsAzure.Storage, Version=4.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 or one of its dependencies. The system cannot find the file specified.

err

Nake.bat not working

When I clone the repository on Microsoft Windows [Version 10.0.10240] and run nake, I get this error

MSBUILD : error : Package restore is disabled by default. To give consent, open
the Visual Studio Options dialog, click on Package Manager node and check 'Allow
 NuGet to download missing packages during build.' You can also give consent by
setting the environment variable 'EnableNuGetPackageRestore' to 'true'.
MSBUILD : error MSB3073: The command "Tools\NuGet.exe restore Orleankka.sln" exi
ted with code 1.
Microsoft.Build.Tasks.Exec failed

This can be easily fixed by using the latest nuget

Chat Sample not working

Hi,

Chat sample is not working. Always throws the same exception:

Unable to map type 'Example.IChatRoom' to the corresponding actor type. Make sure that you've registered the assembly containing this type

Proper support of F#

Current F# API looks quite robust but has one drawback - it's not fully FP idiomatic and has false meaning.

override this.Receive message reply = task {
      match message with
      | Balance         -> balance |> reply
      | Deposit amount  -> balance <- balance + amount
      | Withdraw amount -> 
          if balance >= amount then balance <- balance - amount         
          else invalidOp "Amount may not be larger than account balance. \n"
   }

What the problem with current API?

  • Hiding Orleans’s request/response model which is essentially idiomatic FP approach.
    Receive: message:'TMessage -> reply:(obj -> unit) -> Task<unit>
    Task<unit> is saying that we returns nothing but it's not true.
  • reply:(obj -> unit) has false name meaning which is not correspond to the real side effect which this function does. Also it has wrong type definition for such action. I would prefer to see effectful function.
  • hard to test from FP perspective.

I think we have at least two possible solutions:

  • Leave it as it is to keep quite readable API which is easy to use and ignore the fact that it's not FP idiomatic.
  • Change Receive on Receive: message:'TMessage -> Task<obj>
override this.Receive message = task {
      match message with
      | Balance         -> return response(balance)
      | Deposit amount  -> return response(balance <- balance + amount)
      | Withdraw amount -> 
          if balance >= amount then balance <- balance - amount
          else invalidOp "Amount may not be larger than account balance. \n"
          return response()
   }

This approach will force us explicitly put return expression in every DU case. It looks ugly, in other words it’s impairs readability, but folks who use async { } already familiar with return expression. In F# projects we can notice that in majority of cases we always use return within async { } computations therefore when time comes and we will replace task with async then it will look quite natural.

FSM (switchable behaviors)

The idea is to have built-in FSM support in Orleankka similar to what Akka.Net have with Become but adapted for Orleans virtual actors. Phase 2 will be to introduce hierarchical FSM (HSM) like what Stateless provides at the moment.

That should make Orleankka more close to Akka in terms of application level features and should also make writing actors with complex behaviors more pleasant. I plan to port some of the work (and concepts) I did for latest release of Stateless.

P.S. That will be the last feature before v1 release. Then only documentation will be added.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.