Beispiel #1
0
        /// <summary>
        /// Converts the instance into an internal <see cref="InternalStartWorkflowOptions"/>.
        /// </summary>
        /// <param name="client">The <see cref="CadenceClient"/>.</param>
        /// <param name="taskList">Optionally specifies the target task list.</param>
        /// <param name="methodAttribute">Optionally specifies a <see cref="WorkflowMethodAttribute"/>.</param>
        /// <returns>The corresponding <see cref="InternalStartWorkflowOptions"/>.</returns>
        internal InternalStartWorkflowOptions ToInternal(CadenceClient client, string taskList = null, WorkflowMethodAttribute methodAttribute = null)
        {
            Covenant.Requires <ArgumentNullException>(client != null);

            taskList = client.ResolveTaskList(taskList);

            // Merge optional settings from these options and the method attribute.

            var decisionTaskStartToCloseTimeout = TimeSpan.FromSeconds(10);
            var executionStartToCloseTimeout    = CadenceClient.DefaultTimeout;
            var workflowIdReusePolicy           = global::Neon.Cadence.WorkflowIdReusePolicy.AllowDuplicateFailedOnly;

            if (methodAttribute != null)
            {
                if (string.IsNullOrEmpty(taskList))
                {
                    if (methodAttribute.TaskList != null)
                    {
                        taskList = methodAttribute.TaskList;
                    }
                    else
                    {
                        taskList = client.Settings.DefaultTaskList;
                    }
                }

                if (!DecisionTaskStartToCloseTimeout.HasValue && methodAttribute.TaskStartToCloseTimeoutSeconds > 0)
                {
                    decisionTaskStartToCloseTimeout = TimeSpan.FromSeconds(methodAttribute.TaskStartToCloseTimeoutSeconds);
                }

                if (!ExecutionStartToCloseTimeout.HasValue && methodAttribute.ExecutionStartToCloseTimeoutSeconds > 0)
                {
                    executionStartToCloseTimeout = TimeSpan.FromSeconds(methodAttribute.ExecutionStartToCloseTimeoutSeconds);
                }

                if (!WorkflowIdReusePolicy.HasValue && methodAttribute.WorkflowIdReusePolicy.HasValue)
                {
                    workflowIdReusePolicy = methodAttribute.WorkflowIdReusePolicy.Value;
                }
            }

            return(new InternalStartWorkflowOptions()
            {
                ID = this.WorkflowId,
                TaskList = taskList,
                DecisionTaskStartToCloseTimeout = CadenceHelper.ToCadence(decisionTaskStartToCloseTimeout),
                ExecutionStartToCloseTimeout = CadenceHelper.ToCadence(executionStartToCloseTimeout),
                RetryPolicy = this.RetryOptions?.ToInternal(),
                WorkflowIdReusePolicy = (int)workflowIdReusePolicy,
                CronSchedule = this.CronSchedule,
                Memo = this.Memo
            });
        }