Re: [akka-user] Akka game state

2016-03-20 Thread Konrad Malawski
On Sun, Mar 13, 2016 at 7:12 PM, Владимир Морозов 
wrote:

> If two Player's actors live in two different remote actor systems - how
> safely transfer item from one player to other (read transactionally or
> guaranteed)
>
We don't do distributed transactions, they're  the root of all evil in
distributed systems ;-)

Instead you would send the message over, and expect an acknowlagement from
the other player "ok, I received your item",
and if you didn't receive an ACK, you would try to send it again (because
maybe his node was down, right?).

We have utils to help with that, in Akka Persistence it's
AtLeastOnceDelivery






-- 
Cheers,
Konrad 'ktoso' Malawski
Akka  @ Lightbend 

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


Re: [akka-user] Akka game state

2016-03-19 Thread Владимир Морозов
Thank you, I dig in it :)

пятница, 18 марта 2016 г., 20:17:57 UTC+3 пользователь Konrad Malawski 
написал:
>
>
> On Sun, Mar 13, 2016 at 7:12 PM, Владимир Морозов  > wrote:
>
>> If two Player's actors live in two different remote actor systems - how 
>> safely transfer item from one player to other (read transactionally or 
>> guaranteed) 
>>
> We don't do distributed transactions, they're  the root of all evil in 
> distributed systems ;-)
>
> Instead you would send the message over, and expect an acknowlagement from 
> the other player "ok, I received your item",
> and if you didn't receive an ACK, you would try to send it again (because 
> maybe his node was down, right?).
>
> We have utils to help with that, in Akka Persistence it's 
> AtLeastOnceDelivery 
> 
>  
>
>
>
>
> -- 
> Cheers,
> Konrad 'ktoso' Malawski
> Akka  @ Lightbend 
>

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Akka game state

2016-03-13 Thread Владимир Морозов
Hi All, I have some simple Actor:

case class Item(id: String, description: String)


object Player {


  sealed trait PlayerMessage


  case class PickupItem(item: Item)


  case class GiveItem(itemId: String, player: ActorRef)


  case object ShowInventory


  def props(): Props =
Props(classOf[Player])
}


class Player extends Actor with ActorLogging {


  import Player._


  var inventory = Seq.empty[Item]


  override def receive: Receive = {
case PickupItem(item) =>
  inventory = inventory :+ item


case GiveItem(itemId, player) =>
  inventory
.find(_.id == itemId)
.map { item =>
  inventory = inventory.diff(Seq(item))
  player ! PickupItem(item)
}


case ShowInventory =>
  log.info(s"[${context.self.path.name}] [${inventory.mkString(", ")}]")
  }
}



If two Player's actors live in two different remote actor systems - how 
safely transfer item from one player to other (read transactionally or 
guaranteed) change state of two actor, by design all actions with inventory 
persisted to database (without akka-persistence).

-- 
>>  Read the docs: http://akka.io/docs/
>>  Check the FAQ: 
>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>  Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.