NetheriteOrchestrationServiceSettings GetNetheriteOrchestrationServiceSettings(string taskHubNameOverride = null)
        {
            var eventSourcedSettings = new NetheriteOrchestrationServiceSettings();

            // override DTFx defaults to the defaults we want to use in DF
            eventSourcedSettings.ThrowExceptionOnInvalidDedupeStatus = true;

            // copy all applicable fields from both the options and the storageProvider options
            JsonConvert.PopulateObject(JsonConvert.SerializeObject(this.extensionOptions), eventSourcedSettings);
            JsonConvert.PopulateObject(JsonConvert.SerializeObject(this.extensionOptions.StorageProvider), eventSourcedSettings);

            // if worker id is specified in environment, it overrides the configured setting
            string workerId = Environment.GetEnvironmentVariable("WorkerId");

            if (!string.IsNullOrEmpty(workerId))
            {
                if (workerId == "HostId")
                {
                    workerId = this.hostIdProvider.GetHostIdAsync(CancellationToken.None).GetAwaiter().GetResult();
                }
                eventSourcedSettings.WorkerId = workerId;
            }

            eventSourcedSettings.HubName = this.extensionOptions.HubName;

            if (taskHubNameOverride != null)
            {
                eventSourcedSettings.HubName = taskHubNameOverride;
            }

            eventSourcedSettings.Validate((name) => this.connectionStringResolver.Resolve(name));

            if (this.TraceToConsole || this.TraceToBlob)
            {
                // capture trace events generated in the backend and redirect them to additional sinks
                this.loggerFactory = new LoggerFactoryWrapper(this.loggerFactory, eventSourcedSettings.HubName, eventSourcedSettings.WorkerId, this);
            }

            return(eventSourcedSettings);
        }
        public static NetheriteOrchestrationServiceSettings GetNetheriteOrchestrationServiceSettings()
        {
            var settings = new NetheriteOrchestrationServiceSettings
            {
                StorageConnectionName   = StorageConnectionName,
                EventHubsConnectionName = EventHubsConnectionName,
                HubName = TaskHubName,
                TransportLogLevelLimit = LogLevel.Trace,
                StorageLogLevelLimit   = LogLevel.Trace,
                LogLevelLimit          = LogLevel.Trace,
                EventLogLevelLimit     = LogLevel.Trace,
                WorkItemLogLevelLimit  = LogLevel.Trace,
                TakeStateCheckpointWhenStoppingPartition = true,  // set to false for testing recovery from log
                UseAlternateObjectStore     = false,              // set to true to bypass FasterKV; default is false
                MaxTimeMsBetweenCheckpoints = 1000000000,         // set this low for testing frequent checkpointing
                //MaxNumberBytesBetweenCheckpoints = 10000000, // set this low for testing frequent checkpointing
                //MaxNumberEventsBetweenCheckpoints = 10, // set this low for testing frequent checkpointing
            };

            settings.Validate((name) => Environment.GetEnvironmentVariable(name));

            return(settings);
        }