I am reading the documentation of Alpakka Cassandra here
It makes it very easy to use Cassandra as a source and a sink. but what about flow usage.
By flow usage I mean is that I am not using Cassandra as a source or a sink. but to Lookup Data.
is that possible using Alpakka? or should I have to write the Cassandra jdbc code in a flow myself?
1) Sink. If you check Alpakka's source code, you'll find that the Sink is constructed as follows
Flow[T]
.mapAsyncUnordered(parallelism)(t ⇒ session.executeAsync(statementBinder(t, statement)).asScala())
.toMat(Sink.ignore)(Keep.right)
if you only need a passing flow, you can always trim out the Sink.ignore
part, and you'll have
Flow[T]
.mapAsyncUnordered(parallelism)(t ⇒ session.executeAsync(statementBinder(t, statement)).asScala())
You will only need to expose the Guava futures converter, which is currently package private in Alpakka.
2) Source. You can always obtain a Flow
from a Source
by doing .flatMapConcat(x => CassandraSource(...)
)