Hello,
I am a newbie trying to understand Akka Streams.
Coming from regular socket programming I am trying to mimic a client connection and have the following runnable graph.
Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> flow = Tcp
.get(system).outgoingConnection("127.0.0.1", 6000);
Source<ByteString, NotUsed> clientSource = Source.single(ByteString
.fromString("XYZ"));
clientSource.via(flow).to(Sink.ignore()).run(mat);
This works fine when used with the samples in the doc, where the source is attached that has a list and there is a server listening and we run the source->flow->sink through a materializer.
But this is not a typical use case, typically one would attempt to connect to a server, and either it connects or fails. If connected send data that will be made available and if connection fails, have the ability to backoff.
Currently I don't know how to access the error when a server is not available and want to establish a connection before data is available.
Don't know how to prevent connections every time data is sent, I understand why it happens, but don't know how to reuse a materialized flow that has already connected.
What I am trying to get my head around is how does one run a graph without any source data and get a completable future that tells me if it succeeded or not.
Then I want to use the same connection to send data later using the source.
I have attempted with a runfold and that give me the akka TCP Exception when the server is not availble, but I simply want to forward the data from the source without manipulation.
Any pointers or snippets would be greatly appreciated. Yes I am not used to this paradigm of programming but trying to figure it out.
-chhil