/// <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); }
/// <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);
/// <summary> /// TBD /// </summary> /// <param name="task">TBD</param> public TaskSource(Task <T> task) { ReactiveStreamsCompliance.RequireNonNullElement(task); _task = task; Shape = new SourceShape <T>(Outlet); }
/// <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); }
/// <summary> /// TBD /// </summary> /// <param name="writeTimeout">TBD</param> public OutputStreamSourceStage(TimeSpan writeTimeout) { _writeTimeout = writeTimeout; Shape = new SourceShape <ByteString>(_out); }
/// <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); }
protected override SourceModule <T, TestPublisher.Probe <T> > NewInstance(SourceShape <T> shape) { return(new ProbeSource <T>(_testKit, _attributes, shape)); }
/// <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); }
/// <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})"; }
/// <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);
/// <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; }
/// <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);
/// <summary> /// TBD /// </summary> /// <param name="attributes">TBD</param> /// <param name="shape">TBD</param> public MaybeSource(Attributes attributes, SourceShape <TOut> shape) : base(shape) { Attributes = attributes; }
/// <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);
/// <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);
/// <inheritdoc/> private bool Equals(SourceShape <TOut> other) => Outlet.Equals(other.Outlet);
/// <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);
public ProbeSource(TestKitBase testKit, Attributes attributes, SourceShape <T> shape) : base(shape) { _testKit = testKit; _attributes = attributes; }
/// <summary> /// TBD /// </summary> /// <param name="shape">TBD</param> protected SourceModule(SourceShape <TOut> shape) { _shape = shape; }
/// <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)); }
// 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);
public ChannelReaderSource(ChannelReader <T> reader) { _reader = reader; Outlet = new Outlet <T>("channelReader.out"); Shape = new SourceShape <T>(Outlet); }
public EmptySource() { Shape = new SourceShape <TOut>(Out); }
public AttibutesSourceStage() { Shape = new SourceShape <Attributes>(Out); }
/// <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); }
/// <summary> /// TBD /// </summary> /// <param name="element">TBD</param> public SingleSource(T element) { ReactiveStreamsCompliance.RequireNonNullElement(element); _element = element; Shape = new SourceShape <T>(Outlet); }
/// <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); }
/// <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; }
/// <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); }
private TestSourceStage(GraphStageWithMaterializedValue <SourceShape <T>, TMat> stageUnderTest, TestProbe probe) { _stageUnderTest = stageUnderTest; _probe = probe; Shape = new SourceShape <T>(_out); }
/// <summary> /// TBD /// </summary> /// <param name="attributes">TBD</param> /// <param name="shape">TBD</param> public SubscriberSource(Attributes attributes, SourceShape <TOut> shape) : base(shape) { Attributes = attributes; }