Esempio n. 1
0
 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));
 }
Esempio n. 2
0
        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)));
        }
Esempio n. 3
0
 public DummySilo(
     ILifecycleObservable lifecycle,
     ILoggerFactory loggerFactory,
     IMembershipOracle membershipOracle,
     IReminderService reminderService,
     IMessageCenter messageCenter,
     IRuntime runtime)
 {
     logger = loggerFactory.CreateLogger <DummySilo>();
     lifecycle.Subscribe(Initialize, Start, Stop);
 }
Esempio n. 4
0
        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)));
        }
Esempio n. 5
0
        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)));
        }
Esempio n. 6
0
 public static IDisposable Subscribe(this ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart)
 {
     return(observable.Subscribe(observerName, stage, onStart, NoOp));
 }
Esempio n. 7
0
 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);
 }
Esempio n. 9
0
 /// <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));
 }
Esempio n. 10
0
 /// <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));
 }
Esempio n. 11
0
 public Lifecycle(ILifecycleObservable lifecycle)
 {
     lifecycle.Subscribe(this);
     subscribers = new ConcurrentDictionary <object, OrderedObserver>();
 }
Esempio n. 12
0
 public Thingy(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory)
 {
     logger = loggerFactory.CreateLogger <Thingy>();
     lifecycle.Subscribe(this);
 }
Esempio n. 13
0
 public static IDisposable Subscribe <TStage>(this ILifecycleObservable <TStage> observable, TStage stage, Func <CancellationToken, Task> onStart)
 {
     return(observable.Subscribe(stage, new Observer(onStart, NoOp)));
 }
Esempio n. 14
0
 public static IDisposable Subscribe(this ILifecycleObservable observable, Func <Task> onInitialize)
 {
     return(observable.Subscribe(new Observer(onInitialize, NoOp, NoOp)));
 }
Esempio n. 15
0
 public static IDisposable Subscribe(this ILifecycleObservable observable, Func <Task> onStart, Func <Task> onStop)
 {
     return(observable.Subscribe(new Observer(NoOp, onStart, onStop)));
 }
Esempio n. 16
0
 public static IDisposable Subscribe <TObserver>(this ILifecycleObservable observable, int stage, Func <CancellationToken, Task> onStart)
 {
     return(observable.Subscribe <TObserver>(stage, onStart, NoOperation));
 }
Esempio n. 17
0
 public DummyMessageCenter(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory)
 {
     logger = loggerFactory.CreateLogger <DummyMessageCenter>();
     lifecycle.Subscribe(Initialize, Start, Stop);
 }
Esempio n. 18
0
 private StartupObserver(ILifecycleObservable observable, string observerName, int stage, Func <CancellationToken, Task> onStart)
 {
     _onStart      = onStart;
     _registration = observable.Subscribe(observerName, stage, this);
 }
Esempio n. 19
0
 public void Configure(string azureConnectionString)
 {
     connectionString = azureConnectionString;
     lifecycle.Subscribe(Initialize);
 }
Esempio n. 20
0
 /// <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));
 }
Esempio n. 21
0
 public DummyReminderService(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory)
 {
     logger = loggerFactory.CreateLogger <DummyReminderService>();
     lifecycle.Subscribe(Initialize, Start, Stop);
 }
Esempio n. 22
0
 public static IDisposable Subscribe(this ILifecycleObservable observable, GrainLifecycleStage stage, Func <CancellationToken, Task> onStart)
 {
     return(observable.Subscribe((int)stage, onStart));
 }
Esempio n. 23
0
 public DummyMembershipOracle(ILifecycleObservable lifecycle, ILoggerFactory loggerFactory)
 {
     logger = loggerFactory.CreateLogger <DummyMembershipOracle>();
     lifecycle.Subscribe(Initialize, Start, Stop);
 }