Exemplo n.º 1
0
 /// <summary>
 /// Creates a <see cref="Source{TOut,TMat}"/> from an <see cref="Stream"/> created by the given function.
 /// Emitted elements are <paramref name="chunkSize"/> sized <see cref="ByteString"/> elements,
 /// except the final element, which will be up to <paramref name="chunkSize"/> in size.
 /// 
 /// 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"/>.
 /// 
 /// It materializes a <see cref="Task{TResult}"/> of <see cref="IOResult"/> containing the number of bytes read from the source file upon completion,
 /// and a possible exception if IO operation was not completed successfully.
 /// 
 /// The created <see cref="Stream"/> will be closed when the <see cref="Source{TOut,TMat}"/> is cancelled.
 /// </summary>
 /// <param name="createInputStream">A function which creates the <see cref="Stream"/> to read from</param>
 /// <param name="chunkSize">The size of each read operation, defaults to 8192</param>
 public static Source<ByteString, Task<IOResult>> FromInputStream(Func<Stream> createInputStream, int chunkSize = 8192)
 {
     var shape = new SourceShape<ByteString>(new Outlet<ByteString>("InputStreamSource"));
     var streamSource = new InputStreamSource(createInputStream, chunkSize, DefaultAttributes.InputStreamSource,
         shape);
     return new Source<ByteString, Task<IOResult>>(streamSource);
 }
Exemplo n.º 2
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <ByteString, Task <IOResult> > NewInstance(SourceShape <ByteString> shape)
 => new InputStreamSource(_createInputStream, _chunkSize, Attributes, shape);
Exemplo n.º 3
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="task">TBD</param>
 public TaskSource(Task <T> task)
 {
     ReactiveStreamsCompliance.RequireNonNullElement(task);
     _task = task;
     Shape = new SourceShape <T>(Outlet);
 }
Exemplo n.º 4
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="computation">TBD</param>
 /// <param name="outlet">TBD</param>
 public MaterializedValueSource(StreamLayout.IMaterializedValueNode computation, Outlet <T> outlet)
 {
     Computation = computation;
     Outlet      = outlet;
     Shape       = new SourceShape <T>(Outlet);
 }
Exemplo n.º 5
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="writeTimeout">TBD</param>
 public OutputStreamSourceStage(TimeSpan writeTimeout)
 {
     _writeTimeout = writeTimeout;
     Shape         = new SourceShape <ByteString>(_out);
 }
Exemplo n.º 6
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <typeparam name="TIn">TBD</typeparam>
        /// <typeparam name="TOut">TBD</typeparam>
        /// <typeparam name="TMat">TBD</typeparam>
        /// <param name="ops">TBD</param>
        /// <param name="source">TBD</param>
        /// <returns>TBD</returns>
        public static GraphDsl.Builder <TMat> From <TIn, TOut, TMat>(this GraphDsl.ReverseOps <TIn, TMat> ops, SourceShape <TOut> source)
            where TIn : TOut
        {
            var b = ops.Builder;

            b.AddEdge(source.Outlet, ops.In);
            return(b);
        }
Exemplo n.º 7
0
 protected override SourceModule <T, TestPublisher.Probe <T> > NewInstance(SourceShape <T> shape)
 {
     return(new ProbeSource <T>(_testKit, _attributes, shape));
 }
Exemplo n.º 8
0
 /// <summary>
 /// Create a new instance of the <see cref="EventHubSource"/>
 /// </summary>
 /// <param name="createCheckpointOnClose">Creates a checkpoint when the processor is closed if set to true</param>
 /// <param name="createCheckpointForEveryBatch">Creates a checkpoint for every batch of messages that are received from the EventHub, if set to true</param>
 public EventHubSource(bool createCheckpointOnClose = true, bool createCheckpointForEveryBatch = false)
 {
     _createCheckpointOnClose       = createCheckpointOnClose;
     _createCheckpointForEveryBatch = createCheckpointForEveryBatch;
     Shape = new SourceShape <Tuple <PartitionContext, EventData> >(Out);
 }
Exemplo n.º 9
0
        /// <summary>
        /// TBD
        /// </summary>
        /// <param name="bufferSize">TBD</param>
        /// <param name="overflowStrategy">TBD</param>
        /// <param name="attributes">TBD</param>
        /// <param name="shape">TBD</param>
        public ActorRefSource(int bufferSize, OverflowStrategy overflowStrategy, Attributes attributes, SourceShape <TOut> shape) : base(shape)
        {
            _bufferSize       = bufferSize;
            _overflowStrategy = overflowStrategy;
            Attributes        = attributes;

            Label = $"ActorRefSource({bufferSize}, {overflowStrategy})";
        }
Exemplo n.º 10
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <TOut, IActorRef> NewInstance(SourceShape <TOut> shape)
 => new ActorPublisherSource <TOut>(_props, Attributes, shape);
Exemplo n.º 11
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="props">TBD</param>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public ActorPublisherSource(Props props, Attributes attributes, SourceShape <TOut> shape) : base(shape)
 {
     _props     = props;
     Attributes = attributes;
 }
Exemplo n.º 12
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <TOut, TaskCompletionSource <TOut> > NewInstance(SourceShape <TOut> shape)
 => new MaybeSource <TOut>(Attributes, shape);
Exemplo n.º 13
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public MaybeSource(Attributes attributes, SourceShape <TOut> shape) : base(shape)
 {
     Attributes = attributes;
 }
Exemplo n.º 14
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <TOut, NotUsed> NewInstance(SourceShape <TOut> shape)
 => new PublisherSource <TOut>(_publisher, Attributes, shape);
Exemplo n.º 15
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <TOut, ISubscriber <TOut> > NewInstance(SourceShape <TOut> shape)
 => new SubscriberSource <TOut>(Attributes, shape);
Exemplo n.º 16
0
 /// <inheritdoc/>
 private bool Equals(SourceShape <TOut> other) => Outlet.Equals(other.Outlet);
Exemplo n.º 17
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected override SourceModule <TOut, IActorRef> NewInstance(SourceShape <TOut> shape)
 => new ActorRefSource <TOut>(_bufferSize, _overflowStrategy, Attributes, shape);
Exemplo n.º 18
0
 public ProbeSource(TestKitBase testKit, Attributes attributes, SourceShape <T> shape) : base(shape)
 {
     _testKit    = testKit;
     _attributes = attributes;
 }
Exemplo n.º 19
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 protected SourceModule(SourceShape <TOut> shape)
 {
     _shape = shape;
 }
Exemplo n.º 20
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <typeparam name="TOut">TBD</typeparam>
 /// <param name="source">TBD</param>
 /// <returns>TBD</returns>
 public ForwardOps <TOut, T> From <TOut>(SourceShape <TOut> source)
 {
     return(new ForwardOps <TOut, T>(this, source.Outlet));
 }
Exemplo n.º 21
0
 // This is okay since the only caller of this method is right below.
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="shape">TBD</param>
 /// <returns>TBD</returns>
 protected abstract SourceModule <TOut, TMat> NewInstance(SourceShape <TOut> shape);
Exemplo n.º 22
0
 public ChannelReaderSource(ChannelReader <T> reader)
 {
     _reader = reader;
     Outlet  = new Outlet <T>("channelReader.out");
     Shape   = new SourceShape <T>(Outlet);
 }
Exemplo n.º 23
0
 public EmptySource()
 {
     Shape = new SourceShape <TOut>(Out);
 }
Exemplo n.º 24
0
 public AttibutesSourceStage()
 {
     Shape = new SourceShape <Attributes>(Out);
 }
Exemplo n.º 25
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="maxBuffer">TBD</param>
 /// <param name="overflowStrategy">TBD</param>
 public QueueSource(int maxBuffer, OverflowStrategy overflowStrategy)
 {
     _maxBuffer        = maxBuffer;
     _overflowStrategy = overflowStrategy;
     Shape             = new SourceShape <TOut>(Out);
 }
Exemplo n.º 26
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="element">TBD</param>
 public SingleSource(T element)
 {
     ReactiveStreamsCompliance.RequireNonNullElement(element);
     _element = element;
     Shape    = new SourceShape <T>(Outlet);
 }
Exemplo n.º 27
0
 /// <summary>
 /// Creates a new <see cref="LazySource{TOut,TMat}"/>
 /// </summary>
 /// <param name="sourceFactory">The factory that generates the source when needed</param>
 public LazySource(Func <Source <TOut, TMat> > sourceFactory)
 {
     _sourceFactory = sourceFactory;
     Shape          = new SourceShape <TOut>(Out);
 }
Exemplo n.º 28
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="createInputStream">TBD</param>
 /// <param name="chunkSize">TBD</param>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public InputStreamSource(Func <Stream> createInputStream, int chunkSize, Attributes attributes, SourceShape <ByteString> shape) : base(shape)
 {
     _createInputStream = createInputStream;
     _chunkSize         = chunkSize;
     Attributes         = attributes;
 }
Exemplo n.º 29
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="state">TBD</param>
 /// <param name="unfoldFunc">TBD</param>
 public Unfold(TState state, Func <TState, Tuple <TState, TElement> > unfoldFunc)
 {
     State      = state;
     UnfoldFunc = unfoldFunc;
     Shape      = new SourceShape <TElement>(Out);
 }
Exemplo n.º 30
0
 private TestSourceStage(GraphStageWithMaterializedValue <SourceShape <T>, TMat> stageUnderTest, TestProbe probe)
 {
     _stageUnderTest = stageUnderTest;
     _probe          = probe;
     Shape           = new SourceShape <T>(_out);
 }
Exemplo n.º 31
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="attributes">TBD</param>
 /// <param name="shape">TBD</param>
 public SubscriberSource(Attributes attributes, SourceShape <TOut> shape) : base(shape)
 {
     Attributes = attributes;
 }