private void OnStatusChange(GrainServiceStatus oldStatus, GrainServiceStatus newStatus) { if (oldStatus != GrainServiceStatus.Started && newStatus == GrainServiceStatus.Started) { ring.SubscribeToRangeChangeEvents(this); } if (oldStatus != GrainServiceStatus.Stopped && newStatus == GrainServiceStatus.Stopped) { ring.UnSubscribeFromRangeChangeEvents(this); } }
/// <summary>Invoked when service is being stopped</summary> /// <returns>A <see cref="Task"/> representing the work performed.</returns> public virtual Task Stop() { StoppedCancellationTokenSource.Cancel(); Logger.LogInformation( (int)ErrorCode.RS_ServiceStopping, "Stopping {TypeName} grain service", typeName); Status = GrainServiceStatus.Stopped; return(Task.CompletedTask); }
/// <summary> /// Deferred part of initialization that executes after the service is already started (to speed up startup). /// Sets Status to Started. /// </summary> protected virtual Task StartInBackground() { Status = GrainServiceStatus.Started; return(Task.CompletedTask); }