typesafehub / activator-akka-stream-scala Goto Github PK
View Code? Open in Web Editor NEWDemonstrate Akka streams in Scala
License: Other
Demonstrate Akka streams in Scala
License: Other
Was implemented in Java here typesafehub/activator-akka-stream-java8@c8e514c
We need to update this template to akka-stream 1.0-m4
As seen here: #36 (comment)
with the new GroupBy, it's harder to keep it streaming all the way (i.e. submited PR went the easy way of accumulating into a List, while we must do so into a stream)
I tried to simply change the dependency version, didn't work out of the box. I'm having some headache with 2.1.0 and this is the only full example out in the wild. Documentation provides just snippets.
I haven't used Scalariform before, but it seems like meaningful assumption that sbt compile
would not change the sources, from what's in the repo. Now it does.
sbt compile
$ git diff
diff --git a/src/main/scala/sample/stream/GroupLogFile.scala b/src/main/scala/sample/stream/GroupLogFile.scala
index d886c44..dcc7477 100644
--- a/src/main/scala/sample/stream/GroupLogFile.scala
+++ b/src/main/scala/sample/stream/GroupLogFile.scala
@@ -30,8 +30,8 @@ object GroupLogFile {
via(Framing.delimiter(ByteString(System.lineSeparator), maximumFrameLength = 512, allowTruncation = true)).
map(_.utf8String).
map {
- case line@LoglevelPattern(level) => (level, line)
- case line@other => ("OTHER", line)
+ case line @ LoglevelPattern(level) => (level, line)
+ case line @ other => ("OTHER", line)
}.
// group them by log level
groupBy(5, _._1).
It closes the file upon completion of the master stream, which has of course nothing to do with the completion of the individual groups writing (the master completes earlier). The proper solution is instead of using onComplete on the individual streams, just return the future, and call mapAsync(identity) on the master stream, and then register the onComplete(close()) call.
There's a reference in the tutorial to Transformer
and Flow, but in scaladsl2, Flow does not take Transformer. In scaladsl
, there's a reference to Flow.transform()
but it's not clear how that connects, and there's no Transformer
import.
https://github.com/typesafehub/activator-akka-stream-scala/blob/master/tutorial/index.html#L111
http://doc.akka.io/api/akka-stream-and-http-experimental/0.9/index.html#akka.stream.Transformer
=== wrong activator delete this, sorry ===
Most probably org.reactivestreams.api
was renamed org.reactivestreams
, this should also be done for the tutorial, e.g. on the first page in org.reactivestreams.api.Producer
.
I'm going to use the Akka Streams sample in our Helsinki Scala Club meetup. Unfortunately, one of the samples reads a resource using a build-time relative path. This only works in development, of course, and not in production. In fact, the current way is not using the file as a resource, at all. All of this might be misleading to Scala learners.
Unfortunately, I don't know how to fix this for real. Using a Stream instead of File changes the later iteration code.
Here is a code that is somewhere in between. Creates a File out of a resource. This is done pretty often, but is not ideal, or recommended. Better than the current way, though.
// Note: Resources should be read using '.getResourceAsStream'. While the code shows Akka Streams, it should not
// teach bad (nonfunctional, in production) manners. AKa240116
//
//val log: InputStream = getClass.getResourceAsStream("/logfile.txt")
// read lines from a log file
val logFile: File = new File(getClass.getResource("/logfile.txt").toURI)
at line 47 and 48 I have this error
value ~> is not a member of akka.stream.scaladsl.Source[Int, akka.NotUsed]
When I run WritePrimes.scala the numbers are appearing on the console faster than 1 number/second.
Also when I checked primes.txt there were always less numbers than in the console output.
Is there something I am missing?
The regex does not recognize the tags and places all lines in the OTHER bucket.
Obviously caused by the Windows eol not fully matching the line separator.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.