コード例 #1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            kclProcess = KclProcess.Create(new DataMessageProcessor());
            kclProcess.Run();

            return(Task.CompletedTask);
        }
コード例 #2
0
 /// <summary>
 /// This method handle the process being launched. It will determine if the launch is to the process a stream or is a normal launch and perform the appropriate action
 /// </summary>
 /// <param name="args">The args the program has been launched with</param>
 /// <param name="streamToProcessorFactoryMapping">A dictionary of StreamName to Funcs that create stream processors.</param>
 /// <param name="fallbackMain">If this is not a stream processing launch, this is the fallback Main method that will be called to load the process normally</param>
 /// <exception cref="ArgumentException">If the stream that we're being asked to process is not a key in streamToProcessorFactoryMapping parameter</exception>
 public static void ProcessLaunch(string[] args, Dictionary <string, Func <IShardRecordProcessor> > streamToProcessorFactoryMapping, Action <string[]> fallbackMain)
 {
     //Parse the command line argument and see if we are being launched properly or as a consumer
     CommandLine.Parser.Default.ParseArguments <ProcessLaunchOptions>(args)
     .WithParsed <ProcessLaunchOptions>(opts =>
     {
         //this means we are a consumer with a stream
         if (!streamToProcessorFactoryMapping.ContainsKey(opts.StreamName))
         {
             //we havent been told what to run for this stream
             throw new ArgumentException($"Dont have a processor for this stream: {opts.StreamName}");
         }
         else
         {
             //Run the factory func for the recordProcessor and create a process with it.
             var recordProcessor = streamToProcessorFactoryMapping[opts.StreamName]();
             var process         = KclProcess.Create(recordProcessor);
             process.Run();
         }
     }
                                        )
     .WithNotParsed <ProcessLaunchOptions>((errs) =>
     {
         fallbackMain(args);
     }
                                           );
 }
コード例 #3
0
 /// <summary>
 /// This method creates a KclProcess and starts running an SampleRecordProcessor instance.
 /// </summary>
 public static void Main(string[] args)
 {
     try
     {
         KclProcess.Create(new SampleRecordProcessor()).Run();
     }
     catch (Exception e) {
         Console.Error.WriteLine("ERROR: " + e);
     }
 }