public void Participate(ILifecycleObservable <TestStages> lifecycle) { lifecycle.Subscribe(TestStages.Down, ct => OnStartStage(TestStages.Down), ct => OnStopStage(TestStages.Down)); lifecycle.Subscribe(TestStages.Initialize, ct => OnStartStage(TestStages.Initialize), ct => OnStopStage(TestStages.Initialize)); lifecycle.Subscribe(TestStages.Configure, ct => OnStartStage(TestStages.Configure), ct => OnStopStage(TestStages.Configure)); lifecycle.Subscribe(TestStages.Run, ct => OnStartStage(TestStages.Run), ct => OnStopStage(TestStages.Run)); }
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart, Func <CancellationToken, Task> onStop) { if (observable is null) { throw new ArgumentNullException(nameof(observable)); } if (onStart is null) { throw new ArgumentNullException(nameof(onStart)); } if (onStop is null) { var observer = new StartupObserver(onStart); return(observer.Registration = observable.Subscribe(observerName, stage, observer)); } return(observable.Subscribe(observerName, stage, new Observer(onStart, onStop))); }
public DummySilo( ILifecycleObservable lifecycle, ILoggerFactory loggerFactory, IMembershipOracle membershipOracle, IReminderService reminderService, IMessageCenter messageCenter, IRuntime runtime) { logger = loggerFactory.CreateLogger <DummySilo>(); lifecycle.Subscribe(Initialize, Start, Stop); }
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart, Func <CancellationToken, Task> onStop) { if (observable == null) { throw new ArgumentNullException(nameof(observable)); } if (onStart == null) { throw new ArgumentNullException(nameof(onStart)); } if (onStop == null) { throw new ArgumentNullException(nameof(onStop)); } return(observable.Subscribe(observerName, stage, new Observer(onStart, onStop))); }
public static IDisposable Subscribe(this ILifecycleObservable observable, Func <Task> onInitialize, Func <Task> onStart, Func <Task> onStop) { if (observable == null) { throw new ArgumentNullException(nameof(observable)); } if (onInitialize == null) { throw new ArgumentNullException(nameof(onInitialize)); } if (onStart == null) { throw new ArgumentNullException(nameof(onStart)); } if (onStop == null) { throw new ArgumentNullException(nameof(onStop)); } return(observable.Subscribe(new Observer(onInitialize, onStart, onStop))); }
public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart) { return(observable.Subscribe(observerName, stage, onStart, NoOp)); }
public virtual void Participate(ILifecycleObservable <GrainLifecycleStage> lifecycle) { lifecycle.Subscribe(GrainLifecycleStage.SetupState, OnSetupState); }
public Thingy(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory) { logger = loggerFactory.CreateLogger <Thingy>(); lifecycle.Subscribe(Initialize, Start, Stop); }
/// <summary> /// Creates a disposable subscription to the lifecycle. /// </summary> /// <typeparam name="TObserver"> /// The observer type, used for diagnostics. /// </typeparam> /// <param name="observable">The lifecycle observable.</param> /// <param name="stage">The stage to participate in.</param> /// <param name="observer">The observer.</param> /// <returns>A <see cref="IDisposable"/> instance which can be disposed to unsubscribe the observer from the lifecycle.</returns> public static IDisposable Subscribe <TObserver>(this ILifecycleObservable observable, int stage, ILifecycleObserver observer) { return(observable.Subscribe(typeof(TObserver).FullName, stage, observer)); }
/// <summary> /// Creates a disposable subscription to the lifecycle. /// </summary> /// <param name="observable">The lifecycle observable.</param> /// <param name="stage">The stage to participate in.</param> /// <param name="observer">The observer.</param> /// <returns>A <see cref="IDisposable"/> instance which can be disposed to unsubscribe the observer from the lifecycle.</returns> public static IDisposable Subscribe(this ILifecycleObservable observable, int stage, ILifecycleObserver observer) { return(observable.Subscribe(observer.GetType().FullName, stage, observer)); }
public Lifecycle(ILifecycleObservable lifecycle) { lifecycle.Subscribe(this); subscribers = new ConcurrentDictionary <object, OrderedObserver>(); }
public Thingy(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory) { logger = loggerFactory.CreateLogger <Thingy>(); lifecycle.Subscribe(this); }
public static IDisposable Subscribe <TStage>(this ILifecycleObservable <TStage> observable, TStage stage, Func <CancellationToken, Task> onStart) { return(observable.Subscribe(stage, new Observer(onStart, NoOp))); }
public static IDisposable Subscribe(this ILifecycleObservable observable, Func <Task> onInitialize) { return(observable.Subscribe(new Observer(onInitialize, NoOp, NoOp))); }
public static IDisposable Subscribe(this ILifecycleObservable observable, Func <Task> onStart, Func <Task> onStop) { return(observable.Subscribe(new Observer(NoOp, onStart, onStop))); }
public static IDisposable Subscribe <TObserver>(this ILifecycleObservable observable, int stage, Func <CancellationToken, Task> onStart) { return(observable.Subscribe <TObserver>(stage, onStart, NoOperation)); }
public DummyMessageCenter(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory) { logger = loggerFactory.CreateLogger <DummyMessageCenter>(); lifecycle.Subscribe(Initialize, Start, Stop); }
private StartupObserver(ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart) { _onStart = onStart; _registration = observable.Subscribe(observerName, stage, this); }
public void Configure(string azureConnectionString) { connectionString = azureConnectionString; lifecycle.Subscribe(Initialize); }
/// <summary> /// Creates a disposable subscription to the lifecycle. /// </summary> /// <typeparam name="TObserver"> /// The observer type, used for diagnostics. /// </typeparam> /// <param name="observable">The lifecycle observable.</param> /// <param name="stage">The stage to participate in.</param> /// <param name="onStart">The delegate called when starting the specified lifecycle stage.</param> /// <returns>A <see cref="IDisposable"/> instance which can be disposed to unsubscribe the observer from the lifecycle.</returns> public static IDisposable Subscribe <TObserver>(this ILifecycleObservable observable, int stage, Func <CancellationToken, Task> onStart) { return(observable.Subscribe(typeof(TObserver).FullName, stage, onStart, null)); }
public DummyReminderService(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory) { logger = loggerFactory.CreateLogger <DummyReminderService>(); lifecycle.Subscribe(Initialize, Start, Stop); }
public static IDisposable Subscribe(this ILifecycleObservable observable, GrainLifecycleStage stage, Func <CancellationToken, Task> onStart) { return(observable.Subscribe((int)stage, onStart)); }
public DummyMembershipOracle(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory) { logger = loggerFactory.CreateLogger <DummyMembershipOracle>(); lifecycle.Subscribe(Initialize, Start, Stop); }