orleanscontrib / orleankka Goto Github PK
View Code? Open in Web Editor NEWFunctional API for Microsoft Orleans http://orleanscontrib.github.io/Orleankka
License: Apache License 2.0
Functional API for Microsoft Orleans http://orleanscontrib.github.io/Orleankka
License: Apache License 2.0
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
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:
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?
I've tryed Orlenkka, it is awesome but it lacks of 2 features (maybe there are but I haven't found these).
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?
Do you have any ETA for adding support of Orleans 1.0.10 and release a new nuget package of Orleankka?
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?
Demo observers. Also, will be a good example on advantages of streams (could be compared to the stream-based version)
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?
It is pretty hard to find which newly added actor doesn't have constructor. Would be much easier if exception would be like System.MissingMethodException : No parameterless constructor defined for Orleankka.TestActor
ActorRef is marked as serializable but its mock equivalent is not which causes invalid test results when used between actors.
There is no option in Orleankka to Resume client stream subscription. Our client is unstable and is subscribing over and over again until it blows up pubsub store. More info.
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.
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
public BootstrapProviderConfiguration(Type type, object properties)
{
this.type = type;
this.properties.Add(BootstrapProvider.TypeKey, type.AssemblyQualifiedName);
this.properties.Add(BootstrapProvider.PropertiesKey, Serialize(properties));
}
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.
Similar to C# version we should have FSharp.Runtime library and corresponding nuget package.
The ActorSystem.createClient
call should not be inlined as it is accessing an internal method and will cause a MemberAccessException
for callers.
should be
foreach (var type in assemblies.SelectMany(x => x.ActorInterfaces()))
or replaced with
client.Assemblies(assemblies);
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
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.
Storing reminder state in a distributed, partitioned fashion. Correlation, compensation, idempotency, etc. Useful for implementing highly scalable orchestration services (Saga/ProcessManager/Workflow)
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).
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.
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.
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:
Good candidate to be merged back to the core (after some trial)
That's what I tried
https://gist.github.com/aprooks/3f9cb68a3f17ac041362
the output is
Started system
recieved System.String
handled
recieved Program+TestRecord
handled record
so streams are only working if Orleankka.Actor is used (not Fsharp adapter) and DU's are completely ignored
Here we're tracking things that need to be put in place in order to target Orleans 2.0 and .Net Core 2.0:
(based on https://gitter.im/OrleansContrib/Orleankka?at=59e212165c40c1ba799d7fbc )
.csproj
/.fsproj
project files to the new dotnet formatNake
won't support .Net Core (Fake
is a candidate)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\CodeFor switch syntax, type "MSBuild /help"
Process exited with code 1
Actual directory name was "Code Samples"
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.
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
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.
Showcase how to dealing with serialization, routing, media types, versioning, etc. See @damianh Cedar.CommandHandling for inspiration
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.
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.
Since 1.3.0 Orleans added support distributed cancellation tokens in grain methods (GrainCancellationToken
) see #1599
This need to be ported to Orleankka
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 ?
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
So that they could be passed around in the same way as now actor refs could be passed
It is nice to have Orleankka running in Microsoft Service Fabric http://azure.microsoft.com/en-us/campaigns/service-fabric/ as a Reliable Service.
The simplicity of creating a Service Fabric Stateless Service via Visual Studio 2015 http://azure.microsoft.com/en-us/documentation/articles/service-fabric-reliable-services-quick-start/ and integrating Orleankka would be nice feature.
I created a simple console application and added the following references. This project does not use Azure.
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.
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
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
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?
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.I think we have at least two possible solutions:
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.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.