(parent context.Context, iterable Iterable, operatorFactory func() operator, forceSeq, bypassGather bool, opts ...Option)
| 128 | } |
| 129 | |
| 130 | func observable(parent context.Context, iterable Iterable, operatorFactory func() operator, forceSeq, bypassGather bool, opts ...Option) Observable { |
| 131 | option := parseOptions(opts...) |
| 132 | parallel, _ := option.getPool() |
| 133 | |
| 134 | if option.isEagerObservation() { |
| 135 | next := option.buildChannel() |
| 136 | ctx := option.buildContext(parent) |
| 137 | if forceSeq || !parallel { |
| 138 | runSequential(ctx, next, iterable, operatorFactory, option, opts...) |
| 139 | } else { |
| 140 | runParallel(ctx, next, iterable.Observe(opts...), operatorFactory, bypassGather, option, opts...) |
| 141 | } |
| 142 | return &ObservableImpl{iterable: newChannelIterable(next)} |
| 143 | } |
| 144 | |
| 145 | if forceSeq || !parallel { |
| 146 | return &ObservableImpl{ |
| 147 | iterable: newFactoryIterable(func(propagatedOptions ...Option) <-chan Item { |
| 148 | mergedOptions := append(opts, propagatedOptions...) |
| 149 | option := parseOptions(mergedOptions...) |
| 150 | |
| 151 | next := option.buildChannel() |
| 152 | ctx := option.buildContext(parent) |
| 153 | runSequential(ctx, next, iterable, operatorFactory, option, mergedOptions...) |
| 154 | return next |
| 155 | }), |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | if serialized, f := option.isSerialized(); serialized { |
| 160 | firstItemIDCh := make(chan Item, 1) |
| 161 | fromCh := make(chan Item, 1) |
| 162 | obs := &ObservableImpl{ |
| 163 | iterable: newFactoryIterable(func(propagatedOptions ...Option) <-chan Item { |
| 164 | mergedOptions := append(opts, propagatedOptions...) |
| 165 | option := parseOptions(mergedOptions...) |
| 166 | |
| 167 | next := option.buildChannel() |
| 168 | ctx := option.buildContext(parent) |
| 169 | observe := iterable.Observe(opts...) |
| 170 | go func() { |
| 171 | select { |
| 172 | case <-ctx.Done(): |
| 173 | return |
| 174 | case firstItemID := <-firstItemIDCh: |
| 175 | if firstItemID.Error() { |
| 176 | firstItemID.SendContext(ctx, fromCh) |
| 177 | return |
| 178 | } |
| 179 | Of(firstItemID.V.(int)).SendContext(ctx, fromCh) |
| 180 | runParallel(ctx, next, observe, operatorFactory, bypassGather, option, mergedOptions...) |
| 181 | } |
| 182 | }() |
| 183 | runFirstItem(ctx, f, firstItemIDCh, observe, next, operatorFactory, option, mergedOptions...) |
| 184 | return next |
| 185 | }), |
| 186 | } |
| 187 | return obs.serialize(parent, fromCh, f) |
no test coverage detected
searching dependent graphs…