Re: [akka-user] Implementation of Persistent Actor with initial state

2016-10-15 Thread Patrik Nordwall
I'm not sure I understand. You want to read the old data if the persistent
actor doesn't have any events of its own?

You can check the state when you get RecoveryCompleted. You can also count
the events/snapshot in receiveRecover and act on that when
RecoveryCompleted.

/Patrik

fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska :

> Hey,
>
> what is the best practice to do in this hypothetical scenario :
> 1) Say you have a time series pipeline that started at 2014 and created
> persistent state on S3 and other DB systems
> 2) You can introspect these storages and know what partitions already
> exists in all of them
> 3) The persistent actor's job would be scheduling tasks for newly added
> partitions (next minute/hour/day, etc.)
> 3) Now at 2016 you deploy a persistent Actor that will hold state about
> completness (existing partitions) of these storages and keep up with their
> progress
>
> The way I see it, when this persistent Actor boots up, it will have 2
> choices :
> a) either it starts for the very first time, it will have to replay all
> DomainEvents for all historical partitions from 2014 to itself to
> initialize it's state to the current view of the world in 2016
> b) or it restarts or crashes and its state is replayed from the journal
> implicitly
>
> Now I cannot find any reference of how this should be done. The only
> solution that comes to mind is to use persistence-query and obtaining
> Journal :
>
>readJournal.currentPersistenceIds()
>readJournal.eventsByPersistenceId("user-us-1337")
>1.
>And if the result is empty, then it will reconstructs the history.
>
> Is this a way to go?
>
> --
> >> 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.
>

-- 
>>  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] Implementation of Persistent Actor with initial state

2016-10-15 Thread Patrik Nordwall
I think fsm has something similar to recovery completed

lör 15 okt. 2016 kl. 11:34 skrev Jakub Liska :

> Yes, that's what I meant.
>
> Perfect, it would work in Persistent Actor... What about PersistentFSM ?
> I guess that I will have to introduce an initial FSMState where I would
> check whether the persistent state is empty or it was recovered and act on
> that.
>
> Cool, thanks a lot Patrik !
>
>
>
> On Saturday, October 15, 2016 at 8:14:22 AM UTC+2, Patrik Nordwall wrote:
>
> I'm not sure I understand. You want to read the old data if the persistent
> actor doesn't have any events of its own?
>
> You can check the state when you get RecoveryCompleted. You can also count
> the events/snapshot in receiveRecover and act on that when
> RecoveryCompleted.
>
> /Patrik
>
> fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska :
>
> Hey,
>
> what is the best practice to do in this hypothetical scenario :
> 1) Say you have a time series pipeline that started at 2014 and created
> persistent state on S3 and other DB systems
> 2) You can introspect these storages and know what partitions already
> exists in all of them
> 3) The persistent actor's job would be scheduling tasks for newly added
> partitions (next minute/hour/day, etc.)
> 3) Now at 2016 you deploy a persistent Actor that will hold state about
> completness (existing partitions) of these storages and keep up with their
> progress
>
> The way I see it, when this persistent Actor boots up, it will have 2
> choices :
> a) either it starts for the very first time, it will have to replay all
> DomainEvents for all historical partitions from 2014 to itself to
> initialize it's state to the current view of the world in 2016
> b) or it restarts or crashes and its state is replayed from the journal
> implicitly
>
> Now I cannot find any reference of how this should be done. The only
> solution that comes to mind is to use persistence-query and obtaining
> Journal :
>
>readJournal.currentPersistenceIds()
>readJournal.eventsByPersistenceId("user-us-1337")
>1.
>And if the result is empty, then it will reconstructs the history.
>
> Is this a way to go?
>
> --
> >> 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+...@googlegroups.com.
> To post to this group, send email to akka...@googlegroups.com.
>
>
> Visit this group at https://groups.google.com/group/akka-user.
> For more options, visit https://groups.google.com/d/optout.
>
> --
> >> 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.
>

-- 
>>  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] Implementation of Persistent Actor with initial state

2016-10-15 Thread Jakub Liska
Yes, that's what I meant. 

Perfect, it would work in Persistent Actor... What about PersistentFSM ? 
I guess that I will have to introduce an initial FSMState where I would 
check whether the persistent state is empty or it was recovered and act on 
that.

Cool, thanks a lot Patrik !



On Saturday, October 15, 2016 at 8:14:22 AM UTC+2, Patrik Nordwall wrote:
>
> I'm not sure I understand. You want to read the old data if the persistent 
> actor doesn't have any events of its own?
>
> You can check the state when you get RecoveryCompleted. You can also count 
> the events/snapshot in receiveRecover and act on that when 
> RecoveryCompleted.
>
> /Patrik
>
> fre 14 okt. 2016 kl. 22:11 skrev Jakub Liska  >:
>
>> Hey,
>>
>> what is the best practice to do in this hypothetical scenario : 
>> 1) Say you have a time series pipeline that started at 2014 and created 
>> persistent state on S3 and other DB systems
>> 2) You can introspect these storages and know what partitions already 
>> exists in all of them
>> 3) The persistent actor's job would be scheduling tasks for newly added 
>> partitions (next minute/hour/day, etc.)
>> 3) Now at 2016 you deploy a persistent Actor that will hold state about 
>> completness (existing partitions) of these storages and keep up with their 
>> progress
>>
>> The way I see it, when this persistent Actor boots up, it will have 2 
>> choices :
>> a) either it starts for the very first time, it will have to replay all 
>> DomainEvents for all historical partitions from 2014 to itself to 
>> initialize it's state to the current view of the world in 2016 
>> b) or it restarts or crashes and its state is replayed from the journal 
>> implicitly
>>
>> Now I cannot find any reference of how this should be done. The only 
>> solution that comes to mind is to use persistence-query and obtaining 
>> Journal : 
>>
>>readJournal.currentPersistenceIds()
>>readJournal.eventsByPersistenceId("user-us-1337")
>>1. 
>>And if the result is empty, then it will reconstructs the history.
>>
>> Is this a way to go?
>>
>> -- 
>> >> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
>>  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] Re: Simple beginner questions: Accessing values in flows

2016-10-15 Thread mnielsen894
Actually, I worked it out.  Thanks!

On Saturday, October 15, 2016 at 12:51:10 PM UTC-4, mniel...@gmail.com 
wrote:
>
> I have the following code:
>
>
> val cmdSrc: Source[Message, ActorRef] = Source.actorRef[Message](10, 
> OverflowStrategy.fail)
>
> val wsr: WebSocketRequest = WebSocketRequest(myEndpoint)
>
> val webSocketFlow: Flow[Message, Message, 
> Future[WebSocketUpgradeResponse]] = Http().webSocketClientFlow(wsr)
>
> val webSocketGraph: RunnableGraph[(ActorRef, Future[Done])] = 
> cmdSrc.via(webSocketFlow).toMat(printSink)(Keep.both)
>
> val (actorRef, fd): (ActorRef, Future[Done]) = webSocketGraph.run()
>
>
>
> The idea is that I want to send messages to actorRef that are then sent 
> through the flow.
>
> This code produces the required result, but its an early and amateurish 
> attempt as I try to understand Akka.
>
> My questions are:
>
>- Is this somewhere near the accepted idiom, or is there a better 
>representation of the same thing?
>- How do I get my hands on the Future[WebSocketUpgradeResponse] from 
>webSocketFlow (line 3)?
>
> Thanks!
>

-- 
>>  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] Re: ('=') sign still not allowed in query string even with Uri.ParsingMode.Relaxed? (akka/akka#18479)

2016-10-15 Thread Richard Imaoka
Sorry I had read the full discussion but I think I didn't correctly 
understand what is allowed in Akka, and what is RFC 3986 compliant.
Now it's clearer for me - double "=" isn't even RFC 3986 compliant, so it 
shouldn't be allowed in the relaxed mode.

I will try to add decent amount of examples for #276 so that other people 
don't need to ask the same or similar question as I did !


Thanks

2016年10月12日水曜日 16時31分59秒 UTC+9 André:
>
> I know it's long but please read the full discussion in 
> https://github.com/akka/akka/issues/18479.
>
> The problem isn't the question mark but the double "=". That's why you get 
> an IllegalUriException: Illegal query: Invalid input '='.
>
> > will try to work on #276 if no one is picking it up yet
>
> Excellent! :)
>
> On Tuesday, October 11, 2016 at 7:34:40 PM UTC+2, Richard Imaoka wrote:
>>
>> Ah, I thought akka/akka#18479  
>> was saying 
>> that "GROUP=10380?page=2" is a valid case for the relaxed mode 
>> as RomanIakovlev said this.
>>
>> > I still think it's a workaround rather than proper solution though. 
>> Question marks and equal signs are not prohibited inside the query. Just 
>> sayin'.
>>
>> If that is still not allowed, and if you need your own parsing 
>> implementation to allow that, then clarification in the documentation helps 
>> us more, which akka/akka-http#276 
>>  is asking for. (will try 
>> to work on #276 if no one is picking it up yet)
>>
>> Thanks
>>
>> 2016年10月10日月曜日 17時23分00秒 UTC+9 André:
>>>
>>> Hi Richard,
>>>
>>> "GROUP=10380?page=2" isn't a well formed query and therefore can't be 
>>> parsed even in relaxed mode. akka/akka#18479 
>>>  provides a way to prevent 
>>> parsing of the query component and to just look at the raw query string. 
>>> You can access your query via the queryString() method and parse it youself.
>>>
>>> HTH
>>> André
>>>
>>> On Sunday, October 9, 2016 at 6:38:34 PM UTC+2, Richard Imaoka wrote:

 Hi,

 While I tried to work on akka/akka-http#276 
 , and looked at 
 akka/akka#18479  (PR to fix 
 #18479 = akka/akka#18715 ), 
 I found that the following code:

 Query("GROUP=10380?page=2",mode = Uri.ParsingMode.Relaxed)


 throws an exception:

   IllegalUriException: Illegal query: Invalid input '=', expected '+', 
 query-char, 'EOI', '&' or pct-encoded (line 1, column 17): 
 GROUP=10380?page=


 Wasn't akka/akka#18479  (PR=
 akka/akka#18715 ) intended to 
 make this a valid query string, with Uri.ParsingMode.Relaxed ?


 *Additional Info*
 1. I looked for a test case for this.
 According to UriSpec.scala 
 ,
  
 Uri("?a=b=c").query() is still invalid, although query() method has 
 default 
 mode = Uri.ParsingMode.Relaxed.


 2. I didn't fully understand how parsing works  but probably it's 
 because CharacterClases.scala 
 
 defines:

   val `relaxed-query-char` = VCHAR -- "%&=#"

 where ('=') is made invalid?

 UriParser has 

 private[this] val `query-char` = uriParsingMode match {
   case Uri.ParsingMode.Strict  ⇒ `strict-query-char`
   case Uri.ParsingMode.Relaxed ⇒ `relaxed-query-char`
 }

 where `relaxed-query-char` is defined as above.

 Thanks,
 Richard



-- 
>>  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] Re: Issue regarding AddressFromURIString and DNS hostnames

2016-10-15 Thread 'Carl Pulley' via Akka User List
Interestingly, AddressFromURIString is also used in 
akka.cluster.ClusterSettings - and so seeding using DNS names with 
underscores in their hostnames is also problematic (especially as in my 
example use cases I don't have any control over the choice of the DNS name).

Is this an intended design decision (if so, I'd like to understand this 
decision better please) or should this be considered a bug/issue?

Many thanks,

  Carl.

-- 
>>  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] Re: Issue regarding AddressFromURIString and DNS hostnames

2016-10-15 Thread 'Carl Pulley' via Akka User List
Hi Johan,
  how curious. 

I'm using version 1.12.1 of docker and version 1.8.0 of docker-compose, so 
in looking at that specific ticket, I'd have expected it to be included?

Having said that, I note that docker-compose has the open 
issue https://github.com/docker/compose/issues/3912 - so, as you're 
suggesting, it looks like the issue here is with docker not following 
hostname naming standards.

Thanks for that,

  Carl.

-- 
>>  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] Re: Issue regarding AddressFromURIString and DNS hostnames

2016-10-15 Thread Johan Andrén
Hi Carl,

I think that underscore in a hostname actually is not valid, if you look at 
RFC 952, the definition host hostname boils down to:

  ::= [*[]]


Which means a letter followed by zero or more letters, digits or hyphens 
ending with a letter or a digit. I think docker actually has been changed 
to not use underscore (I think this ticket is about 
that https://github.com/docker/docker/issues/22057)

--
Johan
Akka Team

On Saturday, October 15, 2016 at 8:13:08 PM UTC+2, Carl Pulley wrote:
>
> Interestingly, AddressFromURIString is also used in 
> akka.cluster.ClusterSettings - and so seeding using DNS names with 
> underscores in their hostnames is also problematic (especially as in my 
> example use cases I don't have any control over the choice of the DNS name).
>
> Is this an intended design decision (if so, I'd like to understand this 
> decision better please) or should this be considered a bug/issue?
>
> Many thanks,
>
>   Carl.
>

-- 
>>  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] Re: akka.http.scaladsl.model.Uri's apply() methods should still take charset and mode parameters?

2016-10-15 Thread Richard Imaoka
Hi,

Raised an issue akka-http#395 

I didn't realize @2beaucoup was you ! It's great I could to talk to you 
here :)
I guess it takes time for me to submit a PR, but hopefully I can still fix 
this a bit later.

Thanks!

2016年10月12日水曜日 18時24分34秒 UTC+9 André:
>
> > The last comment there by 2beaucoup was exactly what I am asking here.
>
> That's me BTW.
>
> There's no reason one can't pick up on this with an issue/PR in 
> akka/akka-http. ;)
>
> Cheers
> André
>
> On Tuesday, October 11, 2016 at 7:39:57 PM UTC+2, Richard Imaoka wrote:
>>
>> Thank you, I was missing that discussion. The last comment there by 
>> 2beaucoup was exactly what I am asking here.
>> It seems the question was not answered yet?
>>
>> Thanks
>>
>> 2016年10月10日月曜日 17時16分24秒 UTC+9 André:
>>>
>>> Hi Richard!
>>>
>>> See [1] for the discussion related to your question.
>>>
>>> [1] https://github.com/akka/akka/pull/18715#discussion-diff-41831981
>>>
>>> Cheers
>>> André
>>>
>>> On Sunday, October 9, 2016 at 6:49:23 PM UTC+2, Richard Imaoka wrote:

 Hi,

 While I was trying to work on akka/akka-http#276 
 , I noticed something 
 strange.

 After akka/akka#18479  was 
 fixed (PR to fix #18479 = akka/akka#18715 
 ), now the following is 
 possible.
 Isn't it non-intuitive that you can specify Uri.ParsingMode twice - 
 once in Uri() and secondly in query() method?


 val uri = Uri("http://localhost?a^=b;, mode=Uri.ParsingMode.Relaxed)

 //prints Some(b)
 println(uri.query(mode=Uri.ParsingMode.Relaxed).get("a^"))

 //IllegalUriException: Illegal query: Invalid input '^',
 // expected '+', '=', query-char, 'EOI', '&' or pct-encoded
 // (line 1, column 2): a^=b
 println(uri.query(mode=Uri.ParsingMode.Strict).get("a^"))




 If parsing a query string should be deferred as in akka/akka#18479 
 , should we not pass mode as well 
 as charset into akka.http.scaladsl.model.Uri companion object's apply() 
 methods?

 Thanks,
 Richard





-- 
>>  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] Simple beginner questions: Accessing values in flows

2016-10-15 Thread mnielsen894
I have the following code:


val cmdSrc: Source[Message, ActorRef] = Source.actorRef[Message](10, 
OverflowStrategy.fail)

val wsr: WebSocketRequest = WebSocketRequest(myEndpoint)

val webSocketFlow: Flow[Message, Message, Future[WebSocketUpgradeResponse]] 
= Http().webSocketClientFlow(wsr)

val webSocketGraph: RunnableGraph[(ActorRef, Future[Done])] = 
cmdSrc.via(webSocketFlow).toMat(printSink)(Keep.both)

val (actorRef, fd): (ActorRef, Future[Done]) = webSocketGraph.run()



The idea is that I want to send messages to actorRef that are then sent 
through the flow.

This code produces the required result, but its an early and amateurish 
attempt as I try to understand Akka.

My questions are:

   - Is this somewhere near the accepted idiom, or is there a better 
   representation of the same thing?
   - How do I get my hands on the Future[WebSocketUpgradeResponse] from 
   webSocketFlow (line 3)?

Thanks!

-- 
>>  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.