コード例 #1
0
        public BootstrapperBase(
            JobsOptions options,
            IStorage storage,
            IProcessingServer server,
            IApplicationLifetime appLifetime,
            IServiceProvider provider)
        {
            Options      = options;
            Storage      = storage;
            Server       = server;
            _appLifetime = appLifetime;
            Provider     = provider;

            _cts             = new CancellationTokenSource();
            _ctsRegistration = appLifetime.ApplicationStopping.Register(() =>
            {
                _cts.Cancel();
                try
                {
                    _bootstrappingTask?.Wait();
                }
                catch (OperationCanceledException)
                {
                }
            });
        }
コード例 #2
0
        /// <summary>
        /// creates or updates a pipeline based on the registrationcontext
        /// </summary>
        /// <param name="server"></param>
        /// <param name="pipelineId"></param>
        /// <param name="registration"></param>
        public static void SetupPipeline(this IProcessingServer server, string pipelineId, Action <PipelineRegistration> registration)
        {
            //TODO: add the possibility to delay the setup
            var context = new PipelineRegistration(pipelineId, server);

            registration(context);
        }
コード例 #3
0
ファイル: PipelineBuilder.cs プロジェクト: WickedFlame/Gaucho
        /// <summary>
        /// Build the pipeline based on the configuration
        /// </summary>
        /// <param name="server"></param>
        /// <param name="config"></param>
        public void BuildPipeline(IProcessingServer server, PipelineConfiguration config)
        {
            _logger.Write($"Setup Pipeline:{config}", Category.Log, LogLevel.Debug, "PipelineBuilder");

            server.SetupPipeline(config.Id, s =>
            {
                var rootCtx = GlobalConfiguration.Configuration.Resolve <IActivationContext>();

                s.Register(() =>
                {
                    var pipeline = new EventPipeline();
                    foreach (var node in config.OutputHandlers)
                    {
                        var ctx           = rootCtx.ChildContext();
                        var outputHandler = BuildHandler <IOutputHandler>(ctx, node);

                        var converter = node.BuildDataFilter();
                        if (converter.Filters.Any(f => f.FilterType == Filters.FilterType.Property))
                        {
                            outputHandler = new DataFilterDecorator(converter, outputHandler);
                        }

                        pipeline.AddHandler(outputHandler);
                    }

                    return(pipeline);
                }, config.Options);

                var inputHandler = BuildHandler <IInputHandler>(rootCtx.ChildContext(), config.InputHandler);
                s.Register(inputHandler);
            });
        }
コード例 #4
0
        /// <summary>
        /// creates or updates a pipeline based on the given configuration
        /// </summary>
        /// <param name="server"></param>
        /// <param name="pipelineId"></param>
        /// <param name="config"></param>
        /// <returns></returns>
        public static IProcessingServer SetupPipeline(this IProcessingServer server, string pipelineId, PipelineConfiguration config)
        {
            var builder = new PipelineBuilder();

            builder.BuildPipeline(server, config);

            return(server);
        }
コード例 #5
0
ファイル: BootstrapperBase.cs プロジェクト: 5118234/Angel-CMS
 public BootstrapperBase(
     JobsOptions options,
     IStorage storage,
     IProcessingServer server)
 {
     Options = options;
     Storage = storage;
     Server  = server;
 }
コード例 #6
0
 public SqlServerBootstrapper(
     JobsOptions options,
     IStorage storage,
     IProcessingServer server,
     IApplicationLifetime appLifetime)
     : base(options, storage, server)
 {
     _appLifetime = appLifetime;
 }
コード例 #7
0
 public JobsManager(
     JobsOptions options,
     IStorage storage,
     IProcessingServer server)
 {
     _options = options;
     _storage = storage;
     _server  = server;
 }
コード例 #8
0
 public SqlServerBootstrapper(
     JobsOptions options,
     IStorage storage,
     IProcessingServer server,
     IApplicationLifetime appLifetime,
     IServiceProvider provider)
     : base(options, storage, server, appLifetime, provider)
 {
 }
コード例 #9
0
 /// <summary>
 /// 初始化一个<see cref="TestController"/>类型的实例
 /// </summary>
 public TestController(ITestService testService
                       , IProcessingServer processingServer
                       , IMessageEventBus messageEventBus
                       , IAdminUnitOfWork unitOfWork)
 {
     TestService      = testService;
     ProcessingServer = processingServer;
     MessageEventBus  = messageEventBus;
     UnitOfWork       = unitOfWork;
 }
コード例 #10
0
 public JobsManager(
     JobsOptions options,
     IStorage storage,
     IStateChanger stateChanger,
     IProcessingServer server,
     IStorageConnection connection)
 {
     _options      = options;
     _storage      = storage;
     _stateChanger = stateChanger;
     _server       = server;
     _connection   = connection;
 }
コード例 #11
0
        public void Initialize(IProcessingServer server)
        {
            _server      = server;
            _broadcaster = new Broadcaster(ProcessorMode.Background);

            var interval = _arguments.GetValue <int>("Interval");

            if (interval == 0)
            {
                interval = 10;
            }

            // delay start to end initializing
            _broadcaster.Schedule(() => _broadcaster.Recurring(Process, TimeSpan.FromSeconds(interval)), TimeSpan.FromSeconds(10));
        }
コード例 #12
0
 /// <summary>
 /// 初始化一个<see cref="TestController"/>类型的实例
 /// </summary>
 public TestController(ITestService testService
                       , IProcessingServer processingServer
                       , IMessageEventBus messageEventBus
                       , IAdminUnitOfWork unitOfWork
                       , IExceptionNotifier exceptionNotifier
                       , ILogger <TestController> logger
                       , ILog <TestController> otherLog)
 {
     TestService       = testService;
     ProcessingServer  = processingServer;
     MessageEventBus   = messageEventBus;
     UnitOfWork        = unitOfWork;
     ExceptionNotifier = exceptionNotifier;
     Logger            = logger;
     OtherLog          = otherLog;
 }
コード例 #13
0
 /// <summary>
 /// Register an EventPipeline to the pipeline
 /// </summary>
 /// <param name="pipelineId"></param>
 /// <param name="factory"></param>
 public static void Register(this IProcessingServer server, string pipelineId, Func <EventPipeline> factory)
 => server.Register(pipelineId, factory, new PipelineOptions());
コード例 #14
0
 public void Initialize(IProcessingServer server)
 {
     Server = server;
 }
コード例 #15
0
 /// <summary>
 /// Creates a new instance of the PipelineRegistration
 /// </summary>
 /// <param name="pipelineId"></param>
 /// <param name="server"></param>
 internal PipelineRegistration(string pipelineId, IProcessingServer server)
 {
     _pipelineId = pipelineId;
     _server     = server;
 }
コード例 #16
0
ファイル: PipelineMonitor.cs プロジェクト: WickedFlame/Gaucho
 /// <summary>
 /// Creates a new instance of the PipelineMonitor
 /// </summary>
 /// <param name="server"></param>
 public PipelineMonitor(IProcessingServer server)
 {
     _server = server;
 }
コード例 #17
0
ファイル: EventDispatcher.cs プロジェクト: WickedFlame/Gaucho
 /// <summary>
 /// Creates a new instance of the EventDispatcher
 /// </summary>
 /// <param name="server">The <see cref="IProcessingServer"/> that the events are dispatched to</param>
 public EventDispatcher(IProcessingServer server)
 {
     _server = server;
 }
コード例 #18
0
 public ValuesController(ICapPublisher publisher, IServiceProvider serviceProvider, IProcessingServer processingServer)
 {
     _publisher        = publisher;
     _serviceProvider  = serviceProvider;
     _processingServer = processingServer;
 }
コード例 #19
0
 private IEnumerable <IOutputHandler> GetOutputHandlers(IProcessingServer server, string pipelineId)
 {
     return(server.EventBusFactory.GetEventBus(pipelineId).PipelineFactory.Setup().Handlers);
 }
コード例 #20
0
        /// <summary>
        /// Add the dashbaord API
        /// </summary>
        /// <param name="services"></param>
        /// <param name="server"></param>
        /// <returns></returns>
        public static IServiceCollection AddGauchoServer(this IServiceCollection services, IProcessingServer server)
        {
            if (services == null)
            {
                throw new ArgumentNullException(nameof(services));
            }

            // ===== Configurable services =====

            //services.TryAddSingletonChecked(_ => JobStorage.Current);
            //services.TryAddSingletonChecked(_ => JobActivator.Current);
            services.TryAddSingletonChecked <IPipelineMonitor>(_ => new PipelineMonitor(server));
            services.TryAddSingletonChecked(_ => DashboardRoutes.Routes);

            return(services);
        }
コード例 #21
0
 public static IServiceCollection AddGauchoDashboard(this IServiceCollection services, IProcessingServer server)
 {
     return(AddGauchoServer(services, server));
 }