Beispiel #1
0
        /// <summary>
        /// Attempts to cancel the associated workflow.
        /// </summary>
        /// <returns>The tracking <see cref="Task"/>.</returns>
        public async Task CancelAsync()
        {
            await SyncContext.Clear;

            EnsureStarted();

            if (Execution == null)
            {
                throw new InvalidOperationException("The stub can't cancel the workflow because it doesn't have the workflow execution.");
            }

            await client.CancelWorkflowAsync(Execution, client.ResolveNamespace(Options?.Namespace));
        }
Beispiel #2
0
        /// <summary>
        /// Internal constructor for use outside of a workflow.
        /// </summary>
        /// <param name="client">Specifies the associated client.</param>
        /// <param name="execution">Specifies the target workflow execution.</param>
        /// <param name="namespace">Optionally specifies the target namespace (defaults to the client's default namespace).</param>
        internal ExternalWorkflowStub(TemporalClient client, WorkflowExecution execution, string @namespace = null)
        {
            Covenant.Requires <ArgumentNullException>(client != null, nameof(client));
            Covenant.Requires <ArgumentNullException>(execution != null, nameof(execution));

            this.client     = client;
            this.@namespace = client.ResolveNamespace(@namespace);
            this.Execution  = execution;
        }
Beispiel #3
0
        /// <summary>
        /// Internal constructor for use within a workflow.
        /// </summary>
        /// <param name="parentWorkflow">Specifies the parent workflow.</param>
        /// <param name="execution">Specifies the target workflow execution.</param>
        /// <param name="namespace">Optionally specifies the target namespace (defaults to the client's default namespace).</param>
        internal ExternalWorkflowStub(Workflow parentWorkflow, WorkflowExecution execution, string @namespace = null)
        {
            Covenant.Requires <ArgumentNullException>(parentWorkflow != null, nameof(parentWorkflow));
            Covenant.Requires <ArgumentNullException>(execution != null, nameof(execution));

            this.parentWorkflow = parentWorkflow;
            this.client         = parentWorkflow.Client;
            this.@namespace     = client.ResolveNamespace(@namespace);
            this.Execution      = execution;
        }