go.uber.org/cadence@v1.2.9/workflow/activity_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/internal" 27 ) 28 29 // ActivityOptions stores all activity-specific invocation parameters that will be stored inside of a context. 30 type ActivityOptions = internal.ActivityOptions 31 32 // LocalActivityOptions doc 33 type LocalActivityOptions = internal.LocalActivityOptions 34 35 // RetryPolicy specify how to retry activity if error happens. 36 type RetryPolicy = internal.RetryPolicy 37 38 // WithActivityOptions makes a copy of the context and adds the 39 // passed in options to the context. If an activity options exists, 40 // it will be overwritten by the passed in value as a whole. 41 // So specify all the values in the options as necessary, as values 42 // in the existing context options will not be carried over. 43 func WithActivityOptions(ctx Context, options ActivityOptions) Context { 44 return internal.WithActivityOptions(ctx, options) 45 } 46 47 // WithLocalActivityOptions makes a copy of the context and adds the 48 // passed in options to the context. If a local activity options exists, 49 // it will be overwritten by the passed in value. 50 func WithLocalActivityOptions(ctx Context, options LocalActivityOptions) Context { 51 return internal.WithLocalActivityOptions(ctx, options) 52 } 53 54 // WithTaskList makes a copy of the current context and update the taskList 55 // field in its activity options. An empty activity options will be created 56 // if it does not exist in the original context. 57 func WithTaskList(ctx Context, name string) Context { 58 return internal.WithTaskList(ctx, name) 59 } 60 61 // GetActivityTaskList returns tasklist in the Context's current ActivityOptions, 62 // or workflow.GetInfo(ctx).TaskListName if not set or empty 63 func GetActivityTaskList(ctx Context) string { 64 tl := internal.GetActivityTaskList(ctx) 65 if tl != nil && *tl != "" { 66 return *tl 67 } 68 return GetInfo(ctx).TaskListName 69 } 70 71 // WithScheduleToCloseTimeout makes a copy of the current context and update 72 // the ScheduleToCloseTimeout field in its activity options. An empty activity 73 // options will be created if it does not exist in the original context. 74 // 75 // Cadence time resolution is in seconds and the library uses math.Ceil(d.Seconds()) 76 // to calculate the final value. This is subject to change in the future. 77 func WithScheduleToCloseTimeout(ctx Context, d time.Duration) Context { 78 return internal.WithScheduleToCloseTimeout(ctx, d) 79 } 80 81 // WithScheduleToStartTimeout makes a copy of the current context and update 82 // the ScheduleToStartTimeout field in its activity options. An empty activity 83 // options will be created if it does not exist in the original context. 84 // 85 // Cadence time resolution is in seconds and the library uses math.Ceil(d.Seconds()) 86 // to calculate the final value. This is subject to change in the future. 87 func WithScheduleToStartTimeout(ctx Context, d time.Duration) Context { 88 return internal.WithScheduleToStartTimeout(ctx, d) 89 } 90 91 // WithStartToCloseTimeout makes a copy of the current context and update 92 // the StartToCloseTimeout field in its activity options. An empty activity 93 // options will be created if it does not exist in the original context. 94 // 95 // Cadence time resolution is in seconds and the library uses math.Ceil(d.Seconds()) 96 // to calculate the final value. This is subject to change in the future. 97 func WithStartToCloseTimeout(ctx Context, d time.Duration) Context { 98 return internal.WithStartToCloseTimeout(ctx, d) 99 } 100 101 // WithHeartbeatTimeout makes a copy of the current context and update 102 // the HeartbeatTimeout field in its activity options. An empty activity 103 // options will be created if it does not exist in the original context. 104 // 105 // Cadence time resolution is in seconds and the library uses math.Ceil(d.Seconds()) 106 // to calculate the final value. This is subject to change in the future. 107 func WithHeartbeatTimeout(ctx Context, d time.Duration) Context { 108 return internal.WithHeartbeatTimeout(ctx, d) 109 } 110 111 // WithWaitForCancellation makes a copy of the current context and update 112 // the WaitForCancellation field in its activity options. An empty activity 113 // options will be created if it does not exist in the original context. 114 func WithWaitForCancellation(ctx Context, wait bool) Context { 115 return internal.WithWaitForCancellation(ctx, wait) 116 } 117 118 // WithRetryPolicy makes a copy of the current context and update 119 // the RetryPolicy field in its activity options. An empty activity 120 // options will be created if it does not exist in the original context. 121 func WithRetryPolicy(ctx Context, retryPolicy RetryPolicy) Context { 122 return internal.WithRetryPolicy(ctx, retryPolicy) 123 }