public static IDisposable DoWorkContiniously(IRxnManager <IRxn> rxnManage, IObservable <StartUnitTest[]> unitTestToRun, Action fireStyle) { return(unitTestToRun.Select(tests => { var stopFiringContiniously = rxnManage.CreateSubscription <CommandResult>() .Where(c => c.InResponseTo.Equals(tests[0].Id)) .Select(_ => -- iteration) .If(e => e <= 0, _ => { if (_notUpdating) { CurrentThreadScheduler.Instance.Run(() => { fireStyle(); }); } }) .Until(); fireStyle(); return stopFiringContiniously; }) .FinallyR(() => { "Continuous mode is stopping".LogDebug(); }) .Until()); }
public bfgWorkerRemoteOrchestrator(IRxnManager <IRxn> rxnManager, IAppStatusStore appCmds, IUpdateStorageClient appUpdates, IRxnProcessor <WorkerDiscovered <StartUnitTest, UnitTestResult> > workerPool, IClusterFanout <StartUnitTest, UnitTestResult> cluster, IRxnProcessor <WorkerDisconnected> workerPoolD) { _rxnManager = rxnManager; _appCmds = appCmds; _appUpdates = appUpdates; _workerPool = workerPool; _cluster = cluster; _workerPoolD = workerPoolD; }
public bfgWorkerRxnManagerBridge(IAppStatusStore appCmds, IRxnManager <IRxn> repsonseChannel, IUpdateStorageClient updates, IDictionary <string, string> info = null) { _repsonseChannel = repsonseChannel; _updates = updates; _appCmds = appCmds; if (info != null) { Info = info; } }
public bfgCluster(SystemStatusPublisher appStatus, IRxnManager <IRxn> rxnManager, IClusterFanout <StartUnitTest, UnitTestResult> fanoutStrategy) : base(fanoutStrategy) { _rxnManager = rxnManager; _fanoutStrategy = fanoutStrategy; appStatus.Process(new AppStatusInfoProviderEvent() { Info = () => new[] { new AppStatusInfo("Free Workers", $"{Workflow.Workers.Count - Workflow.Workers.Count(w => w.Value.Worker.IsBusy.Value())} / {Workflow.Workers.Count}") } }).Until(); }
public bfgWorker(string name, string route, string[] tags, IAppServiceRegistry registry, IAppServiceDiscovery services, IZipService zipService, IAppStatusServiceClient appStatus, IRxnManager <IRxn> rxnManager, IUpdateServiceClient updateService, IAppStatusCfg cfg, Func <ITestArena[]> arena) { _registry = registry; _services = services; _zipService = zipService; _appStatus = appStatus; _rxnManager = rxnManager; _updateService = updateService; _cfg = cfg; _arena = arena; Name = name; Route = route; Info.Add(bfgTagWorkflow.WorkerTag, tags.ToStringEach()); }
public static string DefaultReactorName = "default"; //i want to let users configure this, so no const public ReactorManager(IServiceCommandFactory cmdFactory, IRxnManager <IRxn> defaultReactorInputOutputStream, Func <string, Rxns.Interfaces.IReactor <IRxn> > reactorFactory, IRxnHistoryProvider eventHistory) { _rxnManager = defaultReactorInputOutputStream; _reactorFactory = reactorFactory; _eventHistory = eventHistory; //we want raw access to the eventManager, not via IrxnProcessor/IReactTo _rxnManager.CreateSubscription <StopReactor>().Do(r => StopReactor(r.Name)).Until().DisposedBy(this); _rxnManager.CreateSubscription <StartReactor>().Do(r => StartReactor(r.Name)).Until().DisposedBy(this); new DisposableAction(() => { OnWarning("Shutting down. This usually should not happen!"); Reactors.Values.ForEach(r => { r.Reactor.Dispose(); }); }).DisposedBy(this); }
/// <summary> /// Pairs this reactor with an rxn manager. The rxn manager is the parent in the relationship, /// anythign observed over its subscription is piped as input into the reactors world. The output /// /// </summary> /// <param name="rxnManager"></param> /// <param name="input"></param> /// <param name="output"></param> /// <returns></returns> public IDisposable Chain(IRxnManager <IRxn> rxnManager, IScheduler input = null, IScheduler output = null) { var @out = output == null ? Output : Output.ObserveOn(output); var @in = rxnManager.CreateSubscription <TEvent>(); @in = input == null ? @in : @in.ObserveOn(input); var inChannel = @in.Subscribe(e => Input.OnNext(e), OnError); var outChannel = @out.Subscribe(rxnManager.Publish, OnError); _molecules.Add(rxnManager); OnInformation("Chained to '{0}'", rxnManager.GetType().Name); return(new CompositeDisposable(inChannel, outChannel, new DisposableAction(() => { OnInformation("Unchained '{0}'", rxnManager.GetType().Name); _molecules.Remove(rxnManager); })) .DisposedBy(_resources)); }
public static string ClientId = bfgCfg.Detect().Id.Split('-').FirstOrDefault(); //get from cfg file if exists public bfgWorkerManager(bfgCluster workerCluster, IObservable <StartUnitTest[]> cfg, SystemStatusPublisher systemStatus, IResolveTypes resolver, IRxnManager <IRxn> eventManager, IAppStatusCfg appStatusCfg, IAppServiceRegistry appServiceRegistry, IZipService zipService, IAppStatusStore appCmds, IAppStatusServiceClient appStatus, IAppServiceDiscovery serviceDiscovery, IUpdateServiceClient appUpdates) { _workerCluster = workerCluster; _cfg = cfg; _resolver = resolver; _eventManager = eventManager; _appStatusCfg = appStatusCfg; _appServiceRegistry = appServiceRegistry; _zipService = zipService; _appCmds = appCmds; _appStatus = appStatus; _serviceDiscovery = serviceDiscovery; _appUpdates = appUpdates; systemStatus.Process(new AppStatusInfoProviderEvent() { ReporterName = nameof(bfgWorkerManager), Component = "Status", Info = WorkerManagerStatus }).Until(); }
public static IDisposable WatchForCompletion(IRxnManager <IRxn> rxnManage, IObservable <StartUnitTest[]> unitTestToRun, Action onComplete) { return(unitTestToRun.Select(tests => { var stopDOingWork = rxnManage.CreateSubscription <CommandResult>() .Where(_ => unitTestToRun != null) .Where(c => c.InResponseTo.BasicallyEquals(tests[0].Id)) //todo this this, should look at all unit tests .Do(_ => { $"Duration: {startedAt.Elapsed}".LogDebug(); if (iteration <= 0) { onComplete?.Invoke(); } }) .Until(); return stopDOingWork; }) .Until()); }
public bfgTestArenaProgressHub(bfgTestArenaProgressView testArena, IHubContext <bfgTestArenaProgressHub> context, IAppCommandService cmdService, IRxnManager <IRxn> historyBuffer) { _testArena = testArena; _context = context; _cmdService = cmdService; if (!theBfg.Args.Contains("save")) { historyBuffer.CreateSubscription <ITestDomainEvent>().Do(_testStream).Until(); } }
public IRxnRouteCfg <T> PublishTo <T>(IRxnManager <T> rxnManager) { return(new EventRouteToManagerCfg <T>(_conditions, rxnManager)); }
public static void WatchForTestUpdates(IRxnManager <IRxn> rxnManage) { rxnManage.CreateSubscription <UpdateSystemCommand>() .Do(_ => { _notUpdating = false; }) .Until(); }
public static IDisposable StartTestArena(string[] args, IObservable <StartUnitTest[]> testCfg, bfgCluster cluster, bfgWorkerManager workerManager, IRxnManager <IRxn> toFireOn, IAppServiceDiscovery discovery) { "Starting up TestArena".LogDebug(); if (_started.HasValue) { _started = DateTime.Now; } var stopAdvertising = bfgTestArenaApi.AdvertiseForWorkers(discovery, "all", $"http://{RxnApp.GetIpAddress()}:888"); theBfg.Use(cluster, workerManager); var stopWorkers = Disposable.Empty; if (args.Any(a => a.BasicallyEquals("fire"))) { stopWorkers = theBfg.StartTestArenaWorkers(args, testCfg).Until(); } var stopFiring = StartFiringWorkflow(args, testCfg, toFireOn); return(new CompositeDisposable(stopAdvertising, stopWorkers, stopFiring)); }
public IRxnRouteCfg <TBaseEvent> AndTo(IRxnManager <TBaseEvent> rxnManager) { Destinations.Add(rxnManager); return(this); }
public EventRouteToManagerCfg(IList <Func <object, bool> > conditions, IRxnManager <TBaseEvent> rxnManager) { Conditions = conditions; Destinations = new List <IRxnManager <TBaseEvent> >(new[] { rxnManager }); }
public AssertionFilter(IAppNav <Page, IRxnPageModel> appNav, IRxnManager <IRxn> eventManager) { _appNav = appNav; eventManager.CreateSubscription <ShakeGesture>().Do(_ => eventManager.Publish(new AssertModel(Snapshot(_appNav.Current.Model)))).Until(); }
/// <summary> /// Implements the firing sematics of the bfg, reponding to rapidly condintiously etc /// </summary> /// <param name="args"></param> /// <param name="unitTestToRun"></param> /// <param name="rxnManager"></param> /// <param name="resolver"></param> /// <returns></returns> public static IDisposable StartFiringWorkflow(string[] args, IObservable <StartUnitTest[]> unitTestToRun, IRxnManager <IRxn> rxnManager) { //todo: should be implemented with a rxnmediator, can seperate firestyle into injected logic classes if (args.Contains("continuously")) { WatchForTestUpdates(rxnManager); if (args.Contains("rapidly")) { DoWorkContiniously(rxnManager, unitTestToRun, () => FireRapidly(unitTestToRun)); } else { DoWorkContiniously(rxnManager, unitTestToRun, () => Fire(unitTestToRun)); } } else { if (args.Contains("rapidly")) { if (args.Contains("compete")) { FireCompeteRapidly(unitTestToRun); } else { FireRapidly(unitTestToRun); } } else { Fire(unitTestToRun); } } return(WatchForCompletion(rxnManager, unitTestToRun, () => { theBfg.IsCompleted.OnNext(new Unit()); theBfg.IsCompleted.OnCompleted(); })); }