Example #1
0
 /// <summary>
 /// Creates a Sink which writes incoming <see cref="ByteString"/>s to an <see cref="Stream"/> created by the given function.
 /// 
 /// Materializes a <see cref="Task{TResult}"/> of <see cref="IOResult"/> that will be completed with the size of the file (in bytes) at the streams completion,
 /// and a possible exception if IO operation was not completed successfully.
 /// 
 /// You can configure the default dispatcher for this Source by changing the "akka.stream.blocking-io-dispatcher" or
 /// set it for a given Source by using <see cref="ActorAttributes.CreateDispatcher"/>. 
 /// If <paramref name="autoFlush"/> is true the OutputStream will be flushed whenever a byte array is written, defaults to false.
 /// 
 /// The <see cref="Stream"/> will be closed when the stream flowing into this <see cref="Sink{TIn,TMat}"/> is completed. The <see cref="Sink{TIn,TMat}"/>
 /// will cancel the stream when the <see cref="Stream"/> is no longer writable.
 /// </summary>
 /// <param name="createOutputStream">A function which creates the <see cref="Stream"/> to write to</param>
 /// <param name="autoFlush">If set to true the <see cref="Stream"/> will be flushed whenever a byte array is written, default is false</param>
 public static Sink<ByteString, Task<IOResult>> FromOutputStream(Func<Stream> createOutputStream, bool autoFlush = false)
 {
     var shape = new SinkShape<ByteString>(new Inlet<ByteString>("OutputStreamSink"));
     var streamSink = new OutputStreamSink(createOutputStream, DefaultAttributes.OutputStreamSink, shape,
         autoFlush);
     return new Sink<ByteString, Task<IOResult>>(streamSink);
 }
Example #2
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="ref">TBD</param>
 /// <param name="onCompleteMessage">TBD</param>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public ActorRefSink(IActorRef @ref, object onCompleteMessage, Attributes attributes, SinkShape <TIn> shape)
     : base(shape)
 {
     _ref = @ref;
     _onCompleteMessage = onCompleteMessage;
     _attributes        = attributes;
 }
Example #3
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="props">TBD</param>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public ActorSubscriberSink(Props props, Attributes attributes, SinkShape <TIn> shape)
     : base(shape)
 {
     _props      = props;
     _attributes = attributes;
 }
Example #4
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public CancelSink(Attributes attributes, SinkShape <T> shape)
     : base(shape)
 {
     Attributes = attributes;
 }
Example #5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="subscriber">TBD</param>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public SubscriberSink(ISubscriber <TIn> subscriber, Attributes attributes, SinkShape <TIn> shape) : base(shape)
 {
     Attributes  = attributes;
     _subscriber = subscriber;
 }
Example #6
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public FanoutPublisherSink(Attributes attributes, SinkShape <TIn> shape) : base(shape)
 {
     Attributes = attributes;
 }
Example #7
0
 protected override SinkModule <ByteString, Task <IOResult> > NewInstance(SinkShape <ByteString> shape)
 => new OutputStreamSink(_createOutput, Attributes, shape, _autoFlush);
Example #8
0
 protected override SinkModule <ByteString, Task <IOResult> > NewInstance(SinkShape <ByteString> shape)
 => new FileSink(_f, _fileMode, Attributes, shape);
Example #9
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <TIn, IPublisher <TIn> > NewInstance(SinkShape <TIn> shape)
 => new FanoutPublisherSink <TIn, TStreamBuffer>(Attributes, shape, _onTerminated);
Example #10
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 /// <param name="onTerminated">TBD</param>
 public FanoutPublisherSink(Attributes attributes, SinkShape <TIn> shape, Action onTerminated = null) : base(shape)
 {
     Attributes    = attributes;
     _onTerminated = onTerminated;
 }
Example #11
0
 public CompletionLatch()
 {
     Shape = new SinkShape <MutableElement>(In);
 }
Example #12
0
        public static GraphDsl.Builder <TMat> To <TIn, TOut, TMat>(this GraphDsl.ForwardOps <TOut, TMat> ops, SinkShape <TIn> sink)
            where TIn : TOut
        {
            var b = ops.Builder;

            b.AddEdge(ops.Out, sink.Inlet);
            return(b);
        }
Example #13
0
 public ReverseOps <TIn, T> To <TIn>(SinkShape <TIn> sink)
 {
     return(new ReverseOps <TIn, T>(this, sink.Inlet));
 }
Example #14
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="readTimeout">TBD</param>
 public InputStreamSinkStage(TimeSpan readTimeout)
 {
     _readTimeout = readTimeout;
     Shape        = new SinkShape <ByteString>(_in);
 }
Example #15
0
 protected override SinkModule <T, TestSubscriber.Probe <T> > NewInstance(SinkShape <T> shape)
 {
     return(new ProbeSink <T>(_testKit, _attributes, shape));
 }
Example #16
0
 /// <summary>
 /// TBD
 /// </summary>
 public QueueSink()
 {
     Shape = new SinkShape <T>(In);
 }
Example #17
0
 private TestSinkStage(GraphStageWithMaterializedValue <SinkShape <T>, TMat> stageUnderTest, TestProbe probe)
 {
     _stageUnderTest = stageUnderTest;
     _probe          = probe;
     Shape           = new SinkShape <T>(_in);
 }
Example #18
0
 public OutputStreamSink(Func <Stream> createOutput, Attributes attributes, SinkShape <ByteString> shape, bool autoFlush) : base(shape)
 {
     _createOutput = createOutput;
     Attributes    = attributes;
     _autoFlush    = autoFlush;
 }
Example #19
0
 public IgnoreSink()
 {
     Shape = new SinkShape <T>(Inlet);
 }
Example #20
0
 public SumTestStage(IActorRef probe)
 {
     _probe = probe;
     Shape  = new SinkShape <int>(_inlet);
 }
Example #21
0
 public ObservableSinkStage()
 {
     Shape = new SinkShape <T>(Inlet);
 }
Example #22
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <TIn, IPublisher <TIn> > NewInstance(SinkShape <TIn> shape)
 => new FanoutPublisherSink <TIn>(Attributes, shape);
Example #23
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <TIn, NotUsed> NewInstance(SinkShape <TIn> shape)
 => new ActorRefSink <TIn>(_ref, _onCompleteMessage, _attributes, shape);
Example #24
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <TIn, NotUsed> NewInstance(SinkShape <TIn> shape)
 => new SubscriberSink <TIn>(_subscriber, Attributes, shape);
Example #25
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 protected SinkModule(SinkShape <TIn> shape)
 {
     _shape = shape;
 }
Example #26
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <T, NotUsed> NewInstance(SinkShape <T> shape)
 => new CancelSink <T>(Attributes, shape);
Example #27
0
 /// <summary>
 /// TBD
 /// </summary>
 public FirstOrDefaultStage()
 {
     Shape = new SinkShape <T>(In);
 }
Example #28
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SinkModule <TIn, IActorRef> NewInstance(SinkShape <TIn> shape)
 => new ActorSubscriberSink <TIn>(_props, _attributes, shape);
Example #29
0
 /// <summary>
 /// TBD
 /// </summary>
 public SeqStage()
 {
     Shape = new SinkShape <T>(In);
 }
Example #30
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected abstract SinkModule <TIn, TMat> NewInstance(SinkShape <TIn> shape);
Example #31
0
 public ProbeSink(TestKitBase testKit, Attributes attributes, SinkShape <T> shape) : base(shape)
 {
     _testKit    = testKit;
     _attributes = attributes;
 }