(parent context.Context, iterable Iterable, operatorFactory func() operator, forceSeq, bypassGather bool, opts ...Option)
| 231 | } |
| 232 | |
| 233 | func optionalSingle(parent context.Context, iterable Iterable, operatorFactory func() operator, forceSeq, bypassGather bool, opts ...Option) OptionalSingle { |
| 234 | option := parseOptions(opts...) |
| 235 | ctx := option.buildContext(parent) |
| 236 | parallel, _ := option.getPool() |
| 237 | |
| 238 | if option.isEagerObservation() { |
| 239 | next := option.buildChannel() |
| 240 | if forceSeq || !parallel { |
| 241 | runSequential(ctx, next, iterable, operatorFactory, option, opts...) |
| 242 | } else { |
| 243 | runParallel(ctx, next, iterable.Observe(opts...), operatorFactory, bypassGather, option, opts...) |
| 244 | } |
| 245 | return &OptionalSingleImpl{iterable: newChannelIterable(next)} |
| 246 | } |
| 247 | |
| 248 | return &OptionalSingleImpl{ |
| 249 | parent: ctx, |
| 250 | iterable: newFactoryIterable(func(propagatedOptions ...Option) <-chan Item { |
| 251 | mergedOptions := append(opts, propagatedOptions...) |
| 252 | option = parseOptions(mergedOptions...) |
| 253 | |
| 254 | next := option.buildChannel() |
| 255 | ctx := option.buildContext(parent) |
| 256 | if forceSeq || !parallel { |
| 257 | runSequential(ctx, next, iterable, operatorFactory, option, mergedOptions...) |
| 258 | } else { |
| 259 | runParallel(ctx, next, iterable.Observe(mergedOptions...), operatorFactory, bypassGather, option, mergedOptions...) |
| 260 | } |
| 261 | return next |
| 262 | }), |
| 263 | } |
| 264 | } |
| 265 | |
| 266 | func runSequential(ctx context.Context, next chan Item, iterable Iterable, operatorFactory func() operator, option Option, opts ...Option) { |
| 267 | observe := iterable.Observe(opts...) |
no test coverage detected
searching dependent graphs…