Esempio n. 1
0
 private static BidiFlow <int, long, ByteString, string, NotUsed> Bidi()
 {
     return
         (BidiFlow.FromFlows(
              Flow.Create <int>().Select(x => ((long)x) + 2).WithAttributes(Attributes.CreateName("top")),
              Flow.Create <ByteString>()
              .Select(x => x.ToString(Encoding.UTF8))
              .WithAttributes(Attributes.CreateName("bottom"))));
 }
Esempio n. 2
0
 private static BidiFlow <long, int, string, ByteString, NotUsed> Inverse()
 {
     return
         (BidiFlow.FromFlows(
              Flow.Create <long>().Select(x => ((int)x) + 2).WithAttributes(Attributes.CreateName("top")),
              Flow.Create <string>()
              .Select(ByteString.FromString)
              .WithAttributes(Attributes.CreateName("bottom"))));
 }
Esempio n. 3
0
        public static BidiFlow <ByteString, ByteString, ByteString, ByteString, NotUsed> Create(TimeSpan idleTimeout, EndPoint remoteAddress = null)
        {
            var connectionString = remoteAddress == null ? "" : $" on connection to [{remoteAddress}]";

            var idleException = new TcpIdleTimeoutException(
                $"TCP idle-timeout encountered{connectionString}, no bytes passed in the last {idleTimeout}",
                idleTimeout);

            var toNetTimeout = BidiFlow.FromFlows(
                Flow.Create <ByteString>().SelectError(e => e is TimeoutException ? idleException : e),
                Flow.Create <ByteString>());

            var fromNetTimeout = toNetTimeout.Reversed(); // now the bottom flow transforms the exception, the top one doesn't (since that one is "fromNet")

            return(fromNetTimeout.Atop(BidiFlow.BidirectionalIdleTimeout <ByteString, ByteString>(idleTimeout))
                   .Atop(toNetTimeout));
        }
Esempio n. 4
0
 public static BidiFlow <Emitted <T>, IPersistentRepresentation, Delivery <IPersistentRepresentation>, Delivery <Durable <T> >, NotUsed> Create(string persistenceId) =>
 BidiFlow.FromFlows(Encoder(persistenceId), Decoder);