public DataStreamSource <TOut> AddSource <TOut>(ISourceFunction <TOut> function, string sourceName, TypeInformation <TOut> typeInfo = default) { var isParallel = function is IParallelSourceFunction <TOut>; Clean(function); var sourceOperator = new StreamSource <TOut, ISourceFunction <TOut> >(function); return(new DataStreamSource <TOut>(this, typeInfo, sourceOperator, isParallel, sourceName)); }
public static void Run() { // create the environment to create streams and configure execution var env = StreamExecutionEnvironment.GetExecutionEnvironment(); env.EnableCheckpointing(2000); ISourceFunction <Event> source = default; var events = env.AddSource(source); var alerts = events // partition on the address to make sure equal addresses end up in the same state machine flatMap function .KeyBy(nameof(Event.SourceAddress)) // the function that evaluates the state machine over the sequence of events .FlatMap(new StateMachineMapper()); alerts.Print(); env.Execute("State machine job"); }