akka.net

28
Akka.NET

Upload: betclic-everest-group-tech-team

Post on 05-Aug-2015

770 views

Category:

Software


1 download

TRANSCRIPT

Akka.NET

class ConsoleWriterActor : UntypedActor{

protected override void OnReceive(object message){

if (message is Messages.InputError){

var msg = message as Messages.InputError;Console.ForegroundColor = ConsoleColor.Red;Console.WriteLine(msg.Reason);

}else{

Console.WriteLine(message);}

Console.ResetColor();}

}

System = ActorSystem.Create("MyActorSystem");

var props = Props.Create<ConsoleWriterActor>();

var actor = System.ActorOf(props, "consoleWriterActor");

Creating the system & an actor

Messages are POCOs

Message-passing is asynchronous

Messages are immutable

actor.Tell("message");

Sending a message

Nothing more

_consoleWriterActor.Tell(new Messages.NullInputError());

Sender.Tell(new Messages.ContinueProcessing());

Context.ActorSelection("akka://MyActorSystem/user/tailCoordinatorActor").Tell(new TailCoordinatorActor.StartTail(msg, _consoleWriterActor));

Communication between actors

protected override SupervisorStrategy SupervisorStrategy(){

return new OneForOneStrategy(10, // maxNumberOfRetriesTimeSpan.FromSeconds(30), // durationx =>{

if (x is ApplicationException)return Directive.Escalate;

if (x is ArithmeticException)return Directive.Resume;

if (x is NotSupportedException)return Directive.Stop;

return Directive.Restart;});

}

Supervision strategy

Asynchronous system

.WithDispatcher("akka.actor.synchronized-dispatcher")

Routers

Actors pool

Blocking actors

var getStarrer = _gitHubClient.Activity.Starring.GetAllForUser(starrer);

//ewww

getStarrer.Wait();

var starredRepos = getStarrer.Result;

Sender.Tell(new StarredReposForUser(starrer, starredRepos));

Async inside an actor

var sender = Sender;

var getStarrer = _gitHubClient.Activity.Starring.GetAllForUser(starrer);

getStarrer.ContinueWith<StarredReposForUser>(res =>

{

var starredRepos = getStarrer.Result;

return new StarredReposForUser(starrer, starredRepos

}).PipeTo(sender);

Plugins

Akka.Remote

Akka.Cluster

Akka.Persistence

Akka.TestKit

Yes, it scales

Resources

• http://getakka.net/

• https://github.com/akkadotnet/akka.net

• https://github.com/petabridge/akkadotnet-code-samples

• https://petabridge.com/bootcamp/

• https://www.youtube.com/c/PetabridgeAcademy

25

Find out more• On https://techblog.betclicgroup.com/

About Us• Betclic Everest Group, one of the world leaders in online

gaming, has a unique portfolio comprising variouscomplementary international brands: Betclic, EverestPoker/Casino, Bet-at-home, Expekt, Imperial Casino, Monte-Carlo Casino…

• Through our brands, Betclic Everest Group places expertise,technological know-how and security at the heart of ourstrategy to deliver an on-line gaming offer attuned to thepassion of our players. We want our brands to be easy to usefor every gamer around the world. We’re building ourcompany to make that happen.

• Active in 100 countries with more than 12 million customersworldwide, the Group is committed to promoting secure andresponsible gaming and is a member of several internationalprofessional associations including the EGBA (EuropeanGaming and Betting Association) and the ESSA (EuropeanSports Security Association).

We want our Sports betting, Poker, Horse racing andCasino & Games brands to be easy to use for everygamer around the world. Code with us to make thathappen.

Look at all the challenges we offer HERE

Check our Employer Page

Follow us on LinkedIn

WE’RE HIRING !