コード例 #1
0
        /// <summary>
        ///  this is the main entry point for function runtime
        /// </summary>
        public static void RegisterProvider(IWorkerStatusProvider provider)
        {
            _instance?.Dispose();
            _instance = null;

            if (!Enabled)
            {
                AppServiceEventSource.Instance.Warning(AppServiceSettings.SiteName, AppServiceSettings.CurrentStampName, AppServiceSettings.WorkerName, "Runtime scaling is not enabled.");

                return;
            }

            if (provider != null)
            {
                AppServiceScaleManager instance = null;
                try
                {
                    instance = new AppServiceScaleManager(new AppServiceWorkerInfoProvider(provider));
                    instance.Start();

                    // assign
                    _instance = instance;
                    instance  = null;
                }
                finally
                {
                    instance?.Dispose();
                }
            }

            AppServiceEventSource.Instance.Information(AppServiceSettings.SiteName, AppServiceSettings.CurrentStampName, AppServiceSettings.WorkerName, string.Format("Worker status provider is {0}.", provider != null ? "registered" : "unregistered"));
        }
 public AppServiceWorkerInfoProvider(IWorkerStatusProvider provider)
 {
     _provider = provider;
 }