Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
I don't know what your actor publisher was doing inside there. But yeah,
this is even better if you can get away without implementing custom stages.

On Jul 20, 2016 16:51, "Jakub Liska"  wrote:

> There seems to be a third alternative to ActorPublisher :
>
>  Source.actorRef[User.OutgoingMessage](10, OverflowStrategy.fail).
> mapMaterializedValue
>
> the actorRef can be passed to a different Actor that would feed it
> messages and it would all behave like ActorPublisher, right?
>
> On Wednesday, July 20, 2016 at 4:21:35 PM UTC+2, Konrad Malawski wrote:
>>
>> Glad you resolved it.
>> Related hint is that one really really shouldn't be using ActorPublisher,
>> you should build stages from GraphStage instead,
>> the reason is that a) ActorPublisher is not fusable b) it's really hard
>> to actually implement a *correct* Publisher (even with ActorPublisher's
>> help).
>>
>> Happy hakking.,
>>
>> --
>> Konrad `ktoso` Malawski
>> Akka  @ Lightbend 
>>
>> On 20 July 2016 at 16:19:58, Jakub Liska (liska...@gmail.com) wrote:
>>
>> RESOLVED :
>>
>> I found a way to create Source and consequently ActorPublisher from
>> ActorRef, so that I can obtain the ActorRef upfront, so instead of :
>>
>> val stateChangeSource: Source[PipelineState, ActorRef] = Source.
>> actorPublisher[PipelineState](StateChangePublisher.props)
>>
>> I do :
>>
>> val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
>> PipelineState](stateChangePublisherRef)
>> val stateChangeSource = Source.fromPublisher(stateChangePublisher)
>>
>> And I can send messages to stateChangePublisherRef and push them to
>> Browser...
>>
>> On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>>>
>>> Could you provide a sample snippet that we could help out with?
>>> Context helps to get quicker help.
>>>
>>> --
>>> Konrad `ktoso` Malawski
>>> Akka  @ Lightbend 
>>>
>>> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com) wrote:
>>>
>>> hey,
>>>
>>> I hit a deadend with combination of Websockets and ActorPublisher
>>> because the TextMessage expects Source and one can obtain the underlying
>>> ActorRef from ActorPublisher only by materializing it :
>>>
>>>
>>> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>>>
>>> Theoretically one could look it up but then there is a question "when"
>>> it becomes materialized :-/
>>> --
>>> >> 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+...@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-use

Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
There seems to be a third alternative to ActorPublisher :

 Source.actorRef[User.OutgoingMessage](10, OverflowStrategy.fail).
mapMaterializedValue

the actorRef can be passed to a different Actor that would feed it messages 
and it would all behave like ActorPublisher, right?

On Wednesday, July 20, 2016 at 4:21:35 PM UTC+2, Konrad Malawski wrote:
>
> Glad you resolved it.
> Related hint is that one really really shouldn't be using ActorPublisher, 
> you should build stages from GraphStage instead,
> the reason is that a) ActorPublisher is not fusable b) it's really hard to 
> actually implement a *correct* Publisher (even with ActorPublisher's help).
>
> Happy hakking.,
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:19:58, Jakub Liska (liska...@gmail.com ) 
> wrote:
>
> RESOLVED : 
>
> I found a way to create Source and consequently ActorPublisher from 
> ActorRef, so that I can obtain the ActorRef upfront, so instead of :
> 
> val stateChangeSource: Source[PipelineState, ActorRef] = Source.
> actorPublisher[PipelineState](StateChangePublisher.props)
>
> I do :
>
> val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
> PipelineState](stateChangePublisherRef)
> val stateChangeSource = Source.fromPublisher(stateChangePublisher)
>
> And I can send messages to stateChangePublisherRef and push them to 
> Browser... 
>
> On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote: 
>>
>> Could you provide a sample snippet that we could help out with?
>> Context helps to get quicker help.
>>
>> -- 
>> Konrad `ktoso` Malawski
>> Akka  @ Lightbend 
>>
>> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com) wrote:
>>
>> hey,  
>>
>> I hit a deadend with combination of Websockets and ActorPublisher because 
>> the TextMessage expects Source and one can obtain the underlying ActorRef 
>> from ActorPublisher only by materializing it :
>>  
>>
>> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>>
>> Theoretically one could look it up but then there is a question "when" it 
>> becomes materialized :-/
>> --
>> >> 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+...@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.


Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
RESOLVED : 

I found a way to create Source and consequently ActorPublisher from 
ActorRef, so that I can obtain the ActorRef upfront, so instead of :
   
val stateChangeSource: Source[PipelineState, ActorRef] = Source.
actorPublisher[PipelineState](StateChangePublisher.props)

I do :

val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
PipelineState](stateChangePublisherRef)
val stateChangeSource = Source.fromPublisher(stateChangePublisher)

And I can send messages to stateChangePublisherRef and push them to 
Browser... 

On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>
> Could you provide a sample snippet that we could help out with?
> Context helps to get quicker help.
>
> -- 
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com ) 
> wrote:
>
> hey,  
>
> I hit a deadend with combination of Websockets and ActorPublisher because 
> the TextMessage expects Source and one can obtain the underlying ActorRef 
> from ActorPublisher only by materializing it :
>  
>
> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>
> Theoretically one could look it up but then there is a question "when" it 
> becomes materialized :-/
> --
> >> 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.


Re: [akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
Glad you resolved it.
Related hint is that one really really shouldn't be using ActorPublisher,
you should build stages from GraphStage instead,
the reason is that a) ActorPublisher is not fusable b) it's really hard to
actually implement a *correct* Publisher (even with ActorPublisher's help).

Happy hakking.,

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 16:19:58, Jakub Liska (liska.ja...@gmail.com) wrote:

RESOLVED :

I found a way to create Source and consequently ActorPublisher from
ActorRef, so that I can obtain the ActorRef upfront, so instead of :

val stateChangeSource: Source[PipelineState, ActorRef] = Source.
actorPublisher[PipelineState](StateChangePublisher.props)

I do :

val stateChangePublisher: Publisher[PipelineState] = ActorPublisher[
PipelineState](stateChangePublisherRef)
val stateChangeSource = Source.fromPublisher(stateChangePublisher)

And I can send messages to stateChangePublisherRef and push them to
Browser...

On Wednesday, July 20, 2016 at 4:07:13 PM UTC+2, Konrad Malawski wrote:
>
> Could you provide a sample snippet that we could help out with?
> Context helps to get quicker help.
>
> --
> Konrad `ktoso` Malawski
> Akka  @ Lightbend 
>
> On 20 July 2016 at 16:03:30, Jakub Liska (liska...@gmail.com )
> wrote:
>
> hey,
>
> I hit a deadend with combination of Websockets and ActorPublisher because
> the TextMessage expects Source and one can obtain the underlying ActorRef
> from ActorPublisher only by materializing it :
>
>
> https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30
>
> Theoretically one could look it up but then there is a question "when" it
> becomes materialized :-/
> --
> >> 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] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Konrad Malawski
Could you provide a sample snippet that we could help out with?
Context helps to get quicker help.

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 20 July 2016 at 16:03:30, Jakub Liska (liska.ja...@gmail.com) wrote:

hey,

I hit a deadend with combination of Websockets and ActorPublisher because
the TextMessage expects Source and one can obtain the underlying ActorRef
from ActorPublisher only by materializing it :

https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30

Theoretically one could look it up but then there is a question "when" it
becomes materialized :-/
--
>> 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.


[akka-user] How to use WebSockets with ActorPublisher?

2016-07-20 Thread Jakub Liska
hey, 

I hit a deadend with combination of Websockets and ActorPublisher because 
the TextMessage expects Source and one can obtain the underlying ActorRef 
from ActorPublisher only by materializing it :
 
https://github.com/akka/akka/blob/29029be31d9198ed45c73efbc2d0212651882a94/akka-http-core/src/main/scala/akka/http/scaladsl/model/ws/Message.scala#L30

Theoretically one could look it up but then there is a question "when" it 
becomes materialized :-/

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