Elegantn dataflow pomoc TPL Dataflow Is The Best
Elegantní dataflow pomocí TPL Dataflow Is The Best Library You're Not Using http: //blog. i 3 arnon. com/2016/05/23/tpl-dataflow
Motivation • lightweight actor library on top of TPL • messages passed from a producer to a consumer • consists of built-in blocks used for composing your dataflow • you don’t have to care about synchronization • no lock, Manual/Auto. Reset. Event etc • single responsibility • reusability – blocks might appear in multiple dataflows • parallel out of the box © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
How to get started • nuget • System. Threading. Tasks. Dataflow • DO NOT USE Microsoft. Tpl. Dataflow nuget • Git. Hub: • dotnet/corefx/tree/master/src/System. Threading. Tasks. Dataflow • used to be part of. NET Framework till 4. 5 © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Contents • 9 default data blocks • execution – Action. Block, Transform. Many. Block • buffering – Buffer. Block, Broadcast. Block, Write. Once. Block • grouping – Batch. Block, Join. Block, Batched. Join. Block • Solar. Winds • Expiring. Batch. Block – Batch. Block + Timer © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Creating a dataflow – i. e. linking blocks together • ISource. Block<T>. Link. To(ITarget. Block<T>) • source. Link. To(target, options, criteria) • options • append (default: true) • whether a new link is appended or set as first • propagation (default: false) • criteria • disposable © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Block options • Max. Degree. Of. Parallelism (default: 1) • Ensure. Ordered (default: true) • Bounded. Capacity (default: max) • max number of messages that a block might hold • if reached, block rejects messages © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
DEMO source: https: //new. siemens. com/global/en/markets/oil-gas/midstream/pipelines. html © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Additional topics to cover • completion • cancellation support • encapsulation • task schedulers © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Recommendations • use read-only or immutable types for data being passed around • nuget System. Collections. Immutable • handle exceptions properly • use Rx for async errors - https: //github. com/dotnet/reactive • use functional Either<TResult, TException> • https: //github. com/Target. Process/Tp. Core. Functional#either-type • consider Akka. net in cross-computer scenarios • https: //www. youtube. com/watch? v=6 jh 6 ve. NLHtk © 2018 Solar. Winds Worldwide, LLC. All rights reserved.
Required last page sample The Solar. Winds, Solar. Winds & Design, Orion, and THWACK trademarks are the exclusive property of Solar. Winds Worldwide, LLC or its affiliates, are registered with the U. S. Patent and Trademark Office, and may be registered or pending registration in other countries. All other Solar. Winds trademarks, service marks, and logos may be common law marks or are registered or pending registration. All other trademarks mentioned herein are used for identification purposes only and are trademarks of (and may be registered trademarks) of their respective companies.
- Slides: 10