Skip to content

Commit b5f4223

Browse files
committed
lint
1 parent 0c09201 commit b5f4223

File tree

1 file changed

+37
-36
lines changed

1 file changed

+37
-36
lines changed

workflow/context.go

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
package workflow
2222

2323
import (
24-
"fmt"
25-
2624
"github.com/opentracing/opentracing-go"
25+
2726
"go.uber.org/cadence/internal"
2827
)
2928

@@ -100,42 +99,44 @@ func GetSpanContext(ctx Context) opentracing.SpanContext {
10099
// This is useful to modify baggage items of current workflow and pass it to activities and child workflows.
101100
//
102101
// Example Usage:
103-
// func goodWorkflow(ctx Context) (string, error) {
104-
// // start a short lived new workflow span within SideEffect to avoid duplicate span creation during replay
105-
// spanContextValue := SideEffect(ctx, func(ctx Context) interface{} {
106-
// wSpan := opentracing.StartSpan("workflow-operation-with-new-span", opentracing.ChildOf(GetSpanContext(ctx)))
107-
// defer wSpan.Finish()
108-
// wSpan.SetTag("some-key", "some-value")
109-
// return wSpan.Context()
110-
// })
111-
// var spanContext opentracing.SpanContext
112-
// err := spanContextValue.Get(&spanContext)
113-
// if err != nil {
114-
// return "",fmt.Errorf("failed to get span context: %w", err)
115-
// }
116-
//
117-
// aCtx := WithSpanContext(ctx, spanContext)
118-
// var activityFooResult string
119-
// err = ExecuteActivity(aCtx, activityFoo).Get(aCtx, &activityFooResult)
120-
// return activityFooResult, err
121-
// }
102+
//
103+
// func goodWorkflow(ctx Context) (string, error) {
104+
// // start a short lived new workflow span within SideEffect to avoid duplicate span creation during replay
105+
// spanContextValue := SideEffect(ctx, func(ctx Context) interface{} {
106+
// wSpan := opentracing.StartSpan("workflow-operation-with-new-span", opentracing.ChildOf(GetSpanContext(ctx)))
107+
// defer wSpan.Finish()
108+
// wSpan.SetTag("some-key", "some-value")
109+
// return wSpan.Context()
110+
// })
111+
// var spanContext opentracing.SpanContext
112+
// err := spanContextValue.Get(&spanContext)
113+
// if err != nil {
114+
// return "",fmt.Errorf("failed to get span context: %w", err)
115+
// }
116+
//
117+
// aCtx := WithSpanContext(ctx, spanContext)
118+
// var activityFooResult string
119+
// err = ExecuteActivity(aCtx, activityFoo).Get(aCtx, &activityFooResult)
120+
// return activityFooResult, err
121+
// }
122122
//
123123
// Bad Example:
124-
// func badWorkflow(ctx Context) (string, error) {
125-
// // start a new workflow span for EVERY REPLAY
126-
// wSpan := opentracing.StartSpan("workflow-operation", opentracing.ChildOf(GetSpanContext(ctx)))
127-
// wSpan.SetBaggageItem("some-key", "some-value")
128-
// // pass the new span context to activity
129-
// aCtx := WithSpanContext(ctx, wSpan.Context())
130-
// var activityFooResult string
131-
// err := ExecuteActivity(aCtx, activityFoo).Get(aCtx, &activityFooResult)
132-
// wSpan.Finish()
133-
// return activityFooResult, err
134-
// }
135-
//
136-
// func activityFoo(ctx Context) (string, error) {
137-
// return "activity-foo-result", nil
138-
// }
124+
//
125+
// func badWorkflow(ctx Context) (string, error) {
126+
// // start a new workflow span for EVERY REPLAY
127+
// wSpan := opentracing.StartSpan("workflow-operation", opentracing.ChildOf(GetSpanContext(ctx)))
128+
// wSpan.SetBaggageItem("some-key", "some-value")
129+
// // pass the new span context to activity
130+
// aCtx := WithSpanContext(ctx, wSpan.Context())
131+
// var activityFooResult string
132+
// err := ExecuteActivity(aCtx, activityFoo).Get(aCtx, &activityFooResult)
133+
// wSpan.Finish()
134+
// return activityFooResult, err
135+
// }
136+
//
137+
// func activityFoo(ctx Context) (string, error) {
138+
// return "activity-foo-result", nil
139+
// }
139140
func WithSpanContext(ctx Context, spanContext opentracing.SpanContext) Context {
140141
return internal.WithSpanContext(ctx, spanContext)
141142
}

0 commit comments

Comments
 (0)