go.uber.org/cadence@v1.2.9/workflow/workflow_options.go (about) 1 // Copyright (c) 2017 Uber Technologies, Inc. 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 package workflow 22 23 import ( 24 "time" 25 26 "go.uber.org/cadence/encoded" 27 "go.uber.org/cadence/internal" 28 ) 29 30 // WithChildOptions adds all workflow options to the context. 31 func WithChildOptions(ctx Context, cwo ChildWorkflowOptions) Context { 32 return internal.WithChildWorkflowOptions(ctx, cwo) 33 } 34 35 // WithWorkflowDomain adds a domain to the context. 36 func WithWorkflowDomain(ctx Context, name string) Context { 37 return internal.WithWorkflowDomain(ctx, name) 38 } 39 40 // WithWorkflowTaskList adds a task list to the context. 41 func WithWorkflowTaskList(ctx Context, name string) Context { 42 return internal.WithWorkflowTaskList(ctx, name) 43 } 44 45 // GetWorkflowTaskList returns tasklist in the Context's current ChildWorkflowOptions 46 // or workflow.GetInfo(ctx).TaskListName if not set or empty. 47 func GetWorkflowTaskList(ctx Context) string { 48 tl := internal.GetWorkflowTaskList(ctx) 49 if tl != nil && *tl != "" { 50 return *tl 51 } 52 return GetInfo(ctx).TaskListName 53 } 54 55 // WithWorkflowID adds a workflowID to the context. 56 func WithWorkflowID(ctx Context, workflowID string) Context { 57 return internal.WithWorkflowID(ctx, workflowID) 58 } 59 60 // WithExecutionStartToCloseTimeout adds a workflow execution timeout to the context. 61 func WithExecutionStartToCloseTimeout(ctx Context, d time.Duration) Context { 62 return internal.WithExecutionStartToCloseTimeout(ctx, d) 63 } 64 65 // WithWorkflowTaskStartToCloseTimeout adds a decision timeout to the context. 66 func WithWorkflowTaskStartToCloseTimeout(ctx Context, d time.Duration) Context { 67 return internal.WithWorkflowTaskStartToCloseTimeout(ctx, d) 68 } 69 70 // WithDataConverter adds DataConverter to the context. 71 func WithDataConverter(ctx Context, dc encoded.DataConverter) Context { 72 return internal.WithDataConverter(ctx, dc) 73 }