[akka-user] akka/parboiled2/ParserInput Not found but only when running scalatest in Scala Ide

2015-06-02 Thread Gary Struthers
I copied AkkaHttpMicroservice and ServiceSpec to my project and updated 
akka http version to RC3. ServiceSpec passes its test when I run it in sbt 
terminal. But in Scala Ide I can 
import org.parboiled2.ParserInput 

import org.parboiled2._ just to prove it's in the ide's build path

but when I run the ServiceSpec tests in the ide

java.lang.NoClassDefFoundError: akka/parboiled2/ParserInput

And the trace shows errors in here

  "Service" should "respond to single IP query" in {

Get(s"/ip/${ip1Info.ip}") ~> routes ~> check {


I can live with testing in the Terminal but I'd rather clean this up. What 
am I missing?


Scala IDE Build id: 4.0.0-vfinal-20150305-1644-Typesafe


Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: akka/parboiled2/ParserInput Not found but only when running scalatest in Scala Ide

2015-06-02 Thread Gary Struthers
Pardon my myopia, IDE build path was org.parboiled should be 
aka-parsing-experimental. 
Now it works in ide.

Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] ConnectionPoolSetup RC3 scaladoc arg not in source

2015-06-05 Thread Gary Struthers
http://doc.akka.io/api/akka-stream-and-http-experimental/1.0-RC3/#akka.http.ConnectionPoolSetup
The first create and constructor arg is options: Traversable 

[SocketOption]
The linked to source file
https://github.com/akka/akka/blob/release-2.3-dev/akka-http-core/src/main/scala/akka/http/ConnectionPoolSettings.scala
doesn't have this arg

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: ANNOUNCE Akka Streams & HTTP 1.0-RC4

2015-06-27 Thread Gary Struthers
After updating I can't find *akka-http-spray-json-experimental *for RC4 and 
get this error

[error] missing or invalid dependency detected while loading class file 
'SprayJsonSupport.class'.

[error] Could not access type FlowMaterializer in package akka.stream,

[error] because it (or its dependencies) are missing. Check your build 
definition for

[error] missing or conflicting dependencies. (Re-run with `-Ylog-classpath` 
to see the problematic classpath.)

[error] A full rebuild may help if 'SprayJsonSupport.class' was compiled 
against an incompatible version of akka.stream


Also, I can't find *akka-http-testkit-experimental* for RC4

Are these jars coming soon?


Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] http actor & json client questions

2015-07-10 Thread Gary Struthers
I have a simple scaladsl server and it works with this ScalatestRouteTest 
test

  it should "return existing Checking Account Balances" in {

Post(s"/account/balances/checking", GetAccountBalances(1L)) ~> routes ~> 
check {

  status shouldBe OK

  contentType shouldBe `application/json`

  responseAs[CheckingAccountBalances] shouldBe CheckingAccountBalances(
Some(List((1,1000.1

}

  }
I want to make the equivalent call from an actor. My first problem is 
composing the request

Source.single(HttpRequest(POST, uri = "/account/balances/checking", entity 
= ???) -> 1L) 

On the server I'm doing this for marshaling/unmarshalling case classes to 
json

trait BalancesProtocols extends DefaultJsonProtocol {

  implicit val getAccountBalancesFormat = jsonFormat1(GetAccountBalances)

But I don't see how to turn this RootJsonFormat into an entity for the 
request


Then, in the actor do I just call it in receive like this

val future: Future[HttpResponse] = Source.single(
...).via(connectionPoolFlow).runWith(Sink.head)


I was hoping for a way to tell/receive instead of a synchronous call.


Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] http json & actor client questions

2015-07-10 Thread Gary Struthers
I have a simple scaladsl server and it works with this ScalatestRouteTest 
test

  it should "return existing Checking Account Balances" in {

Post(s"/account/balances/checking", GetAccountBalances(1L)) ~> routes ~>
 check {

  status shouldBe OK

  contentType shouldBe `application/json`

  responseAs[CheckingAccountBalances] shouldBe CheckingAccountBalances(
Some(List((1,1000.1

}

  }
I want to make the equivalent call from an actor. My first problem is 
composing the request

Source.single(HttpRequest(POST, uri = "/account/balances/checking", entity 
= ???) -> 1L) 

On the server I'm doing this for marshaling/unmarshalling case classes to 
json

trait BalancesProtocols extends DefaultJsonProtocol {

  implicit val getAccountBalancesFormat = jsonFormat1(GetAccountBalances)

But I don't see how to turn this RootJsonFormat into an entity for the 
request


Then, in the actor do I just call it in receive like this

val future: Future[HttpResponse] = Source.single(
...).via(connectionPoolFlow).runWith(Sink.head)


I was hoping for a way to tell/receive instead.


Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] pipeTo without ask

2015-09-24 Thread Gary Struthers
I have an actor that makes a call returning a Future and it works

  def receive = {

case GetAccountBalances(id: Long) ⇒ {

  try {

  val f = requestCheckingBalances(id, CheckingBalancesClient.
configBaseUrl(hostConfig))

  f pipeTo sender

  } catch {

case e: Exception =>

  sender() ! akka.actor.Status.Failure(e)

  }

}

  }

Before I write similar actors I want to know if using ask is preferred and 
if so why?


Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: Akka Stream and Http 2.0-M1 Released!

2015-11-08 Thread Gary Struthers

>
> The 2.0M-1 docs have a TODO for GraphStage. In the meantime is there 
> anything out there to help start using them?
>

Gary 

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] FlowGraph within Actor

2015-11-13 Thread Gary Struthers
I have a flow graph that needs initialization and post processing. I'd like 
to do this within an actor. The actor receives a message, the flow graph is 
initialized, then the message is passed to it, then its result is sent to 
different actors. I don't see this use case in the docs so I don't know if 
this is fine or problematic.

Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] 1.3.5 The finer points of stream materialization

2015-11-15 Thread Gary Struthers
2.0 M1 doc "Note: This is not yet implemented as stated here, this document 
illustrates intent." 
OK, things will change but how do I bind an object reference to a Flow or 
PushStage at materialization time in the current implementation?

Gary

-- 
>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] Re: 1.3.5 The finer points of stream materialization

2015-11-16 Thread Gary Struthers
Tim,

Sorry, I read *Akka Stream and HTTP Experimental Scala Documentation* in 
bits and pieces and often misinterpret it. 
Materializers provide a key/value mapping and Attributes and 
ActorAttributes provide specific customizations of streams so this makes me 
wonder if streams are intended to allow custom interactions with their 
environment; they aren't intended to always be "pure". If side effects to 
and from the environment are supported then is there a way to bind objects 
that aren't inputs or outputs to stream components at materialization time?

Gary

On Sunday, November 15, 2015 at 7:57:14 PM UTC-8, Tim Harper wrote:
>
> Gary,
>
> I might be lacking necessary context; if not, your question seems a little 
> vague.
>
> Some of the Source factory methods, such as `actorPublisher` or 
> `actorRef`, yield the instantiated `ActorRef` as the materialized value for 
> the stream. You can use `mapMaterializedValue` to modify the value. You 
> could also set an external value using mapMaterializedValue, but that would 
> be unwise since a stream definition can be materialized multiple times.
>
> Hope that helps. Otherwise, clarify your question?
>
> On Sunday, November 15, 2015 at 8:21:07 PM UTC-7, Gary Struthers wrote:
>>
>> 2.0 M1 doc "Note: This is not yet implemented as stated here, this 
>> document illustrates intent." 
>> OK, things will change but how do I bind an object reference to a Flow or 
>> PushStage at materialization time in the current implementation?
>>
>> Gary
>>
>

-- 
>>>>>>>>>>  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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.


[akka-user] GraphStageLogic OutHandler when data isn't available

2016-01-03 Thread Gary Struthers
I want to write a custom Source, like NumberSource in the reference doc and 
I want to feed it with a Queue or a BlockingQueue. How should I handle the 
case when onPull is received but the queue is empty? I saw an example where 
nothing is pushed. I also see there are isAvailable methods but it doesn't 
look like I can use them for this.

Gary

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

2016-01-21 Thread Gary Struthers
I want to create a FanOutShape with generic types that takes a function (A) 
=> (B, B). I'm getting lost with the UnzipWith, UnzipWith2, 
UnzipWithCreator2, and UnzipWithApply. I can't find explanations of how to 
use this. Can someone explain how this is supposed to be used?

Thanks,
Gary

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

2016-01-23 Thread Gary Struthers
Hi Endre,

Thanks for your example, but it doesn't compile. 3 changes fixed it but 
error messages were misleading and getting an ambiguous reference error 
with 22 alternatives is daunting.
The reference doc gives examples for Broadcast but it's not obvious that 
UnzipWith should work the same way and the Scaladocs for UnzipWith obscure 
how to use it. If I hadn't looked at the Scaladocs I probably would have 
guessed if worked like Broadcast but after looking at them I was completely 
confused. GraphUnzipWithSpec has some tests and that's the best information 
I found.

Gary

On Friday, January 22, 2016 at 2:25:44 AM UTC-8, Akka Team wrote:
>
> Hi Gary,
>
> A simple example:
>
> RunnableGraph.fromGraph(GraphDSL.create() { implicit b ⇒
>   val unzip = b.add(UnzipWith[Int, Int, Int]((b: Int) ⇒ (b, b, b))
>
>   Source(1 to 10) ~> unzip.in
>
>   unzip.out0 ~> Sink.ignore
>   unzip.out1 ~> Sink.ignore
>   unzip.out2 ~> Sink.ignore  
>   ClosedShape
> }).run()
>
> Can you please explain what was the source of the confusion so we can 
> improve our docs?
>
> -Endre
>
> On Fri, Jan 22, 2016 at 4:51 AM, Gary Struthers  > wrote:
>
>> I want to create a FanOutShape with generic types that takes a function 
>> (A) => (B, B). I'm getting lost with the UnzipWith, UnzipWith2, 
>> UnzipWithCreator2, and UnzipWithApply. I can't find explanations of how to 
>> use this. Can someone explain how this is supposed to be used?
>>
>> Thanks,
>> Gary
>>
>> -- 
>> >>>>>>>>>> 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.
>>
>
>
>
> -- 
> Akka Team
> Typesafe - Reactive apps on the JVM
> Blog: letitcrash.com
> Twitter: @akkateam
>

-- 
>>>>>>>>>>  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] Testing a real Source and Flow with TestSink

2016-01-28 Thread Gary Struthers
I'm testing a Flow with TestSource and TestSink

"TestSource/TestSink Example" should {
  "work" in {
val (pub, sub) = TestSource.probe[MyClass]
.via(myFlow[String])
.toMat(TestSink.probe[String])(Keep.both)
.run()
sub.request(1)
pub.sendNext(myData)
val response = sub.expectNext()
pub.sendComplete()
sub.expectComplete()
response.size shouldBe 1
  }
}

I want to also test it with a real Source. The reference doc has this 
example.

val sourceUnderTest = Source(1 to 4).filter(_ % 2 == 0).map(_ * 2)
sourceUnderTest
  .runWith(TestSink.probe[Int])
  .request(2)
  .expectNext(4, 8)
  .expectComplete()

If I change the first line from
val sourceUnderTest = Source(1 to 4).filter(_ % 2 == 0).map(_ * 2)
to
val sourceUnderTest = Source(1 to 4)
The test times out. Why do I need filter or map for the test to run?

What I want to do is replace TestSource with a real Source. I expected to 
drop references to "pub" and have just the TestSink subscriber using 
(Keep.right)
and then do assertions on the response. But this doesn't work.

val sourceUnderTest = Source.fromGraph(sourceGraph)

"Source/TestSink Example" should {
  "work" in {
val sub = sourceUnderTest
.via(myFlow[String])
.toMat(TestSink.probe[String])(Keep.right)
.run()
sub.request(1)
val response = sub.expectNext()
response.size shouldBe 1
  }
}

How do I use the nice TestSource/TestSink format with a real Source?

Gary

-- 
>>  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: [ANNOUNCE] Akka 2.4.2 including Streams and HTTP Released!

2016-02-17 Thread Gary Struthers
I've migrated and everything compiles except the http route test. Tests 
like the one shown don't compile, "route" isn't found.

  it should "respond with handled = false for partial path" in {

Get(saPath) ~> route ~> check {

  handled shouldEqual false

}

  }

I don't see how to migrate this, I've 
tried "akka-http-testkit-experimental_2.11" % "2.4.2-RC3" and 2.0.3

-- 
>>  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] Re: [ANNOUNCE] Akka 2.4.2 including Streams and HTTP Released!

2016-02-18 Thread Gary Struthers
Thanks Konrad,

Knowing it wasn't your change was enough, now everything compiles. I was 
missing an unrelated dependency and that messed up the build.

On Thursday, February 18, 2016 at 1:06:22 AM UTC-8, Konrad Malawski wrote:
>
> I've migrated and everything compiles except the http route test. Tests 
> like the one shown don't compile, "route" isn't found.
>
>   it should "respond with handled = false for partial path" in {
>
> Get(saPath) ~> route ~> check {
>
>   handled shouldEqual false
>
> }
>
>   }
>
> I don't see how to migrate this, I've 
> tried "akka-http-testkit-experimental_2.11" % "2.4.2-RC3" and 2.0.3
>
> What is the compile error you're seeing? We didn't really touch much of 
> the Routing things in this release.
>
>
> -- Konrad
>

-- 
>>  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] Custom Sink doesn't pull

2016-02-19 Thread Gary Struthers
The reference doc shows custom Sources and Flows but not Sinks. I wrote a 
custom Sink with an InHandler that overrides onPush but it is never called. 
I assumed that calling runWith would cause the SinkShape to pull by 
default. An upstream custom Flow doesn't receive either onPush or onPull. 
Are custom Sinks supported? If not, I can change it to a Flow. If they are, 
what more do I need to do to make it pull?

Thanks,
Gary

-- 
>>  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] Custom GraphStage with Java Future

2016-02-23 Thread Gary Struthers
I'm calling a 3rd party Java library that returns a Java Future from my 
GraphStageLogic onPush(). I want the future to complete before calling 
pull(in). Simply blocking with Java Future's get(...) works. So do I really 
need to do this within a blocking-dispatcher? If so, how do I setup 
onPush() to use the dispatcher?

Thanks,
Gary

-- 
>>  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] Stream Supervision.Stop handler

2016-03-06 Thread Gary Struthers
Stream supervision is similar but different to Actor supervision. I don't 
see what I'm supposed to do when a stream triggers a Supervision.Stop. What 
does it mean that a stream "completes with an error"? Where is the error? 
If I create a stream in an Actor is the Actor the stream's supervisor? Or 
how is it different?

Thanks,
Gary

-- 
>>  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: Stream Supervision.Stop handler

2016-03-07 Thread Gary Struthers
Thanks Rafał,

So I have a Future callback. If this in in an Actor I doubt it is safe for 
the Actor to retry the stream. The safe thing is just to throw an exception 
if the Future fails.

Gary

On Sunday, March 6, 2016 at 2:21:37 PM UTC-8, Rafał Krzewski wrote:
>
> Hi Gary,
>
> "completes with an error" in Reactive Streams sense. You might want to 
> look at the specification 
> https://github.com/reactive-streams/reactive-streams-jvm
> The error can originate in the Source (any of the Sources in more complex 
> stream graphs), or in any of the transformation steps. The information 
> about the error travels downstream until it reaches the Sink (or sinks). 
> Sinks usually provide a Future as their materialized value, and in case of 
> completed with a Failure. This is how error manifests itself to the "world" 
> outside of the stream. If your application's design is such that the stream 
> is owned by an Actor and the Actor needs to restart itself in case of 
> Stream's failure you need to "connect the wires" yourself.
>
> Cheers,
> Rafał
>
> W dniu niedziela, 6 marca 2016 21:48:59 UTC+1 użytkownik Gary Struthers 
> napisał:
>>
>> Stream supervision is similar but different to Actor supervision. I don't 
>> see what I'm supposed to do when a stream triggers a Supervision.Stop. What 
>> does it mean that a stream "completes with an error"? Where is the error? 
>> If I create a stream in an Actor is the Actor the stream's supervisor? Or 
>> how is it different?
>>
>> Thanks,
>> Gary
>>
>

-- 
>>>>>>>>>>  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] Source with feedback?

2016-03-29 Thread Gary Struthers
I'm thinking about a Source that gets external data having a feedback input 
to tell it when to get more data. Is there a way to make a shape with an 
input and still work as a Source?

Thanks,
Gary

-- 
>>  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] Pass Future to Sink.ignore, how do I know it's completed

2016-07-21 Thread Gary Struthers
My Sink receives a Future. I don't want to do anything with it so I use 
Sink.ignore but then I don't know when it's completed and that I need to 
know. Should I write a custom Sink or does the API already have a solution 
for this?

Gary

-- 
>>  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] Stream within Actor Supervision

2016-08-04 Thread Gary Struthers
If an Actor contains a Stream what happens when the stream throws an 
exception and there is no stream Decider to handle it? Can the Actor's 
supervisor handle it and Resume, Restart, and Stop the Actor with the 
stream?

Gary 

-- 
>>  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] Stream within Actor Supervision

2016-08-04 Thread Gary Struthers
Thanks Konrad, when I skimmed that page I read it as supervision didn't 
work with GraphStage, which I use a lot but reading slowly I see it's 
GraphStage junction that's not supported and I don't use that. This gives 
me what I need.

-- 
>>  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] Stream within Actor Supervision

2016-08-05 Thread Gary Struthers
I think I understand. The other part of my question is when a stream is 
within an actor. If the stream has an error where I want the enclosing 
actor to stop how do I do that? Also, any advice on testing error handling?

-- 
>>  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] Delay within GraphStageLogic

2016-08-25 Thread Gary Struthers
Hi,

I'm handling exceptions in a custom GraphStage, with some exceptions I want 
to retry after a delay. Is there a preferred way to do this? Do I just call 
Thread.sleep?

Gary

-- 
>>  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] Delay within GraphStageLogic

2016-08-26 Thread Gary Struthers
Thanks Konrad, but I posted because I tried scheduleOnce and got no delay

scheduleOnce(logger.debug("1 currentTimeMillis {}", 
System.currentTimeMillis()), 
FiniteDuration(100, MICROSECONDS))

scheduleOnce(logger.debug("2 currentTimeMillis {}", 
System.currentTimeMillis()), 
FiniteDuration(100, MILLISECONDS))

scheduleOnce(logger.debug("3 currentTimeMillis {}", 
System.currentTimeMillis()), 
FiniteDuration(100, SECONDS))

scheduleOnce(logger.debug("4 currentTimeMillis {}", 
System.currentTimeMillis()), 
FiniteDuration(100, MINUTES))

scheduleOnce(logger.debug("5 currentTimeMillis {}", 
System.currentTimeMillis()), 
FiniteDuration(100, DAYS))

Produced

2016-08-26 09:04:15,111 DEBUG ... akka.actor.default-dispatcher-3 - 1 
currentTimeMillis 1472227455110

2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 2 
currentTimeMillis 1472227455114

2016-08-26 09:04:15,115 DEBUG ... akka.actor.default-dispatcher-3 - 3 
currentTimeMillis 1472227455114

2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 4 
currentTimeMillis 1472227455114

2016-08-26 09:04:15,116 DEBUG ... akka.actor.default-dispatcher-3 - 5 
currentTimeMillis 1472227455114

Akka version 2.4.9


Gary

-- 
>>  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] Delay within GraphStageLogic

2016-08-26 Thread Gary Struthers
Sorry, my onTimer() doesn't fire. It looks like all I need to do is 1. use 
TimerGraphStageLogic 2. call scheduleOnce 3. override onTimer. I am 
misusing Resume for retries but I've tried scheduleOnce in other places and 
it still doesn't fire. Here's an example, 

  override def createLogic(inheritedAttributes: Attributes): 
GraphStageLogic = {

new TimerGraphStageLogic(shape) {


  private def decider = inheritedAttributes.get[SupervisionStrategy].map
(_.decider).

  getOrElse(Supervision.stoppingDecider)


  var retries = 1

  var duration = 100

  

  def myHandler(): Unit = {

  try {

if(testException != null) throw testException

if(iter.hasNext) {

  push(out, iter.next())

}

  } catch {

case NonFatal(e) => decider(e) match {

  case Supervision.Stop => {

failStage(e)

  }

  case Supervision.Resume => {

if(retries > 0) {

  logger.debug("before scheduleOnce retries {} duration {}", 
retries, duration)

  scheduleOnce(None, FiniteDuration(duration, MILLISECONDS))

} else {

  failStage(e) // too many retries

}

  }

}

  }

  }

  setHandler(out, new OutHandler {

override def onPull(): Unit = {

  myHandler()

}

  })


  override protected def onTimer(timerKey: Any): Unit = {

retries -= 1

duration *= 2

myHandler()

  }

} 

  }

-- 
>>  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] Delay within GraphStageLogic

2016-08-27 Thread Gary Struthers

Thanks, It fires now. This was a MockSource just for working out how to do 
error handling. The problem was the tests completed before the timer fired.

Gary

On Saturday, August 27, 2016 at 12:23:59 AM UTC-7, drewhk wrote:
>
>
>
>>
> Is this a Source? You omitted the shape... Anyway, it might be that your 
> stage is shut down earlier than the timer for some reason (for example 
> downstream cancelled). Override postStop() and print something there to see.
>
>
> -Endre
>
>>
>>
>

-- 
>>  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] [ANN] dendrites, library for Reactive streaming Microservices, CQRS, Event Sourcing, Event Logging, etc.

2017-08-02 Thread Gary Struthers
Inspired by Jonas Bonér's *Reactive Microservices Architecture* but for 
Akka Streams with Kafka, Avro, Cassandra, Akka HTTP, Algebird, & Actors 
with Typesafe Config and Logging.

Custom stream stages post-process calls that return errors or throw 
exceptions, some use Akka Streams Supervision. Queueing stages use 
backpressure to push a specified number of elements.  Akka Streams built-in 
stages are a nice use of partially applied functions and currying: apply 
some arguments while initializing streams, apply another as a stage input. 

Users can start with examples and substitute their code and configurations. 
They can also use stream stages as templates for their custom ones.

This began as a scratchpad for learning these technologies. To my surprise, 
Akka and Scala kept me free to experiment and change directions without 
painting myself into a corner. It also kept me free to blur the line 
between generic and custom where more could be generic but almost all of it 
is easily replaced. 

Documentation: https://garyaiki.github.io/dendrites/
Readme setup and code https://github.com/garyaiki/dendrites

-- 
>>  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: How to deal with Future in a customized Sink?

2017-08-05 Thread Gary Struthers


GraphStageLogic has getAsyncCallback. You define its handler method which 
returns an AsyncCallback. Then call AsyncCallback.invoke This is needed to 
re-enter the GraphStage whenever you return a Future in a custom stage.


scalaRSF.onComplete {

  case Success(rs) => {

val successCallback = getAsyncCallback{

  (_: Unit) => {

if(mustFinish) completeStage() else pull(in)

waitForHandler = false

  }

}

successCallback.invoke(rs)

      }

Gary Struthers

https://garyaiki.github.io/dendrites/

-- 
>>>>>>>>>>  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 Client Unmarshalling - different success and error responses

2017-08-22 Thread Gary Struthers

>
> I use Either but I unmarshal all text to Left and JSON to Right


def mapPlain(entity: HttpEntity): Future[Left[String, Nothing]] = {
  Unmarshal(entity).to[String].map(Left(_))
}

def mapChecking(entity: HttpEntity): Future[Right[String, AnyRef]] = {
  Unmarshal(entity).to[CheckingAccountBalances[BigDecimal]].map(Right(_))
} 

  def typedResponse(mapLeft: (HttpEntity) => Future[Left[String, Nothing]],
mapRight: (HttpEntity) => Future[Right[String, AnyRef]])(response: 
HttpResponse)
(implicit ec: ExecutionContext, logger: LoggingAdapter, materializer: 
Materializer):
Future[Either[String, AnyRef]] = {
  response.status match {
case OK => {
  val st = response.entity.contentType.mediaType.subType
  st match {
case "json"  => mapRight(response.entity)
case "plain" => mapLeft(response.entity)
  }
}
case BadRequest => Future.successful(Left(s"FAIL bad 
request:${response.status}"))
case _ => Unmarshal(response.entity).to[String].flatMap { entity =>
  val error = s"FAIL ${response.status} $entity"
  logger.error(error)
  Unmarshal(error).to[String].map(Left(_))
}
  }
  }

Gary
https://garyaiki.github.io/dendrites/HttpJson.html

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